Skip to content

Commit 761f87c

Browse files
committed
Add '[MaybeNull]' analyzer test
1 parent 6d8f6e2 commit 761f87c

File tree

1 file changed

+23
-0
lines changed
  • components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.Tests

1 file changed

+23
-0
lines changed

components/DependencyPropertyGenerator/CommunityToolkit.DependencyPropertyGenerator.Tests/Test_Analyzers.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,29 @@ public partial class MyControl : Control
741741
await CSharpAnalyzerTest<InvalidPropertyNonNullableDeclarationAnalyzer>.VerifyAnalyzerAsync(source, LanguageVersion.CSharp13);
742742
}
743743

744+
[TestMethod]
745+
public async Task InvalidPropertyNonNullableDeclarationAnalyzer_NotNullableType_WithMaybeNull_DoesNotWarn()
746+
{
747+
const string source = """
748+
using System.Diagnostics.CodeAnalysis;
749+
using CommunityToolkit.WinUI;
750+
using Windows.UI.Xaml.Controls;
751+
752+
#nullable enable
753+
754+
namespace MyApp;
755+
756+
public partial class MyControl : Control
757+
{
758+
[GeneratedDependencyProperty]
759+
[MaybeNull]
760+
public partial string {|CS9248:Name|} { get; set; }
761+
}
762+
""";
763+
764+
await CSharpAnalyzerTest<InvalidPropertyNonNullableDeclarationAnalyzer>.VerifyAnalyzerAsync(source, LanguageVersion.CSharp13);
765+
}
766+
744767
[TestMethod]
745768
public async Task InvalidPropertyNonNullableDeclarationAnalyzer_NotNullableType_Warns()
746769
{

0 commit comments

Comments
 (0)