diff --git a/build/dependencies.props b/build/dependencies.props index e546fdf377..ee689b8d77 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -9,6 +9,7 @@ 2.1.0-preview2-28215 2.1.0-preview2-28215 15.3.409 + 15.3.409 15.3.409 2.6.1 2.6.1 diff --git a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props index c25a2ab174..3736003c53 100644 --- a/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props +++ b/src/Microsoft.AspNetCore.Razor.Design/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props @@ -39,6 +39,14 @@ <_RazorToolAssembly Condition="'$(_RazorToolAssembly)'==''">$(_RazorMSBuildRoot)tools\rzc.dll + + + + + diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props index e5ebcb407e..439697f9bc 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Microsoft.NET.Sdk.Razor.props @@ -14,6 +14,6 @@ Copyright (c) .NET Foundation. All rights reserved. - $(MSBuildFileDirectory)Sdk.Razor.CurrentVersion.targets + $(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.targets diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorConfiguration.xaml b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorConfiguration.xaml new file mode 100644 index 0000000000..55ae9abb42 --- /dev/null +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorConfiguration.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorExtension.xaml b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorExtension.xaml new file mode 100644 index 0000000000..49589142ee --- /dev/null +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorExtension.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorGeneral.xaml b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorGeneral.xaml new file mode 100644 index 0000000000..9a8785f206 --- /dev/null +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Rules/RazorGeneral.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props index 725b355e41..31e0482559 100644 --- a/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props +++ b/src/Microsoft.NET.Sdk.Razor/build/netstandard2.0/Sdk.Razor.CurrentVersion.props @@ -42,4 +42,27 @@ Copyright (c) .NET Foundation. All rights reserved. false + + + + + + + + File + + + File + + + Project + + + diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj b/src/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj index 9ab706795b..a3bbd0f3c9 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Microsoft.VisualStudio.LanguageServices.Razor.csproj @@ -4,6 +4,7 @@ net46 Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure for Visual Studio. false + ..\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Rules\ @@ -11,6 +12,8 @@ + + @@ -36,4 +39,79 @@ + + + + + + + + ProjectSystem\Rules\RazorConfiguration.xaml + + + ProjectSystem\Rules\RazorExtension.xaml + + + ProjectSystem\Rules\RazorGeneral.xaml + + + XamlRuleToCode:RazorConfiguration.xaml + + + XamlRuleToCode:RazorExtension.xaml + + + XamlRuleToCode:RazorGeneral.xaml + + + + + Designer + MSBuild:GenerateRuleSourceFromXaml + Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules + RazorProjectProperties + + ProjectSystem\Rules\ + + + Designer + MSBuild:GenerateRuleSourceFromXaml + Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules + RazorProjectProperties + ProjectSystem\Rules\ + + + Designer + MSBuild:GenerateRuleSourceFromXaml + Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules + RazorProjectProperties + ProjectSystem\Rules\ + + + + + ProjectSystem\Rules\RazorConfiguration.xaml + + + ProjectSystem\Rules\RazorExtension.xaml + + + ProjectSystem\Rules\RazorGeneral.xaml + + + + + + + + + diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs new file mode 100644 index 0000000000..d8c2484f5b --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorConfiguration.cs @@ -0,0 +1,212 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules { + + + internal partial class RazorConfiguration { + + /// Backing field for deserialized rule.. + private static Microsoft.Build.Framework.XamlTypes.Rule deserializedFallbackRule; + + /// The name of the schema to look for at runtime to fulfill property access. + internal const string SchemaName = "RazorConfiguration"; + + /// The ItemType given in the Rule.DataSource property. May not apply to every Property's individual DataSource. + internal const string PrimaryDataSourceItemType = "RazorConfiguration"; + + /// The Label given in the Rule.DataSource property. May not apply to every Property's individual DataSource. + internal const string PrimaryDataSourceLabel = ""; + + /// Razor Extensions (The "Extensions" property). + internal const string ExtensionsProperty = "Extensions"; + + /// Backing field for the property. + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule; + + /// Backing field for the file name of the rule property. + private string file; + + /// Backing field for the ItemType property. + private string itemType; + + /// Backing field for the ItemName property. + private string itemName; + + /// Configured Project + private Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject; + + /// The dictionary of named catalogs. + private System.Collections.Immutable.IImmutableDictionary catalogs; + + /// Backing field for the property. + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule fallbackRule; + + /// Thread locking object + private object locker = new object(); + + /// Initializes a new instance of the RazorConfiguration class. + internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule) { + this.rule = rule; + } + + /// Initializes a new instance of the RazorConfiguration class. + internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs, string context, string file, string itemType, string itemName) : + this(GetRule(System.Collections.Immutable.ImmutableDictionary.GetValueOrDefault(catalogs, context), file, itemType, itemName)) { + if ((configuredProject == null)) { + throw new System.ArgumentNullException("configuredProject"); + } + this.configuredProject = configuredProject; + this.catalogs = catalogs; + this.file = file; + this.itemType = itemType; + this.itemName = itemName; + } + + /// Initializes a new instance of the RazorConfiguration class. + internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule, Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject) : + this(rule) { + if ((rule == null)) { + throw new System.ArgumentNullException("rule"); + } + if ((configuredProject == null)) { + throw new System.ArgumentNullException("configuredProject"); + } + this.configuredProject = configuredProject; + this.rule = rule; + this.file = this.rule.File; + this.itemType = this.rule.ItemType; + this.itemName = this.rule.ItemName; + } + + /// Initializes a new instance of the RazorConfiguration class. + internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs, string context, Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertyContext) : + this(configuredProject, catalogs, context, GetContextFile(propertyContext), propertyContext.ItemType, propertyContext.ItemName) { + } + + /// Initializes a new instance of the RazorConfiguration class that assumes a project context (neither property sheet nor items). + internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs) : + this(configuredProject, catalogs, "Project", null, null, null) { + } + + /// Gets the IRule used to get and set properties. + public Microsoft.VisualStudio.ProjectSystem.Properties.IRule Rule { + get { + return this.rule; + } + } + + /// Razor Extensions + internal Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty Extensions { + get { + Microsoft.VisualStudio.ProjectSystem.Properties.IRule localRule = this.rule; + if ((localRule == null)) { + localRule = this.GeneratedFallbackRule; + } + if ((localRule == null)) { + return null; + } + Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(ExtensionsProperty))); + if (((property == null) + && (this.GeneratedFallbackRule != null))) { + localRule = this.GeneratedFallbackRule; + property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(ExtensionsProperty))); + } + return property; + } + } + + /// Get the fallback rule if the current rule on disk is missing or a property in the rule on disk is missing + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule GeneratedFallbackRule { + get { + if (((this.fallbackRule == null) + && (this.configuredProject != null))) { + System.Threading.Monitor.Enter(this.locker); + try { + if ((this.fallbackRule == null)) { + this.InitializeFallbackRule(); + } + } + finally { + System.Threading.Monitor.Exit(this.locker); + } + } + return this.fallbackRule; + } + } + + private static Microsoft.VisualStudio.ProjectSystem.Properties.IRule GetRule(Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog catalog, string file, string itemType, string itemName) { + if ((catalog == null)) { + return null; + } + return catalog.BindToContext(SchemaName, file, itemType, itemName); + } + + private static string GetContextFile(Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertiesContext) { + if ((propertiesContext.IsProjectFile == true)) { + return null; + } + else { + return propertiesContext.File; + } + } + + private void InitializeFallbackRule() { + if ((this.configuredProject == null)) { + return; + } + Microsoft.Build.Framework.XamlTypes.Rule unboundRule = RazorConfiguration.deserializedFallbackRule; + if ((unboundRule == null)) { + System.IO.Stream xamlStream = null; + System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); + try { + xamlStream = thisAssembly.GetManifestResourceStream("XamlRuleToCode:RazorConfiguration.xaml"); + Microsoft.Build.Framework.XamlTypes.IProjectSchemaNode root = ((Microsoft.Build.Framework.XamlTypes.IProjectSchemaNode)(System.Xaml.XamlServices.Load(xamlStream))); + System.Collections.Generic.IEnumerator ruleEnumerator = root.GetSchemaObjects(typeof(Microsoft.Build.Framework.XamlTypes.Rule)).GetEnumerator(); + for ( + ; ((unboundRule == null) + && ruleEnumerator.MoveNext()); + ) { + Microsoft.Build.Framework.XamlTypes.Rule t = ((Microsoft.Build.Framework.XamlTypes.Rule)(ruleEnumerator.Current)); + if (System.StringComparer.OrdinalIgnoreCase.Equals(t.Name, SchemaName)) { + unboundRule = t; + unboundRule.Name = "30e71838-2cb8-4c67-ab28-7670763124af"; + RazorConfiguration.deserializedFallbackRule = unboundRule; + } + } + } + finally { + if ((xamlStream != null)) { + ((System.IDisposable)(xamlStream)).Dispose(); + } + } + } + this.configuredProject.Services.AdditionalRuleDefinitions.AddRuleDefinition(unboundRule, "FallbackRuleCodeGenerationContext"); + Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog catalog = this.configuredProject.Services.PropertyPagesCatalog.GetMemoryOnlyCatalog("FallbackRuleCodeGenerationContext"); + this.fallbackRule = catalog.BindToContext(unboundRule.Name, this.file, this.itemType, this.itemName); + } + } + + internal partial class RazorProjectProperties { + + private static System.Func>, object, RazorConfiguration> CreateRazorConfigurationPropertiesDelegate = new System.Func>, object, RazorConfiguration>(CreateRazorConfigurationProperties); + + private static RazorConfiguration CreateRazorConfigurationProperties(System.Threading.Tasks.Task> namedCatalogs, object state) { + RazorProjectProperties that = ((RazorProjectProperties)(state)); + return new RazorConfiguration(that.ConfiguredProject, namedCatalogs.Result, "Project", that.File, that.ItemType, that.ItemName); + } + + /// Gets the strongly-typed property accessor used to get and set Configuration Properties properties. + internal System.Threading.Tasks.Task GetRazorConfigurationPropertiesAsync() { + System.Threading.Tasks.Task> namedCatalogsTask = this.GetNamedCatalogsAsync(); + return namedCatalogsTask.ContinueWith(CreateRazorConfigurationPropertiesDelegate, this, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously, System.Threading.Tasks.TaskScheduler.Default); + } + } +} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorExtension.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorExtension.cs new file mode 100644 index 0000000000..0ce503811b --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorExtension.cs @@ -0,0 +1,235 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules { + + + internal partial class RazorExtension { + + /// Backing field for deserialized rule.. + private static Microsoft.Build.Framework.XamlTypes.Rule deserializedFallbackRule; + + /// The name of the schema to look for at runtime to fulfill property access. + internal const string SchemaName = "RazorExtension"; + + /// The ItemType given in the Rule.DataSource property. May not apply to every Property's individual DataSource. + internal const string PrimaryDataSourceItemType = "RazorExtension"; + + /// The Label given in the Rule.DataSource property. May not apply to every Property's individual DataSource. + internal const string PrimaryDataSourceLabel = ""; + + /// Razor Extension Assembly Name (The "AssemblyName" property). + internal const string AssemblyNameProperty = "AssemblyName"; + + /// Razor Extension Assembly File Path (The "AssemblyFilePath" property). + internal const string AssemblyFilePathProperty = "AssemblyFilePath"; + + /// Backing field for the property. + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule; + + /// Backing field for the file name of the rule property. + private string file; + + /// Backing field for the ItemType property. + private string itemType; + + /// Backing field for the ItemName property. + private string itemName; + + /// Configured Project + private Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject; + + /// The dictionary of named catalogs. + private System.Collections.Immutable.IImmutableDictionary catalogs; + + /// Backing field for the property. + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule fallbackRule; + + /// Thread locking object + private object locker = new object(); + + /// Initializes a new instance of the RazorExtension class. + internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule) { + this.rule = rule; + } + + /// Initializes a new instance of the RazorExtension class. + internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs, string context, string file, string itemType, string itemName) : + this(GetRule(System.Collections.Immutable.ImmutableDictionary.GetValueOrDefault(catalogs, context), file, itemType, itemName)) { + if ((configuredProject == null)) { + throw new System.ArgumentNullException("configuredProject"); + } + this.configuredProject = configuredProject; + this.catalogs = catalogs; + this.file = file; + this.itemType = itemType; + this.itemName = itemName; + } + + /// Initializes a new instance of the RazorExtension class. + internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule, Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject) : + this(rule) { + if ((rule == null)) { + throw new System.ArgumentNullException("rule"); + } + if ((configuredProject == null)) { + throw new System.ArgumentNullException("configuredProject"); + } + this.configuredProject = configuredProject; + this.rule = rule; + this.file = this.rule.File; + this.itemType = this.rule.ItemType; + this.itemName = this.rule.ItemName; + } + + /// Initializes a new instance of the RazorExtension class. + internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs, string context, Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertyContext) : + this(configuredProject, catalogs, context, GetContextFile(propertyContext), propertyContext.ItemType, propertyContext.ItemName) { + } + + /// Initializes a new instance of the RazorExtension class that assumes a project context (neither property sheet nor items). + internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs) : + this(configuredProject, catalogs, "Project", null, null, null) { + } + + /// Gets the IRule used to get and set properties. + public Microsoft.VisualStudio.ProjectSystem.Properties.IRule Rule { + get { + return this.rule; + } + } + + /// Razor Extension Assembly Name + internal Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty AssemblyName { + get { + Microsoft.VisualStudio.ProjectSystem.Properties.IRule localRule = this.rule; + if ((localRule == null)) { + localRule = this.GeneratedFallbackRule; + } + if ((localRule == null)) { + return null; + } + Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(AssemblyNameProperty))); + if (((property == null) + && (this.GeneratedFallbackRule != null))) { + localRule = this.GeneratedFallbackRule; + property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(AssemblyNameProperty))); + } + return property; + } + } + + /// Razor Extension Assembly File Path + internal Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty AssemblyFilePath { + get { + Microsoft.VisualStudio.ProjectSystem.Properties.IRule localRule = this.rule; + if ((localRule == null)) { + localRule = this.GeneratedFallbackRule; + } + if ((localRule == null)) { + return null; + } + Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(AssemblyFilePathProperty))); + if (((property == null) + && (this.GeneratedFallbackRule != null))) { + localRule = this.GeneratedFallbackRule; + property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(AssemblyFilePathProperty))); + } + return property; + } + } + + /// Get the fallback rule if the current rule on disk is missing or a property in the rule on disk is missing + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule GeneratedFallbackRule { + get { + if (((this.fallbackRule == null) + && (this.configuredProject != null))) { + System.Threading.Monitor.Enter(this.locker); + try { + if ((this.fallbackRule == null)) { + this.InitializeFallbackRule(); + } + } + finally { + System.Threading.Monitor.Exit(this.locker); + } + } + return this.fallbackRule; + } + } + + private static Microsoft.VisualStudio.ProjectSystem.Properties.IRule GetRule(Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog catalog, string file, string itemType, string itemName) { + if ((catalog == null)) { + return null; + } + return catalog.BindToContext(SchemaName, file, itemType, itemName); + } + + private static string GetContextFile(Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertiesContext) { + if ((propertiesContext.IsProjectFile == true)) { + return null; + } + else { + return propertiesContext.File; + } + } + + private void InitializeFallbackRule() { + if ((this.configuredProject == null)) { + return; + } + Microsoft.Build.Framework.XamlTypes.Rule unboundRule = RazorExtension.deserializedFallbackRule; + if ((unboundRule == null)) { + System.IO.Stream xamlStream = null; + System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); + try { + xamlStream = thisAssembly.GetManifestResourceStream("XamlRuleToCode:RazorExtension.xaml"); + Microsoft.Build.Framework.XamlTypes.IProjectSchemaNode root = ((Microsoft.Build.Framework.XamlTypes.IProjectSchemaNode)(System.Xaml.XamlServices.Load(xamlStream))); + System.Collections.Generic.IEnumerator ruleEnumerator = root.GetSchemaObjects(typeof(Microsoft.Build.Framework.XamlTypes.Rule)).GetEnumerator(); + for ( + ; ((unboundRule == null) + && ruleEnumerator.MoveNext()); + ) { + Microsoft.Build.Framework.XamlTypes.Rule t = ((Microsoft.Build.Framework.XamlTypes.Rule)(ruleEnumerator.Current)); + if (System.StringComparer.OrdinalIgnoreCase.Equals(t.Name, SchemaName)) { + unboundRule = t; + unboundRule.Name = "6b577687-703b-41a1-8f5f-c44644f65f2a"; + RazorExtension.deserializedFallbackRule = unboundRule; + } + } + } + finally { + if ((xamlStream != null)) { + ((System.IDisposable)(xamlStream)).Dispose(); + } + } + } + this.configuredProject.Services.AdditionalRuleDefinitions.AddRuleDefinition(unboundRule, "FallbackRuleCodeGenerationContext"); + Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog catalog = this.configuredProject.Services.PropertyPagesCatalog.GetMemoryOnlyCatalog("FallbackRuleCodeGenerationContext"); + this.fallbackRule = catalog.BindToContext(unboundRule.Name, this.file, this.itemType, this.itemName); + } + } + + internal partial class RazorProjectProperties { + + private static System.Func>, object, RazorExtension> CreateRazorExtensionPropertiesDelegate = new System.Func>, object, RazorExtension>(CreateRazorExtensionProperties); + + private static RazorExtension CreateRazorExtensionProperties(System.Threading.Tasks.Task> namedCatalogs, object state) { + RazorProjectProperties that = ((RazorProjectProperties)(state)); + return new RazorExtension(that.ConfiguredProject, namedCatalogs.Result, "Project", that.File, that.ItemType, that.ItemName); + } + + /// Gets the strongly-typed property accessor used to get and set Extension Properties properties. + internal System.Threading.Tasks.Task GetRazorExtensionPropertiesAsync() { + System.Threading.Tasks.Task> namedCatalogsTask = this.GetNamedCatalogsAsync(); + return namedCatalogsTask.ContinueWith(CreateRazorExtensionPropertiesDelegate, this, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously, System.Threading.Tasks.TaskScheduler.Default); + } + } +} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorGeneral.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorGeneral.cs new file mode 100644 index 0000000000..860fb1a80b --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorGeneral.cs @@ -0,0 +1,235 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules { + + + internal partial class RazorGeneral { + + /// Backing field for deserialized rule.. + private static Microsoft.Build.Framework.XamlTypes.Rule deserializedFallbackRule; + + /// The name of the schema to look for at runtime to fulfill property access. + internal const string SchemaName = "RazorGeneral"; + + /// The ItemType given in the Rule.DataSource property. May not apply to every Property's individual DataSource. + internal const string PrimaryDataSourceItemType = null; + + /// The Label given in the Rule.DataSource property. May not apply to every Property's individual DataSource. + internal const string PrimaryDataSourceLabel = ""; + + /// Razor Language Version (The "RazorLangVersion" property). + internal const string RazorLangVersionProperty = "RazorLangVersion"; + + /// Razor Configuration Name (The "RazorDefaultConfiguration" property). + internal const string RazorDefaultConfigurationProperty = "RazorDefaultConfiguration"; + + /// Backing field for the property. + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule; + + /// Backing field for the file name of the rule property. + private string file; + + /// Backing field for the ItemType property. + private string itemType; + + /// Backing field for the ItemName property. + private string itemName; + + /// Configured Project + private Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject; + + /// The dictionary of named catalogs. + private System.Collections.Immutable.IImmutableDictionary catalogs; + + /// Backing field for the property. + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule fallbackRule; + + /// Thread locking object + private object locker = new object(); + + /// Initializes a new instance of the RazorGeneral class. + internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule) { + this.rule = rule; + } + + /// Initializes a new instance of the RazorGeneral class. + internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs, string context, string file, string itemType, string itemName) : + this(GetRule(System.Collections.Immutable.ImmutableDictionary.GetValueOrDefault(catalogs, context), file, itemType, itemName)) { + if ((configuredProject == null)) { + throw new System.ArgumentNullException("configuredProject"); + } + this.configuredProject = configuredProject; + this.catalogs = catalogs; + this.file = file; + this.itemType = itemType; + this.itemName = itemName; + } + + /// Initializes a new instance of the RazorGeneral class. + internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule, Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject) : + this(rule) { + if ((rule == null)) { + throw new System.ArgumentNullException("rule"); + } + if ((configuredProject == null)) { + throw new System.ArgumentNullException("configuredProject"); + } + this.configuredProject = configuredProject; + this.rule = rule; + this.file = this.rule.File; + this.itemType = this.rule.ItemType; + this.itemName = this.rule.ItemName; + } + + /// Initializes a new instance of the RazorGeneral class. + internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs, string context, Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertyContext) : + this(configuredProject, catalogs, context, GetContextFile(propertyContext), propertyContext.ItemType, propertyContext.ItemName) { + } + + /// Initializes a new instance of the RazorGeneral class that assumes a project context (neither property sheet nor items). + internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary catalogs) : + this(configuredProject, catalogs, "Project", null, null, null) { + } + + /// Gets the IRule used to get and set properties. + public Microsoft.VisualStudio.ProjectSystem.Properties.IRule Rule { + get { + return this.rule; + } + } + + /// Razor Language Version + internal Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty RazorLangVersion { + get { + Microsoft.VisualStudio.ProjectSystem.Properties.IRule localRule = this.rule; + if ((localRule == null)) { + localRule = this.GeneratedFallbackRule; + } + if ((localRule == null)) { + return null; + } + Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(RazorLangVersionProperty))); + if (((property == null) + && (this.GeneratedFallbackRule != null))) { + localRule = this.GeneratedFallbackRule; + property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(RazorLangVersionProperty))); + } + return property; + } + } + + /// Razor Configuration Name + internal Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty RazorDefaultConfiguration { + get { + Microsoft.VisualStudio.ProjectSystem.Properties.IRule localRule = this.rule; + if ((localRule == null)) { + localRule = this.GeneratedFallbackRule; + } + if ((localRule == null)) { + return null; + } + Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(RazorDefaultConfigurationProperty))); + if (((property == null) + && (this.GeneratedFallbackRule != null))) { + localRule = this.GeneratedFallbackRule; + property = ((Microsoft.VisualStudio.ProjectSystem.Properties.IEvaluatedProperty)(localRule.GetProperty(RazorDefaultConfigurationProperty))); + } + return property; + } + } + + /// Get the fallback rule if the current rule on disk is missing or a property in the rule on disk is missing + private Microsoft.VisualStudio.ProjectSystem.Properties.IRule GeneratedFallbackRule { + get { + if (((this.fallbackRule == null) + && (this.configuredProject != null))) { + System.Threading.Monitor.Enter(this.locker); + try { + if ((this.fallbackRule == null)) { + this.InitializeFallbackRule(); + } + } + finally { + System.Threading.Monitor.Exit(this.locker); + } + } + return this.fallbackRule; + } + } + + private static Microsoft.VisualStudio.ProjectSystem.Properties.IRule GetRule(Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog catalog, string file, string itemType, string itemName) { + if ((catalog == null)) { + return null; + } + return catalog.BindToContext(SchemaName, file, itemType, itemName); + } + + private static string GetContextFile(Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertiesContext) { + if ((propertiesContext.IsProjectFile == true)) { + return null; + } + else { + return propertiesContext.File; + } + } + + private void InitializeFallbackRule() { + if ((this.configuredProject == null)) { + return; + } + Microsoft.Build.Framework.XamlTypes.Rule unboundRule = RazorGeneral.deserializedFallbackRule; + if ((unboundRule == null)) { + System.IO.Stream xamlStream = null; + System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); + try { + xamlStream = thisAssembly.GetManifestResourceStream("XamlRuleToCode:RazorGeneral.xaml"); + Microsoft.Build.Framework.XamlTypes.IProjectSchemaNode root = ((Microsoft.Build.Framework.XamlTypes.IProjectSchemaNode)(System.Xaml.XamlServices.Load(xamlStream))); + System.Collections.Generic.IEnumerator ruleEnumerator = root.GetSchemaObjects(typeof(Microsoft.Build.Framework.XamlTypes.Rule)).GetEnumerator(); + for ( + ; ((unboundRule == null) + && ruleEnumerator.MoveNext()); + ) { + Microsoft.Build.Framework.XamlTypes.Rule t = ((Microsoft.Build.Framework.XamlTypes.Rule)(ruleEnumerator.Current)); + if (System.StringComparer.OrdinalIgnoreCase.Equals(t.Name, SchemaName)) { + unboundRule = t; + unboundRule.Name = "e0400917-b7e9-4731-b3e6-447b229db9d4"; + RazorGeneral.deserializedFallbackRule = unboundRule; + } + } + } + finally { + if ((xamlStream != null)) { + ((System.IDisposable)(xamlStream)).Dispose(); + } + } + } + this.configuredProject.Services.AdditionalRuleDefinitions.AddRuleDefinition(unboundRule, "FallbackRuleCodeGenerationContext"); + Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog catalog = this.configuredProject.Services.PropertyPagesCatalog.GetMemoryOnlyCatalog("FallbackRuleCodeGenerationContext"); + this.fallbackRule = catalog.BindToContext(unboundRule.Name, this.file, this.itemType, this.itemName); + } + } + + internal partial class RazorProjectProperties { + + private static System.Func>, object, RazorGeneral> CreateRazorGeneralPropertiesDelegate = new System.Func>, object, RazorGeneral>(CreateRazorGeneralProperties); + + private static RazorGeneral CreateRazorGeneralProperties(System.Threading.Tasks.Task> namedCatalogs, object state) { + RazorProjectProperties that = ((RazorProjectProperties)(state)); + return new RazorGeneral(that.ConfiguredProject, namedCatalogs.Result, "Project", that.File, that.ItemType, that.ItemName); + } + + /// Gets the strongly-typed property accessor used to get and set Razor Properties properties. + internal System.Threading.Tasks.Task GetRazorGeneralPropertiesAsync() { + System.Threading.Tasks.Task> namedCatalogsTask = this.GetNamedCatalogsAsync(); + return namedCatalogsTask.ContinueWith(CreateRazorGeneralPropertiesDelegate, this, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously, System.Threading.Tasks.TaskScheduler.Default); + } + } +} diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs new file mode 100644 index 0000000000..b08397ffb9 --- /dev/null +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs @@ -0,0 +1,34 @@ +// 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.Composition; +using Microsoft.VisualStudio.ProjectSystem; +using Microsoft.VisualStudio.ProjectSystem.Properties; + +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules +{ + [Export] + internal partial class RazorProjectProperties : StronglyTypedPropertyAccess + { + [ImportingConstructor] + public RazorProjectProperties(ConfiguredProject configuredProject) + : base(configuredProject) + { + } + + public RazorProjectProperties(ConfiguredProject configuredProject, UnconfiguredProject unconfiguredProject) + : base(configuredProject, unconfiguredProject) + { + } + + public RazorProjectProperties(ConfiguredProject configuredProject, IProjectPropertiesContext projectPropertiesContext) + : base(configuredProject, projectPropertiesContext) + { + } + + public RazorProjectProperties(ConfiguredProject configuredProject, string file, string itemType, string itemName) + : base(configuredProject, file, itemType, itemName) + { + } + } +} \ No newline at end of file