Skip to content

Commit 8404e3a

Browse files
committed
Add unit test for updated diagnostic suppressor
1 parent c7e454a commit 8404e3a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/CommunityToolkit.Mvvm.UnitTests/Test_ObservablePropertyAttribute.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,4 +1797,30 @@ private sealed partial class ModelWithDependentPropertyAndNoPropertyChanging
17971797

17981798
public string? FullName => "";
17991799
}
1800+
1801+
#if NET6_0_OR_GREATER
1802+
// See https://github.com/CommunityToolkit/dotnet/issues/939
1803+
public partial class ModelWithSecondaryPropertySetFromGeneratedSetter_DoesNotWarn : ObservableObject
1804+
{
1805+
[ObservableProperty]
1806+
[set: MemberNotNull(nameof(B))]
1807+
private string a;
1808+
1809+
// This type validates forwarding attributes on generated accessors. In particular, there should
1810+
// be no nullability warning on this constructor (CS8618), thanks to 'MemberNotNullAttribute("B")'
1811+
// being forwarded to the generated setter in the generated property (see linked issue).
1812+
public ModelWithSecondaryPropertySetFromGeneratedSetter_DoesNotWarn()
1813+
{
1814+
A = "";
1815+
}
1816+
1817+
public string B { get; private set; }
1818+
1819+
[MemberNotNull(nameof(B))]
1820+
partial void OnAChanged(string? oldValue, string newValue)
1821+
{
1822+
B = "";
1823+
}
1824+
}
1825+
#endif
18001826
}

0 commit comments

Comments
 (0)