parent
f33e1fca53
commit
40340e9b91
|
|
@ -56,12 +56,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
||||||
target.WriteInjectProperty(context, node);
|
target.WriteInjectProperty(context, node);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(Environment.NewLine +
|
||||||
|
"#nullable restore" + Environment.NewLine +
|
||||||
"#line 2 \"test-path\"" + Environment.NewLine +
|
"#line 2 \"test-path\"" + Environment.NewLine +
|
||||||
"[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]" + Environment.NewLine +
|
"[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]" + Environment.NewLine +
|
||||||
"public PropertyType<ModelType> PropertyName { get; private set; }" + Environment.NewLine + Environment.NewLine +
|
"public PropertyType<ModelType> PropertyName { get; private set; }" + Environment.NewLine + Environment.NewLine +
|
||||||
"#line default" + Environment.NewLine +
|
"#line default" + Environment.NewLine +
|
||||||
"#line hidden" + Environment.NewLine,
|
"#line hidden" + Environment.NewLine +
|
||||||
|
"#nullable disable" + Environment.NewLine,
|
||||||
context.CodeWriter.GenerateCode());
|
context.CodeWriter.GenerateCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -616,6 +616,11 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||||
|
|
||||||
if (!_codeGenerationOptions.SuppressNullabilityEnforcement)
|
if (!_codeGenerationOptions.SuppressNullabilityEnforcement)
|
||||||
{
|
{
|
||||||
|
var endsWithNewline = _writer.Length > 0 && _writer[_writer.Length - 1] == '\n';
|
||||||
|
if (!endsWithNewline)
|
||||||
|
{
|
||||||
|
_writer.WriteLine();
|
||||||
|
}
|
||||||
_writer.WriteLine("#nullable restore");
|
_writer.WriteLine("#nullable restore");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
|
||||||
// the "usings directive is unnecessary" message.
|
// the "usings directive is unnecessary" message.
|
||||||
// Looks like:
|
// Looks like:
|
||||||
// __o = typeof(SomeNamespace.SomeComponent);
|
// __o = typeof(SomeNamespace.SomeComponent);
|
||||||
using (context.CodeWriter.BuildLinePragma(node.Source.Value))
|
using (context.CodeWriter.BuildLinePragma(node.Source.Value, context))
|
||||||
{
|
{
|
||||||
context.CodeWriter.Write(DesignTimeVariable);
|
context.CodeWriter.Write(DesignTimeVariable);
|
||||||
context.CodeWriter.Write(" = ");
|
context.CodeWriter.Write(" = ");
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
bool designTime,
|
bool designTime,
|
||||||
string rootNamespace,
|
string rootNamespace,
|
||||||
bool suppressChecksum,
|
bool suppressChecksum,
|
||||||
bool supressMetadataAttributes,
|
bool suppressMetadataAttributes,
|
||||||
bool suppressPrimaryMethodBody,
|
bool suppressPrimaryMethodBody,
|
||||||
bool suppressNullabilityEnforcement)
|
bool suppressNullabilityEnforcement)
|
||||||
{
|
{
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
DesignTime = designTime;
|
DesignTime = designTime;
|
||||||
RootNamespace = rootNamespace;
|
RootNamespace = rootNamespace;
|
||||||
SuppressChecksum = suppressChecksum;
|
SuppressChecksum = suppressChecksum;
|
||||||
SuppressMetadataAttributes = supressMetadataAttributes;
|
SuppressMetadataAttributes = suppressMetadataAttributes;
|
||||||
SuppressPrimaryMethodBody = suppressPrimaryMethodBody;
|
SuppressPrimaryMethodBody = suppressPrimaryMethodBody;
|
||||||
SuppressNullabilityEnforcement = suppressNullabilityEnforcement;
|
SuppressNullabilityEnforcement = suppressNullabilityEnforcement;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
designTime: false,
|
designTime: false,
|
||||||
suppressChecksum: false,
|
suppressChecksum: false,
|
||||||
rootNamespace: null,
|
rootNamespace: null,
|
||||||
supressMetadataAttributes: false,
|
suppressMetadataAttributes: false,
|
||||||
suppressPrimaryMethodBody: false,
|
suppressPrimaryMethodBody: false,
|
||||||
suppressNullabilityEnforcement: false);
|
suppressNullabilityEnforcement: false);
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
designTime: true,
|
designTime: true,
|
||||||
rootNamespace: null,
|
rootNamespace: null,
|
||||||
suppressChecksum: false,
|
suppressChecksum: false,
|
||||||
supressMetadataAttributes: true,
|
suppressMetadataAttributes: true,
|
||||||
suppressPrimaryMethodBody: false,
|
suppressPrimaryMethodBody: false,
|
||||||
suppressNullabilityEnforcement: false);
|
suppressNullabilityEnforcement: false);
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
public virtual bool SuppressPrimaryMethodBody { get; protected set; }
|
public virtual bool SuppressPrimaryMethodBody { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value that determines if nullability type enforcement is restored to project settings for user code.
|
/// Gets a value that determines if nullability type enforcement should be suppressed for user code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool SuppressNullabilityEnforcement { get; }
|
public virtual bool SuppressNullabilityEnforcement { get; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
||||||
public virtual bool SuppressPrimaryMethodBody { get; set; }
|
public virtual bool SuppressPrimaryMethodBody { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value that determines if nullability type enforcement is restored to project settings for user code.
|
/// Gets or sets a value that determines if nullability type enforcement should be suppressed for user code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool SuppressNullabilityEnforcement { get; set; }
|
public virtual bool SuppressNullabilityEnforcement { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.Razor
|
||||||
public static class RazorProjectEngineBuilderExtensions
|
public static class RazorProjectEngineBuilderExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the C# language version to respect when generating code.
|
/// Sets the C# language version to target when generating code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="builder">The <see cref="RazorProjectEngineBuilder"/>.</param>
|
/// <param name="builder">The <see cref="RazorProjectEngineBuilder"/>.</param>
|
||||||
/// <param name="csharpLanguageVersion">The C# <see cref="LanguageVersion"/>.</param>
|
/// <param name="csharpLanguageVersion">The C# <see cref="LanguageVersion"/>.</param>
|
||||||
|
|
@ -26,12 +26,6 @@ namespace Microsoft.CodeAnalysis.Razor
|
||||||
throw new ArgumentNullException(nameof(builder));
|
throw new ArgumentNullException(nameof(builder));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builder.Configuration.LanguageVersion.Major < 3)
|
|
||||||
{
|
|
||||||
// Prior to 3.0 there were no C# version specific controlled features so there's no value in setting a CSharp language version, noop.
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
var existingFeature = builder.Features.OfType<ConfigureParserForCSharpVersionFeature>().FirstOrDefault();
|
var existingFeature = builder.Features.OfType<ConfigureParserForCSharpVersionFeature>().FirstOrDefault();
|
||||||
if (existingFeature != null)
|
if (existingFeature != null)
|
||||||
{
|
{
|
||||||
|
|
@ -63,8 +57,16 @@ namespace Microsoft.CodeAnalysis.Razor
|
||||||
throw new ArgumentNullException(nameof(options));
|
throw new ArgumentNullException(nameof(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.Configuration.LanguageVersion.Major < 3)
|
||||||
|
{
|
||||||
|
// Prior to 3.0 there were no C# version specific controlled features. Suppress nullability enforcement.
|
||||||
|
options.SuppressNullabilityEnforcement = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (CSharpLanguageVersion < LanguageVersion.CSharp8)
|
if (CSharpLanguageVersion < LanguageVersion.CSharp8)
|
||||||
{
|
{
|
||||||
|
// Having nullable flags < C# 8.0 would cause compile errors.
|
||||||
options.SuppressNullabilityEnforcement = true;
|
options.SuppressNullabilityEnforcement = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -73,10 +75,11 @@ namespace Microsoft.CodeAnalysis.Razor
|
||||||
// cases in tooling when the project isn't fully configured yet at which point the CSharpLanguageVersion
|
// cases in tooling when the project isn't fully configured yet at which point the CSharpLanguageVersion
|
||||||
// may be Default (value 0). In those cases that C# version is equivalently "unspecified" and is up to the consumer
|
// may be Default (value 0). In those cases that C# version is equivalently "unspecified" and is up to the consumer
|
||||||
// to act in a safe manner to not cause unneeded errors for older compilers. Therefore if the version isn't
|
// to act in a safe manner to not cause unneeded errors for older compilers. Therefore if the version isn't
|
||||||
// >= 8.0 (or Latest) then nullability enforcement is suppressed.
|
// >= 8.0 (Latest has a higher value) then nullability enforcement is suppressed.
|
||||||
//
|
//
|
||||||
// Once the project finishes configuration the C# language version will be updated to reflect the effective
|
// Once the project finishes configuration the C# language version will be updated to reflect the effective
|
||||||
// language version for the project.
|
// language version for the project by our workspace change detectors. That mechanism extracts the correlated
|
||||||
|
// Roslyn project and acquires the effective C# version at that point.
|
||||||
options.SuppressNullabilityEnforcement = false;
|
options.SuppressNullabilityEnforcement = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<Project ToolsVersion="14.0">
|
<Project ToolsVersion="14.0">
|
||||||
<!--
|
<!--
|
||||||
What follows in this file is based on:
|
What follows in this file is based on:
|
||||||
https://github.com/dotnet/roslyn/blob/4d92b18aee99ba8b1b4770ce65133e9ca65a94fe/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets
|
https://github.com/dotnet/roslyn/blob/db4f836b97db1e7ad261e51c67cc80c6f3c28791/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets
|
||||||
|
|
||||||
We need to keep this basically up to date, as well as track the set of modifications we've made. Try to keep the formatting
|
We need to keep this basically up to date, as well as track the set of modifications we've made. Try to keep the formatting
|
||||||
similar to the original to reduce noise. In general try to only deviate from the CoreCompile target when we need to for
|
similar to the original to reduce noise. In general try to only deviate from the CoreCompile target when we need to for
|
||||||
|
|
@ -25,32 +25,45 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
Changes:
|
Changes:
|
||||||
Name="RazorCoreCompile"
|
Name="RazorCoreCompile"
|
||||||
|
|
||||||
|
Replace Name="CoreCompile" with Name="RazorCoreCompile"
|
||||||
Replace @(Compile) with @(RazorCompile)
|
Replace @(Compile) with @(RazorCompile)
|
||||||
Replace @(_DebugSymbolsIntermediatePath) with @(_RazorDebugSymbolsIntermediatePath)
|
Replace @(_DebugSymbolsIntermediatePath) with @(_RazorDebugSymbolsIntermediatePath)
|
||||||
Replace @(IntermediateAssembly) with @(RazorIntermediateAssembly)
|
Replace @(IntermediateAssembly) with @(RazorIntermediateAssembly)
|
||||||
Replace @(ReferencePathWithRefAssemblies) with @(RazorReferencePath)
|
Replace @(ReferencePathWithRefAssemblies) with @(RazorReferencePath)
|
||||||
Remove @(_CoreCompileResourceInputs) with @(_RazorCoreCompileResourceInputs)
|
Replace @(_CoreCompileResourceInputs) with @(_RazorCoreCompileResourceInputs)
|
||||||
|
Replace <Csc Condition="'%(_CoreCompileResourceInputs.WithCulture)' != 'true'" with <Csc
|
||||||
|
Remove comment above ^
|
||||||
|
|
||||||
Set TargetType="$(OutputType)" to TargetType="Library" - Razor is always a .dll
|
Set TargetType="$(OutputType)" to TargetType="Library" - Razor is always a .dll
|
||||||
|
|
||||||
|
Remove Returns="@(CscCommandLineArgs)"
|
||||||
|
Remove <Import Project="Microsoft.Managed.Core.targets"/>
|
||||||
Remove Returns="@(CscCommandLineArgs)"
|
Remove Returns="@(CscCommandLineArgs)"
|
||||||
|
|
||||||
Remove @(EmbeddedFiles)
|
Remove @(EmbeddedFiles)
|
||||||
Remove $(ApplicationIcon) $(Win32Resource) $(Win32Manifest)
|
Remove $(ApplicationIcon) $(Win32Resource) $(Win32Manifest)
|
||||||
Remove @(EmbeddedDocumentation) and @(EmbeddedFiles)
|
Remove @(EmbeddedDocumentation) and @(EmbeddedFiles)
|
||||||
Remove @(CustomAdditionalCompileInputs) and @(CustomAdditionalCompileOutputs)
|
Remove @(CustomAdditionalCompileInputs) and @(CustomAdditionalCompileOutputs)
|
||||||
Remove @(DocFileItem)
|
Remove @(DocFileItem)
|
||||||
Remove PdbFile="$(PdbFile)"
|
Remove PdbFile="$(PdbFile)"
|
||||||
|
Remove $(IntermediateRefAssembly)
|
||||||
Remove OutputRefAssembly="@(IntermediateRefAssembly)"
|
Remove OutputRefAssembly="@(IntermediateRefAssembly)"
|
||||||
Remove MainEntryPoint="$(StartupObject)"
|
Remove MainEntryPoint="$(StartupObject)"
|
||||||
|
Remove winmdobj <PdbFile ....> and comment
|
||||||
|
Remove RefOnly="$(ProduceOnlyReferenceAssembly)"
|
||||||
|
Remove Win32Icon="$(ApplicationIcon)"
|
||||||
|
Remove Win32Manifest="$(Win32Manifest)"
|
||||||
|
Remove Win32Resource="$(Win32Resource)"
|
||||||
|
Remove DocumentationFile="@(DocFileItem)"
|
||||||
|
|
||||||
Remove EmbedAllSources="$(EmbedAllSources)" - not supported by our supported version of MSBuild
|
Remove EmbedAllSources="$(EmbedAllSources)" - not supported by our supported version of MSBuild
|
||||||
|
|
||||||
Remove additional steps after calling CSC
|
Remove additional steps after calling CSC
|
||||||
|
|
||||||
Add our FileWrites after the call to CSC
|
Add our FileWrites after the call to CSC
|
||||||
|
|
||||||
|
Add Condition="'@(RazorCompile)'!=''" as a condition to the RazorCoreCompile target.
|
||||||
-->
|
-->
|
||||||
<Target Name="RazorCoreCompile"
|
<Target Name="RazorCoreCompile"
|
||||||
Inputs="$(MSBuildAllProjects);
|
Inputs="$(MSBuildAllProjects);
|
||||||
@(RazorCompile);
|
@(RazorCompile);
|
||||||
$(AssemblyOriginatorKeyFile);
|
$(AssemblyOriginatorKeyFile);
|
||||||
|
|
@ -76,12 +89,6 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<NoWarn Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(VisualStudioVersion)' != '' AND '$(VisualStudioVersion)' > '10.0'">$(NoWarn);2008</NoWarn>
|
<NoWarn Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(VisualStudioVersion)' != '' AND '$(VisualStudioVersion)' > '10.0'">$(NoWarn);2008</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetingClr2Framework)' == 'true'">
|
|
||||||
<ReferencePathWithRefAssemblies>
|
|
||||||
<EmbedInteropTypes />
|
|
||||||
</ReferencePathWithRefAssemblies>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
|
<!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
|
||||||
then we'll use AppConfig -->
|
then we'll use AppConfig -->
|
||||||
|
|
@ -104,6 +111,12 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<UseSharedCompilation>true</UseSharedCompilation>
|
<UseSharedCompilation>true</UseSharedCompilation>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<LangVersion Condition="'$(LangVersion)' == '' AND
|
||||||
|
(('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(TargetFrameworkVersion)' == 'v3.0') OR
|
||||||
|
('$(TargetFrameworkIdentifier)' == '.NETStandard' AND '$(TargetFrameworkVersion)' == 'v2.1'))">8.0</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<Csc
|
<Csc
|
||||||
AdditionalLibPaths="$(AdditionalLibPaths)"
|
AdditionalLibPaths="$(AdditionalLibPaths)"
|
||||||
AddModules="@(AddModules)"
|
AddModules="@(AddModules)"
|
||||||
|
|
@ -120,6 +133,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
DefineConstants="$(DefineConstants)"
|
DefineConstants="$(DefineConstants)"
|
||||||
DelaySign="$(DelaySign)"
|
DelaySign="$(DelaySign)"
|
||||||
DisabledWarnings="$(NoWarn)"
|
DisabledWarnings="$(NoWarn)"
|
||||||
|
DisableSdkPath="$(DisableSdkPath)"
|
||||||
EmitDebugInformation="$(DebugSymbols)"
|
EmitDebugInformation="$(DebugSymbols)"
|
||||||
EnvironmentVariables="$(CscEnvironment)"
|
EnvironmentVariables="$(CscEnvironment)"
|
||||||
ErrorEndLocation="$(ErrorEndLocation)"
|
ErrorEndLocation="$(ErrorEndLocation)"
|
||||||
|
|
@ -139,6 +153,7 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
NoLogo="$(NoLogo)"
|
NoLogo="$(NoLogo)"
|
||||||
NoStandardLib="$(NoCompilerStandardLib)"
|
NoStandardLib="$(NoCompilerStandardLib)"
|
||||||
NoWin32Manifest="$(NoWin32Manifest)"
|
NoWin32Manifest="$(NoWin32Manifest)"
|
||||||
|
NullableContextOptions="$(NullableContextOptions)"
|
||||||
Optimize="$(Optimize)"
|
Optimize="$(Optimize)"
|
||||||
Deterministic="$(Deterministic)"
|
Deterministic="$(Deterministic)"
|
||||||
PublicSign="$(PublicSign)"
|
PublicSign="$(PublicSign)"
|
||||||
|
|
|
||||||
|
|
@ -153,12 +153,6 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<NoWarn Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(VisualStudioVersion)' != '' AND '$(VisualStudioVersion)' > '10.0'">$(NoWarn);2008</NoWarn>
|
<NoWarn Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(VisualStudioVersion)' != '' AND '$(VisualStudioVersion)' > '10.0'">$(NoWarn);2008</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetingClr2Framework)' == 'true'">
|
|
||||||
<ReferencePathWithRefAssemblies>
|
|
||||||
<EmbedInteropTypes />
|
|
||||||
</ReferencePathWithRefAssemblies>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
|
<!-- If the user has specified AppConfigForCompiler, we'll use it. If they have not, but they set UseAppConfigForCompiler,
|
||||||
then we'll use AppConfig -->
|
then we'll use AppConfig -->
|
||||||
|
|
@ -181,6 +175,12 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<UseSharedCompilation>true</UseSharedCompilation>
|
<UseSharedCompilation>true</UseSharedCompilation>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<LangVersion Condition="'$(LangVersion)' == '' AND
|
||||||
|
(('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(TargetFrameworkVersion)' == 'v3.0') OR
|
||||||
|
('$(TargetFrameworkIdentifier)' == '.NETStandard' AND '$(TargetFrameworkVersion)' == 'v2.1'))">8.0</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<Csc
|
<Csc
|
||||||
AdditionalLibPaths="$(AdditionalLibPaths)"
|
AdditionalLibPaths="$(AdditionalLibPaths)"
|
||||||
AddModules="@(AddModules)"
|
AddModules="@(AddModules)"
|
||||||
|
|
@ -211,12 +211,12 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
KeyFile="$(KeyOriginatorFile)"
|
KeyFile="$(KeyOriginatorFile)"
|
||||||
LangVersion="$(LangVersion)"
|
LangVersion="$(LangVersion)"
|
||||||
LinkResources="@(LinkResource)"
|
LinkResources="@(LinkResource)"
|
||||||
MainEntryPoint="$(StartupObject)"
|
|
||||||
ModuleAssemblyName="$(ModuleAssemblyName)"
|
ModuleAssemblyName="$(ModuleAssemblyName)"
|
||||||
NoConfig="true"
|
NoConfig="true"
|
||||||
NoLogo="$(NoLogo)"
|
NoLogo="$(NoLogo)"
|
||||||
NoStandardLib="$(NoCompilerStandardLib)"
|
NoStandardLib="$(NoCompilerStandardLib)"
|
||||||
NoWin32Manifest="$(NoWin32Manifest)"
|
NoWin32Manifest="$(NoWin32Manifest)"
|
||||||
|
NullableContextOptions="$(NullableContextOptions)"
|
||||||
Optimize="$(Optimize)"
|
Optimize="$(Optimize)"
|
||||||
Deterministic="$(Deterministic)"
|
Deterministic="$(Deterministic)"
|
||||||
PublicSign="$(PublicSign)"
|
PublicSign="$(PublicSign)"
|
||||||
|
|
|
||||||
|
|
@ -647,6 +647,37 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
|
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[InitializeTestProject("SimpleMvc")]
|
||||||
|
public async Task Build_CSharp8_NullableEnforcement_WarningsDuringBuild_BuildServer()
|
||||||
|
{
|
||||||
|
var result = await DotnetMSBuild(
|
||||||
|
"Build",
|
||||||
|
"/p:LangVersion=8.0 /p:NullableContextOptions=enable");
|
||||||
|
var indexFilePath = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs");
|
||||||
|
|
||||||
|
Assert.BuildPassed(result, allowWarnings: true);
|
||||||
|
Assert.BuildWarning(result, "CS8618", "Models\\ErrorViewModel.cs(5,18)");
|
||||||
|
Assert.FileContainsLine(result, indexFilePath, "#nullable restore");
|
||||||
|
Assert.FileContainsLine(result, indexFilePath, "#nullable disable");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[InitializeTestProject("SimpleMvc")]
|
||||||
|
public async Task Build_CSharp8_NullableEnforcement_WarningsDuringBuild_NoBuildServer()
|
||||||
|
{
|
||||||
|
var result = await DotnetMSBuild(
|
||||||
|
"Build",
|
||||||
|
"/p:LangVersion=8.0 /p:NullableContextOptions=enable",
|
||||||
|
suppressBuildServer: true);
|
||||||
|
var indexFilePath = Path.Combine(RazorIntermediateOutputPath, "Views", "Home", "Index.cshtml.g.cs");
|
||||||
|
|
||||||
|
Assert.BuildPassed(result, allowWarnings: true);
|
||||||
|
Assert.BuildWarning(result, "CS8618", "Models\\ErrorViewModel.cs(5,18)");
|
||||||
|
Assert.FileContainsLine(result, indexFilePath, "#nullable restore");
|
||||||
|
Assert.FileContainsLine(result, indexFilePath, "#nullable disable");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("SimpleMvc")]
|
[InitializeTestProject("SimpleMvc")]
|
||||||
public async Task Build_Mvc_WithoutAddRazorSupportForMvc()
|
public async Task Build_Mvc_WithoutAddRazorSupportForMvc()
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the parse options applied when using <see cref="AddCSharpSyntaxTree(string, string)"/>.
|
/// Gets the parse options applied when using <see cref="AddCSharpSyntaxTree(string, string)"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual CSharpParseOptions CSharpParseOptions { get; } = new CSharpParseOptions(LanguageVersion.Latest);
|
protected virtual CSharpParseOptions CSharpParseOptions { get; } = new CSharpParseOptions(LanguageVersion.Preview);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the compilation options applied when compiling assemblies.
|
/// Gets the compilation options applied when compiling assemblies.
|
||||||
|
|
@ -323,6 +323,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Features.Add(new DefaultTypeNameFeature());
|
b.Features.Add(new DefaultTypeNameFeature());
|
||||||
|
b.SetCSharpLanguageVersion(CSharpParseOptions.LanguageVersion);
|
||||||
|
|
||||||
// Decorate each import feature so we can normalize line endings.
|
// Decorate each import feature so we can normalize line endings.
|
||||||
foreach (var feature in b.Features.OfType<IImportProjectFeature>().ToArray())
|
foreach (var feature in b.Features.OfType<IImportProjectFeature>().ToArray())
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
||||||
referenceAssemblies,
|
referenceAssemblies,
|
||||||
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
|
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
|
||||||
|
|
||||||
CSharpParseOptions = new CSharpParseOptions(LanguageVersion.CSharp7_3);
|
CSharpParseOptions = new CSharpParseOptions(LanguageVersion.Preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RazorIntegrationTestBase()
|
public RazorIntegrationTestBase()
|
||||||
|
|
@ -129,6 +129,8 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
||||||
References = references,
|
References = references,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
b.SetCSharpLanguageVersion(CSharpParseOptions.LanguageVersion);
|
||||||
|
|
||||||
CompilerFeatures.Register(b);
|
CompilerFeatures.Register(b);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue