@@ -29,6 +29,8 @@ public void Bar(int i)
2929 }
3030}" ;
3131
32+ private const string WhiteSpace = "\t " ;
33+
3234 /// <summary>
3335 /// Verifies that blank lines at the end of the file will produce a warning.
3436 /// </summary>
@@ -49,6 +51,60 @@ internal async Task TestWithBlankLinesAtEndOfFileAsync(OptionSetting? newlineAtE
4951 await VerifyCSharpFixAsync ( newlineAtEndOfFile , testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
5052 }
5153
54+ /// <summary>
55+ /// Verifies file with white space only and no cr/lf at end of file will produce a warning when setting requires.
56+ /// </summary>
57+ /// <param name="newlineAtEndOfFile">The effective <see cref="OptionSetting"/> setting.</param>
58+ /// <param name="expectedText">The expected text to appear at the end of the file.</param>
59+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
60+ [ Theory ]
61+ [ InlineData ( null , null ) ]
62+ [ InlineData ( OptionSetting . Allow , null ) ]
63+ [ InlineData ( OptionSetting . Require , "\r \n " ) ]
64+ [ InlineData ( OptionSetting . Omit , null ) ]
65+ internal async Task TestWithWhiteSpaceOnlyAsync ( OptionSetting ? newlineAtEndOfFile , string expectedText )
66+ {
67+ var testCode = WhiteSpace ;
68+ var fixedCode = expectedText ;
69+
70+ if ( expectedText == null )
71+ {
72+ await VerifyCSharpDiagnosticAsync ( newlineAtEndOfFile , testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
73+ }
74+ else
75+ {
76+ var expected = Diagnostic ( this . GetDescriptor ( newlineAtEndOfFile ) ) . WithLocation ( 1 , 1 ) ;
77+ await VerifyCSharpFixAsync ( newlineAtEndOfFile , testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
78+ }
79+ }
80+
81+ /// <summary>
82+ /// Verifies file with white space only and cr/lf at end of file will produce a warning when setting requires.
83+ /// </summary>
84+ /// <param name="newlineAtEndOfFile">The effective <see cref="OptionSetting"/> setting.</param>
85+ /// <param name="expectedText">The expected text to appear at the end of the file.</param>
86+ /// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
87+ [ Theory ]
88+ [ InlineData ( null , null ) ]
89+ [ InlineData ( OptionSetting . Allow , null ) ]
90+ [ InlineData ( OptionSetting . Require , null ) ]
91+ [ InlineData ( OptionSetting . Omit , "" ) ]
92+ internal async Task TestWithWhiteSpaceAndNewlineOnlyAsync ( OptionSetting ? newlineAtEndOfFile , string expectedText )
93+ {
94+ var testCode = WhiteSpace + "\r \n " ;
95+ var fixedCode = expectedText ;
96+
97+ if ( expectedText == null )
98+ {
99+ await VerifyCSharpDiagnosticAsync ( newlineAtEndOfFile , testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
100+ }
101+ else
102+ {
103+ var expected = Diagnostic ( this . GetDescriptor ( newlineAtEndOfFile ) ) . WithLocation ( 1 , 1 ) ;
104+ await VerifyCSharpFixAsync ( newlineAtEndOfFile , testCode , expected , fixedCode , CancellationToken . None ) . ConfigureAwait ( false ) ;
105+ }
106+ }
107+
52108 /// <summary>
53109 /// Verifies that empty files will not produce a warning.
54110 /// </summary>
0 commit comments