@@ -309,6 +309,80 @@ public class PropertyTester
309309}" ;
310310
311311
312+
313+ /// <summary>
314+ /// The public property test code.
315+ /// </summary>
316+ private const string PublicPropertyInterfaceTestCode = @"
317+ using System;
318+ using System.Collections.Generic;
319+ using System.Text;
320+
321+ namespace ConsoleApp4
322+ {
323+ public interface PropertyTester
324+ {
325+ public string PersonName => ""Person Name"";
326+ }
327+ }" ;
328+
329+ /// <summary>
330+ /// The public property test fix code.
331+ /// </summary>
332+ private const string PublicPropertyInterfaceTestFixCode = @"
333+ using System;
334+ using System.Collections.Generic;
335+ using System.Text;
336+
337+ namespace ConsoleApp4
338+ {
339+ public interface PropertyTester
340+ {
341+ /// <summary>
342+ /// Gets the person name.
343+ /// </summary>
344+ public string PersonName => ""Person Name"";
345+ }
346+ }" ;
347+
348+
349+
350+
351+ /// <summary>
352+ /// The public property test code.
353+ /// </summary>
354+ private const string PrivatePropertyInterfaceTestCode = @"
355+ using System;
356+ using System.Collections.Generic;
357+ using System.Text;
358+
359+ namespace ConsoleApp4
360+ {
361+ public interface PropertyTester
362+ {
363+ string PersonName => ""Person Name"";
364+ }
365+ }" ;
366+
367+ /// <summary>
368+ /// The public property test fix code.
369+ /// </summary>
370+ private const string PrivatePropertyInterfaceTestFixCode = @"
371+ using System;
372+ using System.Collections.Generic;
373+ using System.Text;
374+
375+ namespace ConsoleApp4
376+ {
377+ public interface PropertyTester
378+ {
379+ /// <summary>
380+ /// Gets the person name.
381+ /// </summary>
382+ string PersonName => ""Person Name"";
383+ }
384+ }" ;
385+
312386 }
313387 /// <summary>
314388 /// The property unit test.
@@ -344,15 +418,17 @@ public void NoDiagnosticsShow(string testCode)
344418 /// <param name="line">The line.</param>
345419 /// <param name="column">The column.</param>
346420 [ Theory ]
347- [ InlineData ( PropertyWithGetterSetterTestCode , PropertyWithGetterSetterTestFixCode , 10 , 17 ) ]
348- [ InlineData ( PropertyOnlyGetterTestCode , PropertyOnlyGetterTestFixCode , 10 , 17 ) ]
349- [ InlineData ( PropertyPrivateGetterTestCode , PropertyPrivateGetterTestFixCode , 10 , 23 ) ]
350- [ InlineData ( PropertyInternalGetterTestCode , PropertyInternalGetterTestFixCode , 10 , 23 ) ]
351- [ InlineData ( BooleanPropertyTestCode , BooleanPropertyTestFixCode , 10 , 15 ) ]
352- [ InlineData ( NullableBooleanPropertyTestCode , NullableBooleanPropertyTestFixCode , 10 , 16 ) ]
353- [ InlineData ( ExpressionBodyPropertyTestCode , ExpressionBodyPropertyTestFixCode , 10 , 17 ) ]
354- [ InlineData ( NullableDateTimePropertyTestCode , NullableDateTimePropertyTestFixCode , 10 , 20 ) ]
355- public void ShowDiagnosticAndFix ( string testCode , string fixCode , int line , int column )
421+ [ InlineData ( PropertyWithGetterSetterTestCode , PropertyWithGetterSetterTestFixCode , 10 , 17 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
422+ [ InlineData ( PropertyOnlyGetterTestCode , PropertyOnlyGetterTestFixCode , 10 , 17 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
423+ [ InlineData ( PropertyPrivateGetterTestCode , PropertyPrivateGetterTestFixCode , 10 , 23 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
424+ [ InlineData ( PropertyInternalGetterTestCode , PropertyInternalGetterTestFixCode , 10 , 23 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
425+ [ InlineData ( BooleanPropertyTestCode , BooleanPropertyTestFixCode , 10 , 15 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
426+ [ InlineData ( NullableBooleanPropertyTestCode , NullableBooleanPropertyTestFixCode , 10 , 16 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
427+ [ InlineData ( ExpressionBodyPropertyTestCode , ExpressionBodyPropertyTestFixCode , 10 , 17 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
428+ [ InlineData ( NullableDateTimePropertyTestCode , NullableDateTimePropertyTestFixCode , 10 , 20 , TestFixure . DIAG_TYPE_PUBLIC_ONLY ) ]
429+ [ InlineData ( PublicPropertyInterfaceTestCode , PublicPropertyInterfaceTestFixCode , 10 , 17 , TestFixure . DIAG_TYPE_PUBLIC ) ]
430+ [ InlineData ( PrivatePropertyInterfaceTestCode , PrivatePropertyInterfaceTestFixCode , 10 , 10 , TestFixure . DIAG_TYPE_PRIVATE ) ]
431+ public void ShowDiagnosticAndFix ( string testCode , string fixCode , int line , int column , string diagType )
356432 {
357433 var expected = new DiagnosticResult
358434 {
@@ -365,9 +441,9 @@ public void ShowDiagnosticAndFix(string testCode, string fixCode, int line, int
365441 }
366442 } ;
367443
368- this . VerifyCSharpDiagnostic ( testCode , TestFixure . DIAG_TYPE_PUBLIC , expected ) ;
444+ this . VerifyCSharpDiagnostic ( testCode , diagType , expected ) ;
369445
370- this . VerifyCSharpFix ( testCode , fixCode , TestFixure . DIAG_TYPE_PUBLIC ) ;
446+ this . VerifyCSharpFix ( testCode , fixCode , diagType ) ;
371447 }
372448
373449 /// <summary>
@@ -385,12 +461,15 @@ protected override CodeFixProvider GetCSharpCodeFixProvider()
385461 /// <returns>A DiagnosticAnalyzer.</returns>
386462 protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer ( string diagType )
387463 {
388- if ( diagType == "private" )
464+ if ( diagType == TestFixure . DIAG_TYPE_PRIVATE )
389465 {
390466 CodeDocumentorPackage . Options . IsEnabledForPublishMembersOnly = false ;
391467 return new NonPublicPropertyAnalyzer ( ) ;
392468 }
393- CodeDocumentorPackage . Options . IsEnabledForPublishMembersOnly = true ;
469+ if ( diagType == TestFixure . DIAG_TYPE_PUBLIC_ONLY )
470+ {
471+ CodeDocumentorPackage . Options . IsEnabledForPublishMembersOnly = true ;
472+ }
394473 return new PropertyAnalyzer ( ) ;
395474 }
396475 }
0 commit comments