From 0a8d27b2071d0773a52b17b862da6e6d042ed9ac Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 4 Feb 2021 13:21:43 -0600 Subject: [PATCH 1/2] Add nullablePublicOnly Roslyn Feature This tells Roslyn to not add [AllowNull] attributes in IL to non-public APIs. The same feature is set for dotnet/runtime. --- eng/targets/CSharp.Common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/targets/CSharp.Common.props b/eng/targets/CSharp.Common.props index bddce450d74d..75bbfcc7743c 100644 --- a/eng/targets/CSharp.Common.props +++ b/eng/targets/CSharp.Common.props @@ -4,7 +4,7 @@ 9.0 - strict + strict;nullablePublicOnly From 28c70138b2573e84a626eeee684f9f49cd09b527 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Fri, 5 Feb 2021 10:20:23 -0600 Subject: [PATCH 2/2] Fix tests that rely on nullability to be preserved on non-public types. --- .../test/Microsoft.AspNetCore.Mvc.DataAnnotations.Test.csproj | 2 ++ .../Microsoft.AspNetCore.Mvc.IntegrationTests.csproj | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Mvc/Mvc.DataAnnotations/test/Microsoft.AspNetCore.Mvc.DataAnnotations.Test.csproj b/src/Mvc/Mvc.DataAnnotations/test/Microsoft.AspNetCore.Mvc.DataAnnotations.Test.csproj index 1372cf33ea00..b77a56dc7b43 100644 --- a/src/Mvc/Mvc.DataAnnotations/test/Microsoft.AspNetCore.Mvc.DataAnnotations.Test.csproj +++ b/src/Mvc/Mvc.DataAnnotations/test/Microsoft.AspNetCore.Mvc.DataAnnotations.Test.csproj @@ -3,6 +3,8 @@ $(DefaultNetCoreTargetFramework) false + + $(Features.Replace('nullablePublicOnly', '')) diff --git a/src/Mvc/test/Mvc.IntegrationTests/Microsoft.AspNetCore.Mvc.IntegrationTests.csproj b/src/Mvc/test/Mvc.IntegrationTests/Microsoft.AspNetCore.Mvc.IntegrationTests.csproj index 219c48691150..2645610a14bb 100644 --- a/src/Mvc/test/Mvc.IntegrationTests/Microsoft.AspNetCore.Mvc.IntegrationTests.csproj +++ b/src/Mvc/test/Mvc.IntegrationTests/Microsoft.AspNetCore.Mvc.IntegrationTests.csproj @@ -3,6 +3,8 @@ $(DefaultNetCoreTargetFramework) false + + $(Features.Replace('nullablePublicOnly', ''))