File tree Expand file tree Collapse file tree
WpfAnalyzers.Test/WPF0041SetMutableUsingSetCurrentValueTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace ValidCode . Issues ;
2+
3+ using System . Windows ;
4+
5+ public class Issue376 : FrameworkElement
6+ {
7+ private static readonly DependencyProperty TextProperty = DependencyProperty . Register (
8+ nameof ( Text ) ,
9+ typeof ( string ) ,
10+ typeof ( Issue376 ) ,
11+ new PropertyMetadata ( default ( string ) ) ) ;
12+
13+ private string ? Text
14+ {
15+ get => ( string ? ) this . GetValue ( TextProperty ) ;
16+ set => this . SetValue ( TextProperty , value ) ;
17+ }
18+
19+ public void M ( string text )
20+ {
21+ this . Text = text ;
22+ }
23+ }
Original file line number Diff line number Diff line change @@ -776,4 +776,36 @@ public bool IsTrue
776776
777777 RoslynAssert . Valid ( Analyzer , boxes , code ) ;
778778 }
779+
780+ [ Test ]
781+ public static void WhenPrivate ( )
782+ {
783+ var code = @"
784+ namespace ValidCode.Issues;
785+
786+ using System.Windows;
787+
788+ public class Issue376 : FrameworkElement
789+ {
790+ private static readonly DependencyProperty TextProperty = DependencyProperty.Register(
791+ nameof(Text),
792+ typeof(string),
793+ typeof(Issue376),
794+ new PropertyMetadata(default(string)));
795+
796+ private string? Text
797+ {
798+ get => (string?)this.GetValue(TextProperty);
799+ set => this.SetValue(TextProperty, value);
800+ }
801+
802+ public void M(string text)
803+ {
804+ this.Text = text;
805+ }
806+ }
807+ " ;
808+
809+ RoslynAssert . Valid ( Analyzer , code ) ;
810+ }
779811}
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ private static void HandleAssignment(SyntaxNodeAnalysisContext context)
4949 static bool IsIgnored ( IPropertySymbol property )
5050 {
5151 return property == KnownSymbols . FrameworkElement . DataContext ||
52- property == KnownSymbols . FrameworkElement . Style ;
52+ property == KnownSymbols . FrameworkElement . Style ||
53+ property . DeclaredAccessibility == Accessibility . Private ;
5354 }
5455 }
5556
You can’t perform that action at this time.
0 commit comments