未验证 提交 f0b48aa7 编写于 作者: J Julien Couvreur 提交者: GitHub

Add NullableReferenceTypes msbuild property (#30574)

上级 7172fa8c
......@@ -143,6 +143,12 @@ public string WarningsNotAsErrors
get { return (string)_store[nameof(WarningsNotAsErrors)]; }
}
public bool NullableReferenceTypes
{
set { _store[nameof(NullableReferenceTypes)] = value; }
get { return (bool)_store[nameof(NullableReferenceTypes)]; }
}
#endregion
#region Tool Members
......@@ -198,6 +204,7 @@ protected internal override void AddResponseFileCommands(CommandLineBuilderExten
commandLine.AppendWhenTrue("/errorendlocation", _store, nameof(ErrorEndLocation));
commandLine.AppendSwitchIfNotNull("/preferreduilang:", PreferredUILang);
commandLine.AppendPlusOrMinusSwitch("/highentropyva", _store, nameof(HighEntropyVA));
commandLine.AppendPlusOrMinusSwitch("/nullable", _store, nameof(NullableReferenceTypes));
// If not design time build and the globalSessionGuid property was set then add a -globalsessionguid:<guid>
bool designTime = false;
......
......@@ -88,6 +88,7 @@
NoLogo="$(NoLogo)"
NoStandardLib="$(NoCompilerStandardLib)"
NoWin32Manifest="$(NoWin32Manifest)"
NullableReferenceTypes="$(NullableReferenceTypes)"
Optimize="$(Optimize)"
Deterministic="$(Deterministic)"
PublicSign="$(PublicSign)"
......
......@@ -332,6 +332,24 @@ public void RefOnly()
Assert.Equal("/out:test.exe /refonly test.cs", csc.GenerateResponseFileContents());
}
[Fact]
public void NullableReferenceTypes_True()
{
var csc = new Csc();
csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
csc.NullableReferenceTypes = true;
Assert.Equal("/nullable+ /out:test.exe test.cs", csc.GenerateResponseFileContents());
}
[Fact]
public void NullableReferenceTypes_False()
{
var csc = new Csc();
csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
csc.NullableReferenceTypes = false;
Assert.Equal("/nullable- /out:test.exe test.cs", csc.GenerateResponseFileContents());
}
[Fact]
public void SharedCompilationId()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册