Change GenerateChecksum to SuppressChecksum
This commit is contained in:
parent
3892a6fede
commit
dd4e163173
|
|
@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
|
||||
public override void VisitDocument(DocumentIRNode node)
|
||||
{
|
||||
if (Context.Options.GenerateChecksum)
|
||||
if (!Context.Options.SuppressChecksum)
|
||||
{
|
||||
// See http://msdn.microsoft.com/en-us/library/system.codedom.codechecksumpragma.checksumalgorithmid.aspx
|
||||
const string Sha1AlgorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}";
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
internal class DefaultRazorCodeGenerationOptions : RazorCodeGenerationOptions
|
||||
{
|
||||
public DefaultRazorCodeGenerationOptions(bool indentWithTabs, int indentSize, bool designTime, bool generateChecksum)
|
||||
public DefaultRazorCodeGenerationOptions(bool indentWithTabs, int indentSize, bool designTime, bool suppressChecksum)
|
||||
{
|
||||
IndentWithTabs = indentWithTabs;
|
||||
IndentSize = indentSize;
|
||||
DesignTime = designTime;
|
||||
GenerateChecksum = generateChecksum;
|
||||
SuppressChecksum = suppressChecksum;
|
||||
}
|
||||
|
||||
public override bool DesignTime { get; }
|
||||
|
|
@ -21,6 +19,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public override int IndentSize { get; }
|
||||
|
||||
public override bool GenerateChecksum { get; }
|
||||
public override bool SuppressChecksum { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public override bool IndentWithTabs { get; set; }
|
||||
|
||||
public override bool GenerateChecksum { get; set; }
|
||||
public override bool SuppressChecksum { get; set; }
|
||||
|
||||
public override RazorCodeGenerationOptions Build()
|
||||
{
|
||||
return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, GenerateChecksum);
|
||||
return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, SuppressChecksum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
}
|
||||
|
||||
options.DesignTime = true;
|
||||
options.GenerateChecksum = false;
|
||||
options.SuppressChecksum = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
public abstract class RazorCodeGenerationOptions
|
||||
{
|
||||
public static RazorCodeGenerationOptions Create(bool indentWithTabs, int indentSize, bool designTime, bool generateChecksum)
|
||||
public static RazorCodeGenerationOptions Create(bool indentWithTabs, int indentSize, bool designTime, bool suppressChecksum)
|
||||
{
|
||||
return new DefaultRazorCodeGenerationOptions(indentWithTabs, indentSize, designTime, generateChecksum);
|
||||
return new DefaultRazorCodeGenerationOptions(indentWithTabs, indentSize, designTime, suppressChecksum);
|
||||
}
|
||||
|
||||
public static RazorCodeGenerationOptions CreateDefault()
|
||||
{
|
||||
return new DefaultRazorCodeGenerationOptions(indentWithTabs: false, indentSize: 4, designTime: false, generateChecksum: true);
|
||||
return new DefaultRazorCodeGenerationOptions(indentWithTabs: false, indentSize: 4, designTime: false, suppressChecksum: false);
|
||||
}
|
||||
|
||||
public abstract bool DesignTime { get; }
|
||||
|
|
@ -21,6 +21,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public abstract int IndentSize { get; }
|
||||
|
||||
public abstract bool GenerateChecksum { get; }
|
||||
public abstract bool SuppressChecksum { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public abstract bool IndentWithTabs { get; set; }
|
||||
|
||||
public abstract bool GenerateChecksum { get; set; }
|
||||
public abstract bool SuppressChecksum { get; set; }
|
||||
|
||||
public abstract RazorCodeGenerationOptions Build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,9 +102,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
internal static void AddRuntimeDefaults(IRazorEngineBuilder builder)
|
||||
{
|
||||
builder.Features.Add(new RazorPreallocatedTagHelperAttributeOptimizationPass());
|
||||
|
||||
// Configure options
|
||||
builder.Features.Add(new RuntimeOptionsFeature());
|
||||
}
|
||||
|
||||
internal static void AddDesignTimeDefaults(IRazorEngineBuilder builder)
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
// 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;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language
|
||||
{
|
||||
internal class RuntimeOptionsFeature : RazorEngineFeatureBase, IRazorParserOptionsFeature, IRazorCodeGenerationOptionsFeature
|
||||
{
|
||||
public int Order { get; set; }
|
||||
|
||||
public void Configure(RazorParserOptionsBuilder options)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
options.DesignTime = false;
|
||||
}
|
||||
|
||||
public void Configure(RazorCodeGenerationOptionsBuilder options)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
options.DesignTime = false;
|
||||
options.GenerateChecksum = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ namespace RazorPageGenerator
|
|||
@class.AccessModifier = "internal";
|
||||
});
|
||||
|
||||
builder.Features.Add(new DisableChecksumOptionsFeature());
|
||||
builder.Features.Add(new SuppressChecksumOptionsFeature());
|
||||
});
|
||||
|
||||
var viewDirectories = Directory.EnumerateDirectories(targetProjectDirectory, "Views", SearchOption.AllDirectories);
|
||||
|
|
@ -107,7 +107,7 @@ namespace RazorPageGenerator
|
|||
};
|
||||
}
|
||||
|
||||
private class DisableChecksumOptionsFeature : RazorEngineFeatureBase, IRazorCodeGenerationOptionsFeature
|
||||
private class SuppressChecksumOptionsFeature : RazorEngineFeatureBase, IRazorCodeGenerationOptionsFeature
|
||||
{
|
||||
public int Order { get; set; }
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ namespace RazorPageGenerator
|
|||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
options.GenerateChecksum = false;
|
||||
options.SuppressChecksum = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void WriteDocument_Empty_GenerateChecksumFalse_WritesNothing()
|
||||
public void WriteDocument_Empty_SuppressChecksumTrue_WritesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var optionsBuilder = new DefaultRazorCodeGenerationOptionsBuilder()
|
||||
{
|
||||
GenerateChecksum = false
|
||||
SuppressChecksum = true
|
||||
};
|
||||
var options = optionsBuilder.Build();
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
o.DesignTime = true;
|
||||
o.IndentSize = 17;
|
||||
o.IndentWithTabs = true;
|
||||
o.GenerateChecksum = true;
|
||||
o.SuppressChecksum = true;
|
||||
});
|
||||
|
||||
// Act
|
||||
|
|
@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
Assert.True(irDocument.Options.DesignTime);
|
||||
Assert.Equal(17, irDocument.Options.IndentSize);
|
||||
Assert.True(irDocument.Options.IndentWithTabs);
|
||||
Assert.True(irDocument.Options.GenerateChecksum);
|
||||
Assert.True(irDocument.Options.SuppressChecksum);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -152,8 +152,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
feature => Assert.IsType<DefaultDocumentClassifierPass>(feature),
|
||||
feature => Assert.IsType<DirectiveRemovalIROptimizationPass>(feature),
|
||||
feature => Assert.IsType<DefaultDocumentClassifierPassFeature>(feature),
|
||||
feature => Assert.IsType<RazorPreallocatedTagHelperAttributeOptimizationPass>(feature),
|
||||
feature => Assert.IsType<RuntimeOptionsFeature>(feature));
|
||||
feature => Assert.IsType<RazorPreallocatedTagHelperAttributeOptimizationPass>(feature));
|
||||
}
|
||||
|
||||
private static void AssertDefaultRuntimePhases(IReadOnlyList<IRazorEnginePhase> phases)
|
||||
|
|
|
|||
Loading…
Reference in New Issue