diff --git a/Razor.sln b/Razor.sln index a84be275c9..6566b6d164 100644 --- a/Razor.sln +++ b/Razor.sln @@ -26,14 +26,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime.Test", "test\Microsoft.AspNetCore.Razor.Runtime.Test\Microsoft.AspNetCore.Razor.Runtime.Test.csproj", "{277AB67E-9C8D-4799-A18C-C628E70A8664}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CodeAnalysis.Razor.Workspaces", "src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj", "{0F265874-C592-448B-BC4F-3430AB03E0DC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Razor.Workspaces", "src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj", "{0F265874-C592-448B-BC4F-3430AB03E0DC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CodeAnalysis.Remote.Razor", "src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj", "{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Remote.Razor", "src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj", "{4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tooling", "tooling", "{C0CC1E1F-1559-44DE-93A8-63259CEA2AAB}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.Razor", "tooling\Microsoft.VisualStudio.LanguageServices.Razor\Microsoft.VisualStudio.LanguageServices.Razor.csproj", "{53489966-7486-434F-AA76-6FBC488E3D29}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualStudio.RazorExtension", "tooling\Microsoft.VisualStudio.RazorExtension\Microsoft.VisualStudio.RazorExtension.csproj", "{D66B45B5-CBFD-4947-81F1-F30AB80EA992}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -164,6 +166,18 @@ Global {53489966-7486-434F-AA76-6FBC488E3D29}.Release|x64.Build.0 = Release|x64 {53489966-7486-434F-AA76-6FBC488E3D29}.Release|x86.ActiveCfg = Release|x86 {53489966-7486-434F-AA76-6FBC488E3D29}.Release|x86.Build.0 = Release|x86 + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Debug|x64.ActiveCfg = Debug|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Debug|x64.Build.0 = Debug|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Debug|x86.ActiveCfg = Debug|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Debug|x86.Build.0 = Debug|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Release|Any CPU.Build.0 = Release|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Release|x64.ActiveCfg = Release|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Release|x64.Build.0 = Release|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Release|x86.ActiveCfg = Release|Any CPU + {D66B45B5-CBFD-4947-81F1-F30AB80EA992}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -179,5 +193,6 @@ Global {0F265874-C592-448B-BC4F-3430AB03E0DC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {4EAD959D-73B2-4FB2-B46F-16CEB1EF49D4} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {53489966-7486-434F-AA76-6FBC488E3D29} = {C0CC1E1F-1559-44DE-93A8-63259CEA2AAB} + {D66B45B5-CBFD-4947-81F1-F30AB80EA992} = {C0CC1E1F-1559-44DE-93A8-63259CEA2AAB} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Razor.Evolution/Properties/AssemblyInfo.cs index 7147bc02a9..5e389a08a2 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/Properties/AssemblyInfo.cs @@ -6,4 +6,5 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj index f6c1a47d9f..4232f2a72a 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/Microsoft.CodeAnalysis.Razor.Workspaces.csproj @@ -23,6 +23,7 @@ + diff --git a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Properties/AssemblyInfo.cs b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Properties/AssemblyInfo.cs index c6956d41ad..a827ebd2da 100644 --- a/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Properties/AssemblyInfo.cs +++ b/tooling/Microsoft.VisualStudio.LanguageServices.Razor/Properties/AssemblyInfo.cs @@ -3,5 +3,6 @@ using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/Behaviors/ItemSelectedBehavior.cs b/tooling/Microsoft.VisualStudio.RazorExtension/Behaviors/ItemSelectedBehavior.cs new file mode 100644 index 0000000000..1a709324a9 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/Behaviors/ItemSelectedBehavior.cs @@ -0,0 +1,56 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Input; + +namespace Microsoft.VisualStudio.RazorExtension.Behaviors +{ + public static class ItemSelectedBehavior + { + public static DependencyProperty ItemSelectedProperty = + DependencyProperty.RegisterAttached(nameof(Selector.SelectedItem), + typeof(ICommand), + typeof(ItemSelectedBehavior), + new FrameworkPropertyMetadata(null, new PropertyChangedCallback(ItemSelectedChanged))); + + public static ICommand GetItemSelected(DependencyObject target) + { + return (ICommand)target.GetValue(ItemSelectedProperty); + } + + public static void SetItemSelected(DependencyObject target, ICommand value) + { + target.SetValue(ItemSelectedProperty, value); + } + + private static void ItemSelectedChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) + { + var element = target as Selector; + if (element != null) + { + if ((e.NewValue != null) && (e.OldValue == null)) + { + element.SelectionChanged += Selector_SelectionChanged; + } + + else if ((e.NewValue == null) && (e.OldValue != null)) + { + element.SelectionChanged -= Selector_SelectionChanged; + } + } + } + + private static void Selector_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + var element = sender as Selector; + if (element != null) + { + ICommand command = (ICommand)GetItemSelected(element); + command.Execute(element.SelectedItem); + } + } + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj new file mode 100644 index 0000000000..952240b082 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/Microsoft.VisualStudio.RazorExtension.csproj @@ -0,0 +1,398 @@ + + + + + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + true + true + ..\..\build\Key.snk + + RoslynDev + + Program + $(DevEnvDir)devenv.exe + /rootsuffix RoslynDev /log + + + + Debug + AnyCPU + 2.0 + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {D66B45B5-CBFD-4947-81F1-F30AB80EA992} + Library + Properties + Microsoft.VisualStudio.RazorExtension + Microsoft.VisualStudio.RazorExtension + v4.6 + true + true + true + true + true + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + RazorInfoToolWindowControl.xaml + + + + + + + + + + + + Always + true + + + Designer + + + + + False + + + False + + + False + + + False + + + ..\..\packages\ManagedEsent.1.9.4\lib\net40\Esent.Interop.dll + + + ..\..\packages\Microsoft.CodeAnalysis.Common.2.0.0-rc3-61308-02\lib\netstandard1.3\Microsoft.CodeAnalysis.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0-rc3-61308-02\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.0.0-rc3-61308-02\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll + + + ..\..\packages\Microsoft.CodeAnalysis.Elfie.0.10.6-rc2\lib\net46\Microsoft.CodeAnalysis.Elfie.dll + + + ..\..\packages\Microsoft.CodeAnalysis.VisualBasic.2.0.0-rc3-61308-02\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.dll + True + + + ..\..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.2.0.0-rc3-61308-02\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll + + + ..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0-rc3-61308-02\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll + + + ..\..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0-rc3-61308-02\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll + + + + False + + + ..\..\packages\Microsoft.VisualStudio.ComponentModelHost.15.0.25824-RC\lib\net45\Microsoft.VisualStudio.ComponentModelHost.dll + True + + + ..\..\packages\Microsoft.VisualStudio.CoreUtility.15.0.25901-RC\lib\net45\Microsoft.VisualStudio.CoreUtility.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Imaging.15.0.25901-RC\lib\net45\Microsoft.VisualStudio.Imaging.dll + True + + + ..\..\packages\Microsoft.VisualStudio.LanguageServices.2.0.0-rc3-61308-02\lib\net46\Microsoft.VisualStudio.LanguageServices.dll + + + ..\..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Shell.15.0.15.0.25901-RC\lib\Microsoft.VisualStudio.Shell.15.0.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Shell.Framework.15.0.25901-RC\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll + True + + + True + ..\..\packages\Microsoft.VisualStudio.Shell.Interop.10.0.10.0.30319\lib\Microsoft.VisualStudio.Shell.Interop.10.0.dll + True + + + True + ..\..\packages\Microsoft.VisualStudio.Shell.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll + True + + + True + ..\..\packages\Microsoft.VisualStudio.Shell.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.Shell.Interop.12.0.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Text.Data.15.0.25901-RC\lib\net45\Microsoft.VisualStudio.Text.Data.dll + True + + + ..\..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll + True + + + ..\..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Threading.15.0.20-pre\lib\net45\Microsoft.VisualStudio.Threading.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Utilities.15.0.25901-RC\lib\net45\Microsoft.VisualStudio.Utilities.dll + True + + + ..\..\packages\Microsoft.VisualStudio.Validation.15.0.11-pre\lib\net45\Microsoft.VisualStudio.Validation.dll + True + + + + + False + + + + ..\..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll + True + + + ..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + True + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + True + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + True + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + True + + + ..\..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + True + + + ..\..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + + + + + ..\..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + + + ..\..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll + + + + ..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + + + ..\..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + + + ..\..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + + + + ..\..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll + True + + + ..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + + + ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll + True + + + ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll + True + + + ..\..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll + + + ..\..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll + + + ..\..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + True + + + + + + + ..\..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + + + ..\..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll + + + ..\..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + + + ..\..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + + + + + + Menus.ctmenu + + + + + + + true + VSPackage + + + + + Designer + MSBuild:Compile + + + + + {932f3c9c-a6c0-40d3-ba50-9309886242fc} + Microsoft.AspNetCore.Razor.Evolution + False + + + + + + + {0f265874-c592-448b-bc4f-3430ab03e0dc} + Microsoft.CodeAnalysis.Razor.Workspaces + False + + + + + + + {1840aad6-e26b-43ce-a2b1-7e74ad512888} + Microsoft.CodeAnalysis.Remote.Razor + False + + + + + + + {92114fe9-cb07-4712-9aa4-afab65ca28e1} + Microsoft.VisualStudio.LanguageServices.Razor + False + + + + + + + + + + + + + + PreserveNewest + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/NotifyPropertyChanged.cs b/tooling/Microsoft.VisualStudio.RazorExtension/NotifyPropertyChanged.cs new file mode 100644 index 0000000000..83d3071e07 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/NotifyPropertyChanged.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace Microsoft.VisualStudio.RazorExtension +{ + public abstract class NotifyPropertyChanged : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/Properties/AssemblyInfo.cs b/tooling/Microsoft.VisualStudio.RazorExtension/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..37ae5e2dec --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/Properties/BindingRedirectAttributes.cs b/tooling/Microsoft.VisualStudio.RazorExtension/Properties/BindingRedirectAttributes.cs new file mode 100644 index 0000000000..f6b0780969 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/Properties/BindingRedirectAttributes.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.VisualStudio.Shell; + +[assembly: ProvideBindingRedirection( + AssemblyName = "Microsoft.AspNetCore.Razor.Evolution", + GenerateCodeBase = true, + PublicKeyToken = "adb9793829ddae60", + OldVersionLowerBound = "0.0.0.0", + OldVersionUpperBound = "1.0.0.0", + NewVersion = "1.0.0.0")] + +[assembly: ProvideBindingRedirection( + AssemblyName = "Microsoft.CodeAnalysis.Razor.Workspaces", + GenerateCodeBase = true, + PublicKeyToken = "adb9793829ddae60", + OldVersionLowerBound = "0.0.0.0", + OldVersionUpperBound = "1.2.0.0", + NewVersion = "1.2.0.0")] + +[assembly: ProvideBindingRedirection( + AssemblyName = "Microsoft.CodeAnalysis.Remote.Razor", + GenerateCodeBase = true, + PublicKeyToken = "adb9793829ddae60", + OldVersionLowerBound = "0.0.0.0", + OldVersionUpperBound = "1.2.0.0", + NewVersion = "1.2.0.0")] + +[assembly: ProvideBindingRedirection( + AssemblyName = "Microsoft.VisualStudio.LanguageServices.Razor", + GenerateCodeBase = true, + PublicKeyToken = "adb9793829ddae60", + OldVersionLowerBound = "0.0.0.0", + OldVersionUpperBound = "1.2.0.0", + NewVersion = "1.2.0.0")] \ No newline at end of file diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/AssemblyViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/AssemblyViewModel.cs new file mode 100644 index 0000000000..9eb97f1477 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/AssemblyViewModel.cs @@ -0,0 +1,24 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.VisualStudio.LanguageServices.Razor; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + public class AssemblyViewModel : NotifyPropertyChanged + { + private readonly RazorEngineAssembly _assembly; + + internal AssemblyViewModel(RazorEngineAssembly assembly) + { + _assembly = assembly; + + Name = _assembly.Identity.GetDisplayName(); + FilePath = assembly.FilePath; + } + + public string Name { get; } + + public string FilePath { get; } + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DirectiveViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DirectiveViewModel.cs new file mode 100644 index 0000000000..8009ac9869 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DirectiveViewModel.cs @@ -0,0 +1,41 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Text; +using Microsoft.AspNetCore.Razor.Evolution; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + public class DirectiveViewModel : NotifyPropertyChanged + { + private readonly DirectiveDescriptor _directive; + + internal DirectiveViewModel(DirectiveDescriptor directive) + { + _directive = directive; + + var builder = new StringBuilder(); + builder.Append("@"); + builder.Append(_directive.Name); + + foreach (var token in _directive.Tokens) + { + builder.Append(token.Value); + builder.Append("("); + builder.Append(token.Kind.ToString()); + builder.Append(")"); + } + + if (directive.Kind == DirectiveDescriptorKind.CodeBlock || directive.Kind == DirectiveDescriptorKind.RazorBlock) + { + builder.Append("{ ... }"); + } + + DisplayText = builder.ToString(); + } + + public string DisplayText { get; } + + public string Name => _directive.Name; + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DocumentInfoViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DocumentInfoViewModel.cs new file mode 100644 index 0000000000..404292dd6a --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DocumentInfoViewModel.cs @@ -0,0 +1,19 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.VisualStudio.LanguageServices.Razor; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + public class DocumentInfoViewModel : NotifyPropertyChanged + { + private RazorEngineDocument _document; + + internal DocumentInfoViewModel(RazorEngineDocument document) + { + _document = document; + } + + public string Text => _document.Text; + } +} \ No newline at end of file diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DocumentViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DocumentViewModel.cs new file mode 100644 index 0000000000..184f1f2850 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/DocumentViewModel.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + public class DocumentViewModel : NotifyPropertyChanged + { + public DocumentViewModel(string filePath) + { + FilePath = filePath; + } + + public string FilePath { get; } + } +} \ No newline at end of file diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/ProjectInfoViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/ProjectInfoViewModel.cs new file mode 100644 index 0000000000..4894b53411 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/ProjectInfoViewModel.cs @@ -0,0 +1,55 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.ObjectModel; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + public class ProjectInfoViewModel : NotifyPropertyChanged + { + private ObservableCollection _assemblies; + private ObservableCollection _directives; + private ObservableCollection _documents; + private ObservableCollection _tagHelpers; + + public ObservableCollection Assemblies + { + get { return _assemblies; } + set + { + _assemblies = value; + OnPropertyChanged(); + } + } + + public ObservableCollection Directives + { + get { return _directives; } + set + { + _directives = value; + OnPropertyChanged(); + } + } + + public ObservableCollection Documents + { + get { return _documents; } + set + { + _documents = value; + OnPropertyChanged(); + } + } + + public ObservableCollection TagHelpers + { + get { return _tagHelpers; } + set + { + _tagHelpers = value; + OnPropertyChanged(); + } + } + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/ProjectViewModel.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/ProjectViewModel.cs new file mode 100644 index 0000000000..5eae0fa364 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/ProjectViewModel.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + public class ProjectViewModel : NotifyPropertyChanged + { + public ProjectViewModel(Project project) + { + Id = project.Id; + Name = project.Name; + } + + public string Name { get; } + + public ProjectId Id { get; } + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindow.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindow.cs new file mode 100644 index 0000000000..6afd31f9c8 --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindow.cs @@ -0,0 +1,89 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; +using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.ComponentModelHost; +using Microsoft.VisualStudio.LanguageServices; +using Microsoft.VisualStudio.LanguageServices.Razor; +using Microsoft.CodeAnalysis; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + [Guid("079e9499-d150-40af-8876-3047f7942c2a")] + public class RazorInfoToolWindow : ToolWindowPane + { + private IRazorEngineAssemblyResolver _assemblyResolver; + private IRazorEngineDocumentGenerator _documentGenerator; + private IRazorEngineDirectiveResolver _directiveResolver; + private IRazorEngineTagHelperResolver _tagHelperResolver; + private VisualStudioWorkspace _workspace; + + public RazorInfoToolWindow() : base(null) + { + this.Caption = "Razor Info"; + this.Content = new RazorInfoToolWindowControl(); + } + + protected override void Initialize() + { + base.Initialize(); + + var componentModel = (IComponentModel)GetService(typeof(SComponentModel)); + + _assemblyResolver = componentModel.GetService(); + _documentGenerator = componentModel.GetService(); + _directiveResolver = componentModel.GetService(); + _tagHelperResolver = componentModel.GetService(); + + _workspace = componentModel.GetService(); + _workspace.WorkspaceChanged += Workspace_WorkspaceChanged; + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) + { + _workspace.WorkspaceChanged -= Workspace_WorkspaceChanged; + } + } + + private void Reset(Solution solution) + { + if (solution == null) + { + ((RazorInfoToolWindowControl)this.Content).DataContext = null; + return; + } + + var viewModel = new RazorInfoViewModel(this, _workspace, _assemblyResolver, _directiveResolver, _tagHelperResolver, _documentGenerator); + foreach (var project in solution.Projects) + { + viewModel.Projects.Add(new ProjectViewModel(project)); + } + + ((RazorInfoToolWindowControl)this.Content).DataContext = viewModel; + } + + private void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs e) + { + switch (e.Kind) + { + case WorkspaceChangeKind.ProjectAdded: + case WorkspaceChangeKind.ProjectChanged: + case WorkspaceChangeKind.ProjectReloaded: + case WorkspaceChangeKind.ProjectRemoved: + case WorkspaceChangeKind.SolutionAdded: + case WorkspaceChangeKind.SolutionChanged: + case WorkspaceChangeKind.SolutionCleared: + case WorkspaceChangeKind.SolutionReloaded: + case WorkspaceChangeKind.SolutionRemoved: + Reset(e.NewSolution); + break; + } + } + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindowCommand.cs b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindowCommand.cs new file mode 100644 index 0000000000..53e0627d0f --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindowCommand.cs @@ -0,0 +1,103 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.ComponentModel.Design; +using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.Shell.Interop; + +namespace Microsoft.VisualStudio.RazorExtension.RazorInfo +{ + /// + /// Command handler + /// + internal sealed class RazorInfoToolWindowCommand + { + /// + /// Command ID. + /// + public const int CommandId = 0x0100; + + /// + /// Command menu group (command set GUID). + /// + public static readonly Guid CommandSet = new Guid("eaaf8ee4-d120-4a4d-8b58-b138b7f00b96"); + + /// + /// VS Package that provides this command, not null. + /// + private readonly Package package; + + /// + /// Initializes a new instance of the class. + /// Adds our command handlers for menu (commands must exist in the command table file) + /// + /// Owner package, not null. + private RazorInfoToolWindowCommand(Package package) + { + if (package == null) + { + throw new ArgumentNullException("package"); + } + + this.package = package; + + OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; + if (commandService != null) + { + var menuCommandID = new CommandID(CommandSet, CommandId); + var menuItem = new MenuCommand(this.ShowToolWindow, menuCommandID); + commandService.AddCommand(menuItem); + } + } + + /// + /// Gets the instance of the command. + /// + public static RazorInfoToolWindowCommand Instance + { + get; + private set; + } + + /// + /// Gets the service provider from the owner package. + /// + private IServiceProvider ServiceProvider + { + get + { + return this.package; + } + } + + /// + /// Initializes the singleton instance of the command. + /// + /// Owner package, not null. + public static void Initialize(Package package) + { + Instance = new RazorInfoToolWindowCommand(package); + } + + /// + /// Shows the tool window when the menu item is clicked. + /// + /// The event sender. + /// The event args. + private void ShowToolWindow(object sender, EventArgs e) + { + // Get the instance number 0 of this tool window. This window is single instance so this instance + // is actually the only one. + // The last flag is set to true so that if the tool window does not exists it will be created. + ToolWindowPane window = this.package.FindToolWindow(typeof(RazorInfoToolWindow), 0, true); + if ((null == window) || (null == window.Frame)) + { + throw new NotSupportedException("Cannot create tool window"); + } + + IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame; + Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); + } + } +} diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindowControl.xaml b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindowControl.xaml new file mode 100644 index 0000000000..d4178dda0c --- /dev/null +++ b/tooling/Microsoft.VisualStudio.RazorExtension/RazorInfo/RazorInfoToolWindowControl.xaml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +