Skip to content

Commit

Permalink
Merge pull request #35753 from dotnet/merges/release/dev16.2-preview1…
Browse files Browse the repository at this point in the history
…-to-release/dev16.2-preview1-vs-deps

Merge release/dev16.2-preview1 to release/dev16.2-preview1-vs-deps
  • Loading branch information
dotnet-automerge-bot authored May 16, 2019
2 parents 535127a + c4bb38d commit 04c76c9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Compilers/Core/MSBuildTask/Csc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,30 @@ public string WarningsNotAsErrors

public string Nullable
{
set { _store[nameof(Nullable)] = value; }
set
{
// We merge values into Nullable, prioritizing Nullable value over NullableContextOptions value
if (!string.IsNullOrEmpty(value))
{
_store[nameof(Nullable)] = value;
}
}
get { return (string)_store[nameof(Nullable)]; }
}

public string NullableContextOptions
{
set
{
// We merge values into Nullable, prioritizing Nullable value over NullableContextOptions value
if (string.IsNullOrEmpty(Nullable))
{
Nullable = value;
}
}
get { return Nullable; }
}

#endregion

#region Tool Members
Expand Down
32 changes: 32 additions & 0 deletions src/Compilers/Core/MSBuildTaskTests/CscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,38 @@ public void NullableReferenceTypes_Disabled()
Assert.Equal("/nullable:disable /out:test.exe test.cs", csc.GenerateResponseFileContents());
}

[Theory]
[InlineData(null, "disable")]
[InlineData("", "disable")]
[InlineData("enable", "disable")]
[InlineData("other", "disable")]
[InlineData("disable", null)]
[InlineData("disable", "")]
public void NullableReferenceTypes_NullableWins_Disable(string nullableContextOptions, string nullable)
{
var csc = new Csc();
csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
csc.NullableContextOptions = nullableContextOptions;
csc.Nullable = nullable;
Assert.Equal("/nullable:disable /out:test.exe test.cs", csc.GenerateResponseFileContents());
}

[Theory]
[InlineData(null, "enable")]
[InlineData("", "enable")]
[InlineData("disable", "enable")]
[InlineData("other", "enable")]
[InlineData("enable", null)]
[InlineData("enable", "")]
public void NullableReferenceTypes_NullableWins_Enable(string nullableContextOptions, string nullable)
{
var csc = new Csc();
csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
csc.NullableContextOptions = nullableContextOptions;
csc.Nullable = nullable;
Assert.Equal("/nullable:enable /out:test.exe test.cs", csc.GenerateResponseFileContents());
}

[Fact]
public void NullableReferenceTypes_Safeonly()
{
Expand Down

0 comments on commit 04c76c9

Please sign in to comment.