Change GenerateChecksum to SuppressChecksum

This commit is contained in:
Ajay Bhargav Baaskaran 2017-06-19 16:52:36 -07:00
parent 3892a6fede
commit dd4e163173
12 changed files with 20 additions and 59 deletions

View File

@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
public override void VisitDocument(DocumentIRNode node) 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 // See http://msdn.microsoft.com/en-us/library/system.codedom.codechecksumpragma.checksumalgorithmid.aspx
const string Sha1AlgorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}"; const string Sha1AlgorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}";

View File

@ -1,18 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved. // 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. // 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 namespace Microsoft.AspNetCore.Razor.Language
{ {
internal class DefaultRazorCodeGenerationOptions : RazorCodeGenerationOptions 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; IndentWithTabs = indentWithTabs;
IndentSize = indentSize; IndentSize = indentSize;
DesignTime = designTime; DesignTime = designTime;
GenerateChecksum = generateChecksum; SuppressChecksum = suppressChecksum;
} }
public override bool DesignTime { get; } public override bool DesignTime { get; }
@ -21,6 +19,6 @@ namespace Microsoft.AspNetCore.Razor.Language
public override int IndentSize { get; } public override int IndentSize { get; }
public override bool GenerateChecksum { get; } public override bool SuppressChecksum { get; }
} }
} }

View File

@ -11,11 +11,11 @@ namespace Microsoft.AspNetCore.Razor.Language
public override bool IndentWithTabs { get; set; } public override bool IndentWithTabs { get; set; }
public override bool GenerateChecksum { get; set; } public override bool SuppressChecksum { get; set; }
public override RazorCodeGenerationOptions Build() public override RazorCodeGenerationOptions Build()
{ {
return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, GenerateChecksum); return new DefaultRazorCodeGenerationOptions(IndentWithTabs, IndentSize, DesignTime, SuppressChecksum);
} }
} }
} }

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language
} }
options.DesignTime = true; options.DesignTime = true;
options.GenerateChecksum = false; options.SuppressChecksum = true;
} }
} }
} }

View File

@ -5,14 +5,14 @@ namespace Microsoft.AspNetCore.Razor.Language
{ {
public abstract class RazorCodeGenerationOptions 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() 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; } public abstract bool DesignTime { get; }
@ -21,6 +21,6 @@ namespace Microsoft.AspNetCore.Razor.Language
public abstract int IndentSize { get; } public abstract int IndentSize { get; }
public abstract bool GenerateChecksum { get; } public abstract bool SuppressChecksum { get; }
} }
} }

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public abstract bool IndentWithTabs { get; set; } public abstract bool IndentWithTabs { get; set; }
public abstract bool GenerateChecksum { get; set; } public abstract bool SuppressChecksum { get; set; }
public abstract RazorCodeGenerationOptions Build(); public abstract RazorCodeGenerationOptions Build();
} }

View File

@ -102,9 +102,6 @@ namespace Microsoft.AspNetCore.Razor.Language
internal static void AddRuntimeDefaults(IRazorEngineBuilder builder) internal static void AddRuntimeDefaults(IRazorEngineBuilder builder)
{ {
builder.Features.Add(new RazorPreallocatedTagHelperAttributeOptimizationPass()); builder.Features.Add(new RazorPreallocatedTagHelperAttributeOptimizationPass());
// Configure options
builder.Features.Add(new RuntimeOptionsFeature());
} }
internal static void AddDesignTimeDefaults(IRazorEngineBuilder builder) internal static void AddDesignTimeDefaults(IRazorEngineBuilder builder)

View File

@ -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;
}
}
}

View File

@ -50,7 +50,7 @@ namespace RazorPageGenerator
@class.AccessModifier = "internal"; @class.AccessModifier = "internal";
}); });
builder.Features.Add(new DisableChecksumOptionsFeature()); builder.Features.Add(new SuppressChecksumOptionsFeature());
}); });
var viewDirectories = Directory.EnumerateDirectories(targetProjectDirectory, "Views", SearchOption.AllDirectories); 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; } public int Order { get; set; }
@ -118,7 +118,7 @@ namespace RazorPageGenerator
throw new ArgumentNullException(nameof(options)); throw new ArgumentNullException(nameof(options));
} }
options.GenerateChecksum = false; options.SuppressChecksum = true;
} }
} }

View File

@ -42,13 +42,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
} }
[Fact] [Fact]
public void WriteDocument_Empty_GenerateChecksumFalse_WritesNothing() public void WriteDocument_Empty_SuppressChecksumTrue_WritesNothing()
{ {
// Arrange // Arrange
var codeDocument = TestRazorCodeDocument.CreateEmpty(); var codeDocument = TestRazorCodeDocument.CreateEmpty();
var optionsBuilder = new DefaultRazorCodeGenerationOptionsBuilder() var optionsBuilder = new DefaultRazorCodeGenerationOptionsBuilder()
{ {
GenerateChecksum = false SuppressChecksum = true
}; };
var options = optionsBuilder.Build(); var options = optionsBuilder.Build();

View File

@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Razor.Language
o.DesignTime = true; o.DesignTime = true;
o.IndentSize = 17; o.IndentSize = 17;
o.IndentWithTabs = true; o.IndentWithTabs = true;
o.GenerateChecksum = true; o.SuppressChecksum = true;
}); });
// Act // Act
@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Razor.Language
Assert.True(irDocument.Options.DesignTime); Assert.True(irDocument.Options.DesignTime);
Assert.Equal(17, irDocument.Options.IndentSize); Assert.Equal(17, irDocument.Options.IndentSize);
Assert.True(irDocument.Options.IndentWithTabs); Assert.True(irDocument.Options.IndentWithTabs);
Assert.True(irDocument.Options.GenerateChecksum); Assert.True(irDocument.Options.SuppressChecksum);
} }
[Fact] [Fact]

View File

@ -152,8 +152,7 @@ namespace Microsoft.AspNetCore.Razor.Language
feature => Assert.IsType<DefaultDocumentClassifierPass>(feature), feature => Assert.IsType<DefaultDocumentClassifierPass>(feature),
feature => Assert.IsType<DirectiveRemovalIROptimizationPass>(feature), feature => Assert.IsType<DirectiveRemovalIROptimizationPass>(feature),
feature => Assert.IsType<DefaultDocumentClassifierPassFeature>(feature), feature => Assert.IsType<DefaultDocumentClassifierPassFeature>(feature),
feature => Assert.IsType<RazorPreallocatedTagHelperAttributeOptimizationPass>(feature), feature => Assert.IsType<RazorPreallocatedTagHelperAttributeOptimizationPass>(feature));
feature => Assert.IsType<RuntimeOptionsFeature>(feature));
} }
private static void AssertDefaultRuntimePhases(IReadOnlyList<IRazorEnginePhase> phases) private static void AssertDefaultRuntimePhases(IReadOnlyList<IRazorEnginePhase> phases)