/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/EditorFeatures/Test2/Simplification/NullableAnnotationSimplificationTests.vb
197 строк
3 KB
Cyrus Najmabadi
Organize VB imports
27 июн 2025, 21:53
27 июн 2025, 21:53
e9c47fd
Код
Авторство
О чём код?
' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Simplification <Trait(Traits.Feature, Traits.Features.Simplification)> Public Class NullableAnnotationSimplificationTests Inherits AbstractSimplificationTests #Region "CSharp tests" <Fact> Public Async Function TestCSharpLeaveAnnotationIfValidAndEnabled() As Task Dim input = <Workspace> <Project Language="C#" CommonReferences="true"> <Document> #nullable enable class C { void M() { {|SimplifyParent:string?|} x; } } </Document> </Project> </Workspace> Dim expected = <code> #nullable enable class C { void M() { string? x; } } </code> Await TestAsync(input, expected) End Function <Fact> Public Async Function TestCSharpRemoveAnnotationIfDisabled() As Task Dim input = <Workspace> <Project Language="C#" CommonReferences="true"> <Document> #nullable disable class C { void M() { {|SimplifyParent:string?|} x; } } </Document> </Project> </Workspace> Dim expected = <code> #nullable disable class C { void M() { string x; } } </code> Await TestAsync(input, expected) End Function <Fact> Public Async Function TestCSharpRemoveAnnotationLeavesTrivia() As Task Dim input = <Workspace> <Project Language="C#" CommonReferences="true"> <Document> #nullable disable class C { void M() { {|SimplifyParent:/*before*/string/*inner*/?/*after*/|} x; } } </Document> </Project> </Workspace> Dim expected = <code> #nullable disable class C { void M() { /*before*/string/*inner*//*after*/ x; } } </code> Await TestAsync(input, expected) End Function <Fact> Public Async Function TestCSharpLeaveAnnotationIfStructType() As Task Dim input = <Workspace> <Project Language="C#" CommonReferences="true"> <Document> #nullable disable class C { void M() { {|SimplifyParent:int?|} x; } } </Document> </Project> </Workspace> Dim expected = <code> #nullable disable class C { void M() { int? x; } } </code> Await TestAsync(input, expected) End Function <Fact> Public Async Function TestCSharpLeaveAnnotationIfUnconstrainedGeneric() As Task ' Putting a ? on a unconstrained generic is illegal, but for now we're going to be cautious and not remove any ?s on unconstrained generics. ' If we need extra smarts to clean these up it's not hard, but there's no reason to do it until we have a reason. Dim input = <Workspace> <Project Language="C#" CommonReferences="true"> <Document> #nullable disable class C { void M<T>() { {|SimplifyParent:T?|} x; } } </Document> </Project> </Workspace> Dim expected = <code> #nullable disable class C { void M<T>() { T? x; } } </code> Await TestAsync(input, expected) End Function #End Region End Class End Namespace