Skip to content

Commit 518c041

Browse files
authored
Enable nullable reference types by default (#7130)
* Enable nullable reference types by default This turns C# 9's nullable reference types on by default for all projects in the solution, and opts out unannotated files by adding `#nullable disable` to them. This has two nice properties: 1. New code will be written with nullability in mind as the feature will be on by default. 2. It's easy to find unannotated code by searching for `#nullable disable`. We have taken this approach in the .NET Project System and in CPS, and it's worked very well for us. Code under `Deprecated` is unchanged.
1 parent bba8036 commit 518c041

File tree

1,429 files changed

+2833
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,429 files changed

+2833
-38
lines changed

src/Build.OM.UnitTests/AssemblyResources.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
using System;
55

6+
#nullable disable
7+
68
namespace Microsoft.Build.Shared
79
{
810
/// <summary>

src/Build.OM.UnitTests/Construction/ConstructionEditing_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
1616
using Xunit;
1717

18+
#nullable disable
19+
1820
namespace Microsoft.Build.UnitTests.OM.Construction
1921
{
2022
/// <summary>

src/Build.OM.UnitTests/Construction/ElementLocationPublic_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using Xunit;
99
using Shouldly;
1010

11+
#nullable disable
12+
1113
namespace Microsoft.Build.UnitTests.Construction
1214
{
1315
/// <summary>

src/Build.OM.UnitTests/Construction/ProjectChooseElement_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
1414
using Xunit;
1515

16+
#nullable disable
17+
1618
namespace Microsoft.Build.UnitTests.OM.Construction
1719
{
1820
/// <summary>

src/Build.OM.UnitTests/Construction/ProjectExtensionsElement_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
1010
using Xunit;
1111

12+
#nullable disable
13+
1214
namespace Microsoft.Build.UnitTests.OM.Construction
1315
{
1416
/// <summary>

src/Build.OM.UnitTests/Construction/ProjectFormatting_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using Xunit;
1212
using Xunit.Abstractions;
1313

14+
#nullable disable
15+
1416
namespace Microsoft.Build.Engine.OM.UnitTests.Construction
1517
{
1618
public class ProjectFormatting_Tests : IDisposable

src/Build.OM.UnitTests/Construction/ProjectImportElement_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
1414
using Xunit;
1515

16+
#nullable disable
17+
1618
namespace Microsoft.Build.UnitTests.OM.Construction
1719
{
1820
/// <summary>

src/Build.OM.UnitTests/Construction/ProjectImportGroupElement_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
1111
using Xunit;
1212

13+
#nullable disable
14+
1315
namespace Microsoft.Build.UnitTests.OM.Construction
1416
{
1517
/// <summary>

src/Build.OM.UnitTests/Construction/ProjectItemDefinitionElement_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using Microsoft.Build.Exceptions;
99
using Xunit;
1010

11+
#nullable disable
12+
1113
namespace Microsoft.Build.UnitTests.OM.Construction
1214
{
1315
/// <summary>

src/Build.OM.UnitTests/Construction/ProjectItemDefinitionGroupElement_Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
1010
using Xunit;
1111

12+
#nullable disable
13+
1214
namespace Microsoft.Build.UnitTests.OM.Construction
1315
{
1416
/// <summary>

0 commit comments

Comments
 (0)