Skip to content

Commit

Permalink
Fix the #nullable annotation (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
omsmith authored Apr 25, 2024
1 parent e744f53 commit 7802940
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public string CollectSource() {
m_out.AppendLine( "#pragma warning disable CS1572" );
// This allows us to copy+paste annotations but otherwise does not emit diagnostics
// otherwise we get "CS8669: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source."
m_out.AppendLine( "#nullable annotations" );
m_out.AppendLine( "#nullable enable annotations" );
// File-scoped usings:
m_out.Append( m_root.Usings.ToFullString() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void SomeMethod() {}
);

Assert.AreEqual( @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
", collector.CollectSource() );
}

Expand Down Expand Up @@ -53,7 +53,7 @@ void MyMethodBefore() {
);

Assert.AreEqual( @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using Foo;
Expand Down Expand Up @@ -91,7 +91,7 @@ void MyMethodBefore() {
);

Assert.AreEqual( @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using Foo;
Expand Down Expand Up @@ -127,7 +127,7 @@ void MyMethodBefore() {{
);

Assert.AreEqual( @$"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
partial {kind} X {{
any text
Expand Down Expand Up @@ -167,7 +167,7 @@ class Ignored2 {}
);

Assert.AreEqual( @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using Foo;
Expand Down Expand Up @@ -249,7 +249,7 @@ void MyBeforeMethod4() { }
);

Assert.AreEqual( @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using Foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sealed class Bar {
);

AssertNewTrees( result, @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using System;
using System.IO;
Expand Down Expand Up @@ -92,7 +92,7 @@ partial interface IFoo {
);

AssertNewTrees( result, @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -142,7 +142,7 @@ public async Task BarAsync() {}
);

AssertNewTrees( result, @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using System;
using System.IO;
Expand All @@ -156,7 +156,7 @@ partial class Bar {
[Blocking]
public void Baz( StreamWriter x ) { return; }
}", @"#pragma warning disable CS1572
#nullable annotations
#nullable enable annotations
using System;
using System.IO;
Expand Down

0 comments on commit 7802940

Please sign in to comment.