File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
CSharp/Tests/UseAutoProperty
Core/CodeFixes/UseAutoProperty Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -3233,7 +3233,7 @@ public Test()
32333233 """
32343234 public sealed class Test
32353235 {
3236- public static Test Instance { get; private set; }
3236+ public static Test Instance { get => field! ; private set; }
32373237
32383238 public Test()
32393239 {
@@ -3260,7 +3260,7 @@ static Test()
32603260 """
32613261 public sealed class Test
32623262 {
3263- public static Test Instance { get; } = new Test() ;
3263+ public static Test Instance => field! ;
32643264 }
32653265 """ ) ;
32663266
@@ -3286,7 +3286,11 @@ public Test()
32863286 """
32873287 public sealed class Test
32883288 {
3289- public static Test Instance { get; set; }
3289+ public static Test Instance
3290+ {
3291+ get => field!;
3292+ set;
3293+ }
32903294
32913295 public Test()
32923296 {
Original file line number Diff line number Diff line change @@ -484,12 +484,12 @@ private async Task<SyntaxNode> FormatAsync(
484484 CancellationToken cancellationToken )
485485 {
486486 var isWrittenOutsideConstructor = false ;
487- // Only include constructors that match the static-ness of the field.
488- // For a static field, only static constructors are relevant.
489- // For an instance field, only instance constructors are relevant.
487+
488+ // Only include constructors that match the static-ness of the field. For a static field, only static
489+ // constructors are relevant. For an instance field, only instance constructors are relevant.
490490 var constructorSpans = field . ContainingType
491491 . GetMembers ( )
492- . Where ( m => m . IsConstructor ( ) && m . IsStatic == field . IsStatic )
492+ . Where ( m => field . IsStatic ? m . IsStaticConstructor ( ) : m . IsConstructor ( ) )
493493 . SelectMany ( c => c . DeclaringSyntaxReferences )
494494 . Select ( s => s . GetSyntax ( cancellationToken ) )
495495 . Select ( n => n . FirstAncestorOrSelf < TConstructorDeclaration > ( ) )
You can’t perform that action at this time.
0 commit comments