Skip to content

Commit

Permalink
Add unit test for updated diagnostic suppressor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Sep 18, 2024
1 parent c7e454a commit 8404e3a
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1797,4 +1797,30 @@ private sealed partial class ModelWithDependentPropertyAndNoPropertyChanging

public string? FullName => "";
}

#if NET6_0_OR_GREATER
// See https://github.com/CommunityToolkit/dotnet/issues/939
public partial class ModelWithSecondaryPropertySetFromGeneratedSetter_DoesNotWarn : ObservableObject
{
[ObservableProperty]
[set: MemberNotNull(nameof(B))]
private string a;

// This type validates forwarding attributes on generated accessors. In particular, there should
// be no nullability warning on this constructor (CS8618), thanks to 'MemberNotNullAttribute("B")'
// being forwarded to the generated setter in the generated property (see linked issue).
public ModelWithSecondaryPropertySetFromGeneratedSetter_DoesNotWarn()
{
A = "";
}

public string B { get; private set; }

[MemberNotNull(nameof(B))]
partial void OnAChanged(string? oldValue, string newValue)
{
B = "";
}
}
#endif
}

0 comments on commit 8404e3a

Please sign in to comment.