Skip to content

Commit a12bb71

Browse files
committed
Drop the null forgiving operator from generated TestContext getter
The generated getter used CurrentTestContext.Value!.TestContext. A consuming SDK-style project targeting net462, net472 or net48 defaults to LangVersion 7.3, where ! is CS8370, so UsesVerify.g.cs failed to compile for exactly the target frameworks Verify.MSTest ships. The repo never saw it because ProjectDefaults forces LangVersion=preview. The generated file carries an <auto-generated /> header, so nullable warnings are suppressed there regardless.
1 parent d731cfb commit a12bb71

16 files changed

Lines changed: 21 additions & 18 deletions

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasAssemblyAttribute.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasAssemblyAttributeAndCustomTestClassAttribute.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasAttributeOnClass.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/GlobalNamespaceTests.HasBothAssemblyAndClassAttributes.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Foo
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAssemblyAttributeAndTestClassInheritance.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Base
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAssemblyAttributeWithTestClassOnDerivedAndMarkerAttributeOnBase.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Base
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAttributeOnBaseAndDerivedClasses.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Base
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAttributeOnBaseClass.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Base
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAttributeOnDerivedClass.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Derived
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

src/Verify.MSTest.SourceGenerator.Tests/InheritanceTests.HasAttributeOnDerivedClassAndAbstractPropertyManuallyDefinedInBase.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class Derived
1414
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
1515
public sealed override global::Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
1616
{
17-
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value!.TestContext;
17+
get => global::VerifyMSTest.Verifier.CurrentTestContext.Value.TestContext;
1818
set => global::VerifyMSTest.Verifier.CurrentTestContext.Value = new global::VerifyMSTest.TestExecutionContext(value, GetType());
1919
}
2020
}

0 commit comments

Comments
 (0)