@@ -22,41 +22,38 @@ namespace StyleCop.Analyzers.LayoutRules
2222 /// <para>A violation of this rule occurs when one or more blank lines are at the end of the file.</para>
2323 /// </remarks>
2424 [ DiagnosticAnalyzer ( LanguageNames . CSharp ) ]
25- internal class SA1518CodeMustNotContainBlankLinesAtEndOfFile : DiagnosticAnalyzer
25+ internal class SA1518UseLineEndingsCorrectlyAtEndOfFile : DiagnosticAnalyzer
2626 {
2727 /// <summary>
28- /// The ID for diagnostics produced by the <see cref="SA1518CodeMustNotContainBlankLinesAtEndOfFile "/> analyzer.
28+ /// The ID for diagnostics produced by the <see cref="SA1518UseLineEndingsCorrectlyAtEndOfFile "/> analyzer.
2929 /// </summary>
3030 public const string DiagnosticId = "SA1518" ;
31+ private static readonly LocalizableString Title = new LocalizableResourceString ( nameof ( LayoutResources . SA1518Title ) , LayoutResources . ResourceManager , typeof ( LayoutResources ) ) ;
3132
32- internal static readonly DiagnosticDescriptor DescriptorForAllowSetting =
33- new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormatForAllowSetting , AnalyzerCategory . LayoutRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , DescriptionForAllowSetting , HelpLink ) ;
33+ private static readonly LocalizableString MessageFormatAllow = new LocalizableResourceString ( nameof ( LayoutResources . SA1518MessageFormatAllow ) , LayoutResources . ResourceManager , typeof ( LayoutResources ) ) ;
34+ private static readonly LocalizableString DescriptionAllow = new LocalizableResourceString ( nameof ( LayoutResources . SA1518DescriptionAllow ) , LayoutResources . ResourceManager , typeof ( LayoutResources ) ) ;
35+ private static readonly LocalizableString MessageFormatRequire = new LocalizableResourceString ( nameof ( LayoutResources . SA1518MessageFormatRequire ) , LayoutResources . ResourceManager , typeof ( LayoutResources ) ) ;
36+ private static readonly LocalizableString DescriptionRequire = new LocalizableResourceString ( nameof ( LayoutResources . SA1518DescriptionRequire ) , LayoutResources . ResourceManager , typeof ( LayoutResources ) ) ;
37+ private static readonly LocalizableString MessageFormatOmit = new LocalizableResourceString ( nameof ( LayoutResources . SA1518MessageFormatOmit ) , LayoutResources . ResourceManager , typeof ( LayoutResources ) ) ;
38+ private static readonly LocalizableString DescriptionOmit = new LocalizableResourceString ( nameof ( LayoutResources . SA1518DescriptionOmit ) , LayoutResources . ResourceManager , typeof ( LayoutResources ) ) ;
3439
35- internal static readonly DiagnosticDescriptor DescriptorForRequireSetting =
36- new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormatForRequireSetting , AnalyzerCategory . LayoutRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , DescriptionForRequireSetting , HelpLink ) ;
40+ private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1518.md" ;
3741
38- internal static readonly DiagnosticDescriptor DescriptorForOmitSetting =
39- new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormatForOmitSetting , AnalyzerCategory . LayoutRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , DescriptionForOmitSetting , HelpLink ) ;
40-
41- private const string Title = "Use line endings correctly at the end of the file" ;
42-
43- private const string MessageFormatForAllowSetting = "Code must not contain blank lines at the end of the file" ;
44- private const string DescriptionForAllowSetting = "Code must not contain blank lines at the end of the file" ;
45-
46- private const string MessageFormatForRequireSetting = "Code is required to end with a single newline character" ;
47- private const string DescriptionForRequireSetting = "Code is required to end with a single newline character" ;
42+ private static readonly Action < CompilationStartAnalysisContext > CompilationStartAction = HandleCompilationStart ;
43+ private static readonly Action < SyntaxTreeAnalysisContext , StyleCopSettings > SyntaxTreeAction = HandleSyntaxTree ;
4844
49- private const string MessageFormatForOmitSetting = "Code may not end with a newline character" ;
50- private const string DescriptionForOmitSetting = "Code may not end with a newline character" ;
45+ public static DiagnosticDescriptor DescriptorAllow { get ; } =
46+ new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormatAllow , AnalyzerCategory . LayoutRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , DescriptionAllow , HelpLink ) ;
5147
52- private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1518.md" ;
48+ public static DiagnosticDescriptor DescriptorRequire { get ; } =
49+ new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormatRequire , AnalyzerCategory . LayoutRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , DescriptionRequire , HelpLink ) ;
5350
54- private static readonly Action < CompilationStartAnalysisContext > CompilationStartAction = HandleCompilationStart ;
55- private static readonly Action < SyntaxTreeAnalysisContext , StyleCopSettings > SyntaxTreeAction = HandleSyntaxTree ;
51+ public static DiagnosticDescriptor DescriptorOmit { get ; } =
52+ new DiagnosticDescriptor ( DiagnosticId , Title , MessageFormatOmit , AnalyzerCategory . LayoutRules , DiagnosticSeverity . Warning , AnalyzerConstants . EnabledByDefault , DescriptionOmit , HelpLink ) ;
5653
5754 /// <inheritdoc/>
5855 public override ImmutableArray < DiagnosticDescriptor > SupportedDiagnostics { get ; } =
59- ImmutableArray . Create ( DescriptorForAllowSetting ) ;
56+ ImmutableArray . Create ( DescriptorAllow ) ;
6057
6158 /// <inheritdoc/>
6259 public override void Initialize ( AnalysisContext context )
@@ -156,7 +153,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCop
156153 return ;
157154 }
158155
159- descriptorToReport = DescriptorForOmitSetting ;
156+ descriptorToReport = DescriptorOmit ;
160157 break ;
161158
162159 case EndOfFileHandling . Require :
@@ -165,7 +162,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCop
165162 return ;
166163 }
167164
168- descriptorToReport = DescriptorForRequireSetting ;
165+ descriptorToReport = DescriptorRequire ;
169166 break ;
170167
171168 case EndOfFileHandling . Allow :
@@ -180,7 +177,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCop
180177 }
181178 }
182179
183- descriptorToReport = DescriptorForAllowSetting ;
180+ descriptorToReport = DescriptorAllow ;
184181 break ;
185182 }
186183
0 commit comments