Skip to content

Commit

Permalink
Add NullableReferenceTypes msbuild property (#30574)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv authored Oct 18, 2018
1 parent 7172fa8 commit f0b48aa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Compilers/Core/MSBuildTask/Csc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
NoLogo="$(NoLogo)"
NoStandardLib="$(NoCompilerStandardLib)"
NoWin32Manifest="$(NoWin32Manifest)"
NullableReferenceTypes="$(NullableReferenceTypes)"
Optimize="$(Optimize)"
Deterministic="$(Deterministic)"
PublicSign="$(PublicSign)"
Expand Down
18 changes: 18 additions & 0 deletions src/Compilers/Core/MSBuildTaskTests/CscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit f0b48aa

Please sign in to comment.