Update SDK with tooling changes
These are some updates to the SDK based on the work going on in the VS 15.7 branch. I porting the SDK changes here early for ease of testing.
This commit is contained in:
parent
6d757988c9
commit
2ae925a0f2
|
|
@ -9,6 +9,7 @@
|
|||
<MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>2.1.0-preview2-28215</MicrosoftAspNetCoreHtmlAbstractionsPackageVersion>
|
||||
<MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview2-28215</MicrosoftAspNetCoreTestingPackageVersion>
|
||||
<MicrosoftBuildFrameworkPackageVersion>15.3.409</MicrosoftBuildFrameworkPackageVersion>
|
||||
<MicrosoftBuildPackageVersion>15.3.409</MicrosoftBuildPackageVersion>
|
||||
<MicrosoftBuildUtilitiesCorePackageVersion>15.3.409</MicrosoftBuildUtilitiesCorePackageVersion>
|
||||
<MicrosoftCodeAnalysisCommonPackageVersion>2.6.1</MicrosoftCodeAnalysisCommonPackageVersion>
|
||||
<MicrosoftCodeAnalysisCSharpPackageVersion>2.6.1</MicrosoftCodeAnalysisCSharpPackageVersion>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,14 @@
|
|||
<_RazorToolAssembly Condition="'$(_RazorToolAssembly)'==''">$(_RazorMSBuildRoot)tools\rzc.dll</_RazorToolAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!--
|
||||
Defines the ability to understand the configuration for the Razor language service provided by
|
||||
the runtime/toolset packages. Introduced in 2.1
|
||||
-->
|
||||
<ProjectCapability Include="DotNetCoreRazorConfiguration"/>
|
||||
</ItemGroup>
|
||||
|
||||
<UsingTask TaskName="Microsoft.AspNetCore.Razor.Tasks.RazorGenerate" AssemblyFile="$(_RazorTaskAssembly)" />
|
||||
<UsingTask TaskName="Microsoft.AspNetCore.Razor.Tasks.RazorTagHelper" AssemblyFile="$(_RazorTaskAssembly)" />
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ Copyright (c) .NET Foundation. All rights reserved.
|
|||
|
||||
<PropertyGroup>
|
||||
<!-- Redirect the SDK to use the targets from the current package -->
|
||||
<RazorSdkTargetsPath>$(MSBuildFileDirectory)Sdk.Razor.CurrentVersion.targets</RazorSdkTargetsPath>
|
||||
<RazorSdkTargetsPath>$(MSBuildThisFileDirectory)Sdk.Razor.CurrentVersion.targets</RazorSdkTargetsPath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Rule
|
||||
Description="Configuration Properties"
|
||||
DisplayName="Configuration Properties"
|
||||
Name="RazorConfiguration"
|
||||
PageTemplate="generic"
|
||||
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||
<Rule.DataSource>
|
||||
<DataSource
|
||||
Persistence="ProjectFile"
|
||||
HasConfigurationCondition="True"
|
||||
ItemType="RazorConfiguration" />
|
||||
</Rule.DataSource>
|
||||
|
||||
<Rule.Categories>
|
||||
<Category
|
||||
Name="General"
|
||||
DisplayName="General" />
|
||||
</Rule.Categories>
|
||||
|
||||
<StringProperty
|
||||
Category="General"
|
||||
Description="Razor Extensions"
|
||||
DisplayName="Razor Extensions"
|
||||
Name="Extensions"
|
||||
ReadOnly="True"
|
||||
Visible="True" />
|
||||
|
||||
</Rule>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Rule
|
||||
Description="Extension Properties"
|
||||
DisplayName="Extension Properties"
|
||||
Name="RazorExtension"
|
||||
PageTemplate="generic"
|
||||
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||
<Rule.DataSource>
|
||||
<DataSource
|
||||
Persistence="ProjectFile"
|
||||
HasConfigurationCondition="True"
|
||||
ItemType="RazorExtension" />
|
||||
</Rule.DataSource>
|
||||
|
||||
<Rule.Categories>
|
||||
<Category
|
||||
Name="General"
|
||||
DisplayName="General" />
|
||||
</Rule.Categories>
|
||||
|
||||
<StringProperty
|
||||
Category="General"
|
||||
Description="Razor Extension Assembly Name"
|
||||
DisplayName="Razor Extension Assembly Name"
|
||||
Name="AssemblyName"
|
||||
ReadOnly="True"
|
||||
Visible="True" />
|
||||
|
||||
<StringProperty
|
||||
Category="General"
|
||||
Description="Razor Extension Assembly File Path"
|
||||
DisplayName="Razor Extension Assembly File Path"
|
||||
Name="AssemblyFilePath"
|
||||
ReadOnly="True"
|
||||
Visible="True" />
|
||||
|
||||
</Rule>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Rule
|
||||
Description="Razor Properties"
|
||||
DisplayName="Razor Properties"
|
||||
Name="RazorGeneral"
|
||||
PageTemplate="generic"
|
||||
xmlns="http://schemas.microsoft.com/build/2009/properties">
|
||||
<Rule.DataSource>
|
||||
<DataSource
|
||||
Persistence="ProjectFile"
|
||||
HasConfigurationCondition="True" />
|
||||
</Rule.DataSource>
|
||||
|
||||
<Rule.Categories>
|
||||
<Category
|
||||
Name="General"
|
||||
DisplayName="General" />
|
||||
</Rule.Categories>
|
||||
|
||||
<StringProperty
|
||||
Category="General"
|
||||
Description="Razor Language Version"
|
||||
DisplayName="Razor Language Version"
|
||||
Name="RazorLangVersion"
|
||||
ReadOnly="True"
|
||||
Visible="True" />
|
||||
|
||||
<StringProperty
|
||||
Category="General"
|
||||
Description="Razor Configuration Name"
|
||||
DisplayName="Razor Configuration Name"
|
||||
Name="RazorDefaultConfiguration"
|
||||
ReadOnly="True"
|
||||
Visible="True" />
|
||||
|
||||
</Rule>
|
||||
|
|
@ -42,4 +42,27 @@ Copyright (c) .NET Foundation. All rights reserved.
|
|||
<UseRazorBuildServer Condition="'$(UseRazorBuildServer)'==''">false</UseRazorBuildServer>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!--
|
||||
Defines the generic .NET Core 'Razor' capability.
|
||||
|
||||
Note that we don't define any capabilities here that depend on the version of the runtime/toolset
|
||||
in use by the project. Those capabilities are defined by the relevant runtime packages so that
|
||||
we use the lack of the capability to detect downlevel scenarios.
|
||||
-->
|
||||
<ProjectCapability Include="DotNetCoreRazor"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\RazorConfiguration.xaml">
|
||||
<Context>File</Context>
|
||||
</PropertyPageSchema>
|
||||
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\RazorExtension.xaml">
|
||||
<Context>File</Context>
|
||||
</PropertyPageSchema>
|
||||
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\RazorGeneral.xaml">
|
||||
<Context>Project</Context>
|
||||
</PropertyPageSchema>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
<TargetFrameworks>net46</TargetFrameworks>
|
||||
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure for Visual Studio.</Description>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
<RulesDirectory>..\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Rules\</RulesDirectory>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
|
|
@ -11,6 +12,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.ComponentModelHost" Version="$(MicrosoftVisualStudioComponentModelHostPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Editor" Version="$(MicrosoftVisualStudioEditorPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Language.Intellisense" Version="$(MicrosoftVisualStudioLanguageIntellisensePackageVersion)" />
|
||||
|
|
@ -36,4 +39,79 @@
|
|||
<ProjectReference Include="..\..\src\Microsoft.VisualStudio.Editor.Razor\Microsoft.VisualStudio.Editor.Razor.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Xaml"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
The ProjectSystem.SDK tasks that handle XamlPropertyRule don't work on the dotnet core version
|
||||
of MSBuild. The workaround here is to only hardcode the generated code location such that it gets
|
||||
checked in. Then we don't need to generate it at build time.
|
||||
If you make changes to the rule files, then you need to update them using Desktop MSBuild :(
|
||||
-->
|
||||
<ItemGroup Condition="'$(MSBuildRuntimeType)'=='Core'">
|
||||
<None Include="$(RulesDirectory)RazorConfiguration.xaml">
|
||||
<Link>ProjectSystem\Rules\RazorConfiguration.xaml</Link>
|
||||
</None>
|
||||
<None Include="$(RulesDirectory)RazorExtension.xaml">
|
||||
<Link>ProjectSystem\Rules\RazorExtension.xaml</Link>
|
||||
</None>
|
||||
<None Include="$(RulesDirectory)RazorGeneral.xaml">
|
||||
<Link>ProjectSystem\Rules\RazorGeneral.xaml</Link>
|
||||
</None>
|
||||
<EmbeddedResource Include="$(RulesDirectory)RazorConfiguration.xaml">
|
||||
<LogicalName>XamlRuleToCode:RazorConfiguration.xaml</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(RulesDirectory)RazorExtension.xaml">
|
||||
<LogicalName>XamlRuleToCode:RazorExtension.xaml</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(RulesDirectory)RazorGeneral.xaml">
|
||||
<LogicalName>XamlRuleToCode:RazorGeneral.xaml</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(MSBuildRuntimeType)'!='Core'">
|
||||
<XamlPropertyRule Include="$(RulesDirectory)RazorConfiguration.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:GenerateRuleSourceFromXaml</Generator>
|
||||
<Namespace>Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules</Namespace>
|
||||
<RuleInjectionClassName>RazorProjectProperties</RuleInjectionClassName>
|
||||
<Context></Context>
|
||||
<OutputPath>ProjectSystem\Rules\</OutputPath>
|
||||
</XamlPropertyRule>
|
||||
<XamlPropertyRule Include="$(RulesDirectory)RazorExtension.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:GenerateRuleSourceFromXaml</Generator>
|
||||
<Namespace>Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules</Namespace>
|
||||
<RuleInjectionClassName>RazorProjectProperties</RuleInjectionClassName>
|
||||
<OutputPath>ProjectSystem\Rules\</OutputPath>
|
||||
</XamlPropertyRule>
|
||||
<XamlPropertyRule Include="$(RulesDirectory)RazorGeneral.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:GenerateRuleSourceFromXaml</Generator>
|
||||
<Namespace>Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules</Namespace>
|
||||
<RuleInjectionClassName>RazorProjectProperties</RuleInjectionClassName>
|
||||
<OutputPath>ProjectSystem\Rules\</OutputPath>
|
||||
</XamlPropertyRule>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="ProjectSystem\Rules\RazorConfiguration.cs">
|
||||
<DependentUpon>ProjectSystem\Rules\RazorConfiguration.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ProjectSystem\Rules\RazorExtension.cs">
|
||||
<DependentUpon>ProjectSystem\Rules\RazorExtension.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ProjectSystem\Rules\RazorGeneral.cs">
|
||||
<DependentUpon>ProjectSystem\Rules\RazorGeneral.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Despite us specifying %(XamlPropertyRule.OutputPath), the ProjectSystem.SDK targets still add files in the
|
||||
obj folder to the Compile group. This is a workaround to remove them.
|
||||
-->
|
||||
<Target Name="GrossProjectSystemSDKWorkaround" AfterTargets="GenerateRulePrep">
|
||||
<ItemGroup>
|
||||
<Compile Remove="@(XamlPropertyRule->'$(IntermediateOutputPath)%(FileName)$(DefaultLanguageSourceExtension)')" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,212 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules {
|
||||
|
||||
|
||||
internal partial class RazorConfiguration {
|
||||
|
||||
/// <summary>Backing field for deserialized rule.<see cref='Microsoft.Build.Framework.XamlTypes.Rule'/>.</summary>
|
||||
private static Microsoft.Build.Framework.XamlTypes.Rule deserializedFallbackRule;
|
||||
|
||||
/// <summary>The name of the schema to look for at runtime to fulfill property access.</summary>
|
||||
internal const string SchemaName = "RazorConfiguration";
|
||||
|
||||
/// <summary>The ItemType given in the Rule.DataSource property. May not apply to every Property's individual DataSource.</summary>
|
||||
internal const string PrimaryDataSourceItemType = "RazorConfiguration";
|
||||
|
||||
/// <summary>The Label given in the Rule.DataSource property. May not apply to every Property's individual DataSource.</summary>
|
||||
internal const string PrimaryDataSourceLabel = "";
|
||||
|
||||
/// <summary>Razor Extensions (The "Extensions" property).</summary>
|
||||
internal const string ExtensionsProperty = "Extensions";
|
||||
|
||||
/// <summary>Backing field for the <see cref='Microsoft.Build.Framework.XamlTypes.Rule'/> property.</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule;
|
||||
|
||||
/// <summary>Backing field for the file name of the rule property.</summary>
|
||||
private string file;
|
||||
|
||||
/// <summary>Backing field for the ItemType property.</summary>
|
||||
private string itemType;
|
||||
|
||||
/// <summary>Backing field for the ItemName property.</summary>
|
||||
private string itemName;
|
||||
|
||||
/// <summary>Configured Project</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject;
|
||||
|
||||
/// <summary>The dictionary of named catalogs.</summary>
|
||||
private System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs;
|
||||
|
||||
/// <summary>Backing field for the <see cref='Microsoft.VisualStudio.ProjectSystem.Properties.IRule'/> property.</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.Properties.IRule fallbackRule;
|
||||
|
||||
/// <summary>Thread locking object</summary>
|
||||
private object locker = new object();
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorConfiguration class.</summary>
|
||||
internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorConfiguration class.</summary>
|
||||
internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> 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;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorConfiguration class.</summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorConfiguration class.</summary>
|
||||
internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs, string context, Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertyContext) :
|
||||
this(configuredProject, catalogs, context, GetContextFile(propertyContext), propertyContext.ItemType, propertyContext.ItemName) {
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorConfiguration class that assumes a project context (neither property sheet nor items).</summary>
|
||||
internal RazorConfiguration(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs) :
|
||||
this(configuredProject, catalogs, "Project", null, null, null) {
|
||||
}
|
||||
|
||||
/// <summary>Gets the IRule used to get and set properties.</summary>
|
||||
public Microsoft.VisualStudio.ProjectSystem.Properties.IRule Rule {
|
||||
get {
|
||||
return this.rule;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Razor Extensions</summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Get the fallback rule if the current rule on disk is missing or a property in the rule on disk is missing</summary>
|
||||
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<System.Object> 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<System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>>, object, RazorConfiguration> CreateRazorConfigurationPropertiesDelegate = new System.Func<System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>>, object, RazorConfiguration>(CreateRazorConfigurationProperties);
|
||||
|
||||
private static RazorConfiguration CreateRazorConfigurationProperties(System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>> namedCatalogs, object state) {
|
||||
RazorProjectProperties that = ((RazorProjectProperties)(state));
|
||||
return new RazorConfiguration(that.ConfiguredProject, namedCatalogs.Result, "Project", that.File, that.ItemType, that.ItemName);
|
||||
}
|
||||
|
||||
/// <summary>Gets the strongly-typed property accessor used to get and set Configuration Properties properties.</summary>
|
||||
internal System.Threading.Tasks.Task<RazorConfiguration> GetRazorConfigurationPropertiesAsync() {
|
||||
System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>> namedCatalogsTask = this.GetNamedCatalogsAsync();
|
||||
return namedCatalogsTask.ContinueWith(CreateRazorConfigurationPropertiesDelegate, this, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously, System.Threading.Tasks.TaskScheduler.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules {
|
||||
|
||||
|
||||
internal partial class RazorExtension {
|
||||
|
||||
/// <summary>Backing field for deserialized rule.<see cref='Microsoft.Build.Framework.XamlTypes.Rule'/>.</summary>
|
||||
private static Microsoft.Build.Framework.XamlTypes.Rule deserializedFallbackRule;
|
||||
|
||||
/// <summary>The name of the schema to look for at runtime to fulfill property access.</summary>
|
||||
internal const string SchemaName = "RazorExtension";
|
||||
|
||||
/// <summary>The ItemType given in the Rule.DataSource property. May not apply to every Property's individual DataSource.</summary>
|
||||
internal const string PrimaryDataSourceItemType = "RazorExtension";
|
||||
|
||||
/// <summary>The Label given in the Rule.DataSource property. May not apply to every Property's individual DataSource.</summary>
|
||||
internal const string PrimaryDataSourceLabel = "";
|
||||
|
||||
/// <summary>Razor Extension Assembly Name (The "AssemblyName" property).</summary>
|
||||
internal const string AssemblyNameProperty = "AssemblyName";
|
||||
|
||||
/// <summary>Razor Extension Assembly File Path (The "AssemblyFilePath" property).</summary>
|
||||
internal const string AssemblyFilePathProperty = "AssemblyFilePath";
|
||||
|
||||
/// <summary>Backing field for the <see cref='Microsoft.Build.Framework.XamlTypes.Rule'/> property.</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule;
|
||||
|
||||
/// <summary>Backing field for the file name of the rule property.</summary>
|
||||
private string file;
|
||||
|
||||
/// <summary>Backing field for the ItemType property.</summary>
|
||||
private string itemType;
|
||||
|
||||
/// <summary>Backing field for the ItemName property.</summary>
|
||||
private string itemName;
|
||||
|
||||
/// <summary>Configured Project</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject;
|
||||
|
||||
/// <summary>The dictionary of named catalogs.</summary>
|
||||
private System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs;
|
||||
|
||||
/// <summary>Backing field for the <see cref='Microsoft.VisualStudio.ProjectSystem.Properties.IRule'/> property.</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.Properties.IRule fallbackRule;
|
||||
|
||||
/// <summary>Thread locking object</summary>
|
||||
private object locker = new object();
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorExtension class.</summary>
|
||||
internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorExtension class.</summary>
|
||||
internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> 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;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorExtension class.</summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorExtension class.</summary>
|
||||
internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs, string context, Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertyContext) :
|
||||
this(configuredProject, catalogs, context, GetContextFile(propertyContext), propertyContext.ItemType, propertyContext.ItemName) {
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorExtension class that assumes a project context (neither property sheet nor items).</summary>
|
||||
internal RazorExtension(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs) :
|
||||
this(configuredProject, catalogs, "Project", null, null, null) {
|
||||
}
|
||||
|
||||
/// <summary>Gets the IRule used to get and set properties.</summary>
|
||||
public Microsoft.VisualStudio.ProjectSystem.Properties.IRule Rule {
|
||||
get {
|
||||
return this.rule;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Razor Extension Assembly Name</summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Razor Extension Assembly File Path</summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Get the fallback rule if the current rule on disk is missing or a property in the rule on disk is missing</summary>
|
||||
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<System.Object> 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<System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>>, object, RazorExtension> CreateRazorExtensionPropertiesDelegate = new System.Func<System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>>, object, RazorExtension>(CreateRazorExtensionProperties);
|
||||
|
||||
private static RazorExtension CreateRazorExtensionProperties(System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>> namedCatalogs, object state) {
|
||||
RazorProjectProperties that = ((RazorProjectProperties)(state));
|
||||
return new RazorExtension(that.ConfiguredProject, namedCatalogs.Result, "Project", that.File, that.ItemType, that.ItemName);
|
||||
}
|
||||
|
||||
/// <summary>Gets the strongly-typed property accessor used to get and set Extension Properties properties.</summary>
|
||||
internal System.Threading.Tasks.Task<RazorExtension> GetRazorExtensionPropertiesAsync() {
|
||||
System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>> namedCatalogsTask = this.GetNamedCatalogsAsync();
|
||||
return namedCatalogsTask.ContinueWith(CreateRazorExtensionPropertiesDelegate, this, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously, System.Threading.Tasks.TaskScheduler.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem.Rules {
|
||||
|
||||
|
||||
internal partial class RazorGeneral {
|
||||
|
||||
/// <summary>Backing field for deserialized rule.<see cref='Microsoft.Build.Framework.XamlTypes.Rule'/>.</summary>
|
||||
private static Microsoft.Build.Framework.XamlTypes.Rule deserializedFallbackRule;
|
||||
|
||||
/// <summary>The name of the schema to look for at runtime to fulfill property access.</summary>
|
||||
internal const string SchemaName = "RazorGeneral";
|
||||
|
||||
/// <summary>The ItemType given in the Rule.DataSource property. May not apply to every Property's individual DataSource.</summary>
|
||||
internal const string PrimaryDataSourceItemType = null;
|
||||
|
||||
/// <summary>The Label given in the Rule.DataSource property. May not apply to every Property's individual DataSource.</summary>
|
||||
internal const string PrimaryDataSourceLabel = "";
|
||||
|
||||
/// <summary>Razor Language Version (The "RazorLangVersion" property).</summary>
|
||||
internal const string RazorLangVersionProperty = "RazorLangVersion";
|
||||
|
||||
/// <summary>Razor Configuration Name (The "RazorDefaultConfiguration" property).</summary>
|
||||
internal const string RazorDefaultConfigurationProperty = "RazorDefaultConfiguration";
|
||||
|
||||
/// <summary>Backing field for the <see cref='Microsoft.Build.Framework.XamlTypes.Rule'/> property.</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule;
|
||||
|
||||
/// <summary>Backing field for the file name of the rule property.</summary>
|
||||
private string file;
|
||||
|
||||
/// <summary>Backing field for the ItemType property.</summary>
|
||||
private string itemType;
|
||||
|
||||
/// <summary>Backing field for the ItemName property.</summary>
|
||||
private string itemName;
|
||||
|
||||
/// <summary>Configured Project</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject;
|
||||
|
||||
/// <summary>The dictionary of named catalogs.</summary>
|
||||
private System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs;
|
||||
|
||||
/// <summary>Backing field for the <see cref='Microsoft.VisualStudio.ProjectSystem.Properties.IRule'/> property.</summary>
|
||||
private Microsoft.VisualStudio.ProjectSystem.Properties.IRule fallbackRule;
|
||||
|
||||
/// <summary>Thread locking object</summary>
|
||||
private object locker = new object();
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorGeneral class.</summary>
|
||||
internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.Properties.IRule rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorGeneral class.</summary>
|
||||
internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> 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;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorGeneral class.</summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorGeneral class.</summary>
|
||||
internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs, string context, Microsoft.VisualStudio.ProjectSystem.Properties.IProjectPropertiesContext propertyContext) :
|
||||
this(configuredProject, catalogs, context, GetContextFile(propertyContext), propertyContext.ItemType, propertyContext.ItemName) {
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the RazorGeneral class that assumes a project context (neither property sheet nor items).</summary>
|
||||
internal RazorGeneral(Microsoft.VisualStudio.ProjectSystem.ConfiguredProject configuredProject, System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog> catalogs) :
|
||||
this(configuredProject, catalogs, "Project", null, null, null) {
|
||||
}
|
||||
|
||||
/// <summary>Gets the IRule used to get and set properties.</summary>
|
||||
public Microsoft.VisualStudio.ProjectSystem.Properties.IRule Rule {
|
||||
get {
|
||||
return this.rule;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Razor Language Version</summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Razor Configuration Name</summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Get the fallback rule if the current rule on disk is missing or a property in the rule on disk is missing</summary>
|
||||
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<System.Object> 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<System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>>, object, RazorGeneral> CreateRazorGeneralPropertiesDelegate = new System.Func<System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>>, object, RazorGeneral>(CreateRazorGeneralProperties);
|
||||
|
||||
private static RazorGeneral CreateRazorGeneralProperties(System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>> namedCatalogs, object state) {
|
||||
RazorProjectProperties that = ((RazorProjectProperties)(state));
|
||||
return new RazorGeneral(that.ConfiguredProject, namedCatalogs.Result, "Project", that.File, that.ItemType, that.ItemName);
|
||||
}
|
||||
|
||||
/// <summary>Gets the strongly-typed property accessor used to get and set Razor Properties properties.</summary>
|
||||
internal System.Threading.Tasks.Task<RazorGeneral> GetRazorGeneralPropertiesAsync() {
|
||||
System.Threading.Tasks.Task<System.Collections.Immutable.IImmutableDictionary<string, Microsoft.VisualStudio.ProjectSystem.Properties.IPropertyPagesCatalog>> namedCatalogsTask = this.GetNamedCatalogsAsync();
|
||||
return namedCatalogsTask.ContinueWith(CreateRazorGeneralPropertiesDelegate, this, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously, System.Threading.Tasks.TaskScheduler.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue