@@ -35,6 +35,84 @@ See https://github.com/taori/Amusoft.CodeAnalysis.Analyzers/blob/master/LICENSE
3535 Sources = { fixtest }
3636 },
3737}.RunAsync();</s : String >
38+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/@KeyIndexDefined" >True</s : Boolean >
39+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Applicability/=File/@EntryIndexedValue" >True</s : Boolean >
40+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/CustomProperties/=Extension/@EntryIndexedValue" >cs</s : String >
41+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/CustomProperties/=FileName/@EntryIndexedValue" >Analyzer</s : String >
42+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/CustomProperties/=ValidateFileName/@EntryIndexedValue" >True</s : String >
43+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Description/@EntryValue" >& Analyzer</s : String >
44+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=CLASS/@KeyIndexDefined" >True</s : Boolean >
45+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=CLASS/Expression/@EntryValue" >getAlphaNumericFileNameWithoutExtension()</s : String >
46+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=CLASS/InitialRange/@EntryValue" >-1</s : Int64 >
47+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=CLASS/Order/@EntryValue" >2</s : Int64 >
48+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=HEADER/@KeyIndexDefined" >True</s : Boolean >
49+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=HEADER/Expression/@EntryValue" >fileheader()</s : String >
50+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=HEADER/InitialRange/@EntryValue" >-1</s : Int64 >
51+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=HEADER/Order/@EntryValue" >0</s : Int64 >
52+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=NAMESPACE/@KeyIndexDefined" >True</s : Boolean >
53+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=NAMESPACE/Expression/@EntryValue" >fileDefaultNamespace()</s : String >
54+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=NAMESPACE/InitialRange/@EntryValue" >-1</s : Int64 >
55+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Field/=NAMESPACE/Order/@EntryValue" >1</s : Int64 >
56+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Reformat/@EntryValue" >True</s : Boolean >
57+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Scope/=E8F0594528C33E45BBFEC6CFE851095D/@KeyIndexDefined" >True</s : Boolean >
58+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Scope/=E8F0594528C33E45BBFEC6CFE851095D/Type/@EntryValue" >InCSharpProjectFile</s : String >
59+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/ShortenQualifiedReferences/@EntryValue" >True</s : Boolean >
60+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=211FAF7F1279B04CAA442CA9B37CF79A/Text/@EntryValue" >$HEADER$using System.Collections.Immutable;
61+ using Amusoft.CodeAnalysis.Analyzers.Shared;
62+ using Microsoft.CodeAnalysis;
63+ using Microsoft.CodeAnalysis.Diagnostics;
64+ using Microsoft.CodeAnalysis.CSharp;
65+ using Microsoft.CodeAnalysis.CSharp.Syntax;
66+ using Microsoft.CodeAnalysis.Formatting;
67+ using Microsoft.CodeAnalysis.Simplification;
68+ using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
69+ 
70+ namespace $NAMESPACE$
71+ {
72+ [DiagnosticAnalyzer(LanguageNames.CSharp)]
73+ public class $CLASS$ : DiagnosticAnalyzer
74+ {
75+ #region PrimaryRule
76+ 
77+ private static readonly LocalizableString PrimaryRuleTitle = new LocalizableResourceString(
78+ nameof(Resources.$CLASS$_PrimaryRuleTitle),
79+ Resources.ResourceManager,
80+ typeof(Resources));
81+ 
82+ private static readonly LocalizableString PrimaryRuleMessageFormat = new LocalizableResourceString(
83+ nameof(Resources.$CLASS$_PrimaryRuleMessageFormat),
84+ Resources.ResourceManager,
85+ typeof(Resources));
86+ 
87+ private static readonly LocalizableString PrimaryRuleDescription = new LocalizableResourceString(
88+ nameof(Resources.$CLASS$_PrimaryRuleDescription),
89+ Resources.ResourceManager,
90+ typeof(Resources));
91+ 
92+ private static readonly DiagnosticDescriptor PrimaryRule = new DiagnosticDescriptor(
93+ DiagnosticIds.ACA0002.$END$, PrimaryRuleTitle, PrimaryRuleMessageFormat,
94+ "ACA Diagnostics", DiagnosticSeverity.Info, isEnabledByDefault: true, description: PrimaryRuleDescription);
95+ 
96+ #endregion
97+ /// < inheritdoc />
98+ public override void Initialize(AnalysisContext context)
99+ {
100+ context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
101+ context.RegisterSyntaxNodeAction(AnalyzeClass, syntaxKinds: SyntaxKind.ClassDeclaration);
102+ }
103+ 
104+ /// < inheritdoc />
105+ public override ImmutableArray< DiagnosticDescriptor> SupportedDiagnostics
106+ {
107+ get { return ImmutableArray.Create(PrimaryRule); }
108+ }
109+ 
110+ private void AnalyzeClass(SyntaxNodeAnalysisContext context)
111+ {
112+ throw new System.NotImplementedException();
113+ }
114+ }
115+ }</s : String >
38116 <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/@KeyIndexDefined" >True</s : Boolean >
39117 <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Description/@EntryValue" >& CodeFixTest</s : String >
40118 <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=CLASS/Expression/@EntryValue" >getAlphaNumericFileNameWithoutExtension()</s : String >
@@ -153,6 +231,44 @@ namespace ConsoleApplication1
153231};
154232
155233await Verifier.VerifyCodeFixAsync(test, expected, fixtest);</s : String >
234+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/@KeyIndexDefined" >True</s : Boolean >
235+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Applicability/=Live/@EntryIndexedValue" >True</s : Boolean >
236+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=className/@KeyIndexDefined" >True</s : Boolean >
237+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=className/Expression/@EntryValue" >typeName()</s : String >
238+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=className/InitialRange/@EntryValue" >-1</s : Int64 >
239+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=className/Order/@EntryValue" >2</s : Int64 >
240+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=Name/@KeyIndexDefined" >True</s : Boolean >
241+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=Name/Order/@EntryValue" >0</s : Int64 >
242+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=severity/@KeyIndexDefined" >True</s : Boolean >
243+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=severity/Expression/@EntryValue" >completeSmart()</s : String >
244+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Field/=severity/Order/@EntryValue" >1</s : Int64 >
245+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Reformat/@EntryValue" >True</s : Boolean >
246+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/@KeyIndexDefined" >True</s : Boolean >
247+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue" >2.0</s : String >
248+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/Type/@EntryValue" >InCSharpTypeMember</s : String >
249+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Shortcut/@EntryValue" >diagnosticRule</s : String >
250+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/ShortenQualifiedReferences/@EntryValue" >True</s : Boolean >
251+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=69AF852163625840B2613F739ACE8A8C/Text/@EntryValue" >#region $Name$
252+ 
253+ private static readonly LocalizableString $Name$Title = new LocalizableResourceString(
254+ nameof(Amusoft.CodeAnalysis.Analyzers.Resources.$className$_$Name$Title),
255+ Amusoft.CodeAnalysis.Analyzers.Resources.ResourceManager,
256+ typeof(Amusoft.CodeAnalysis.Analyzers.Resources));
257+ 
258+ private static readonly LocalizableString $Name$MessageFormat = new LocalizableResourceString(
259+ nameof(Amusoft.CodeAnalysis.Analyzers.Resources.$className$_$Name$MessageFormat),
260+ Amusoft.CodeAnalysis.Analyzers.Resources.ResourceManager,
261+ typeof(Amusoft.CodeAnalysis.Analyzers.Resources));
262+ 
263+ private static readonly LocalizableString $Name$Description = new LocalizableResourceString(
264+ nameof(Amusoft.CodeAnalysis.Analyzers.Resources.$className$_$Name$Description),
265+ Amusoft.CodeAnalysis.Analyzers.Resources.ResourceManager,
266+ typeof(Amusoft.CodeAnalysis.Analyzers.Resources));
267+ 
268+ public static readonly DiagnosticDescriptor $Name$ = new DiagnosticDescriptor(
269+ Amusoft.CodeAnalysis.Analyzers.Shared.DiagnosticIds.ACA0002.DiagnosticOnArray, $Name$Title, $Name$MessageFormat, "ACA Diagnostics", DiagnosticSeverity.$severity$, isEnabledByDefault: true, description: $Name$Description);
270+ 
271+ #endregion</s : String >
156272 <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/@KeyIndexDefined" >True</s : Boolean >
157273 <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Applicability/=File/@EntryIndexedValue" >True</s : Boolean >
158274 <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/CustomProperties/=Extension/@EntryIndexedValue" >cs</s : String >
@@ -163,6 +279,10 @@ await Verifier.VerifyCodeFixAsync(test, expected, fixtest);</s:String>
163279 <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=CLASS/Expression/@EntryValue" >getAlphaNumericFileNameWithoutExtension()</s : String >
164280 <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=CLASS/InitialRange/@EntryValue" >-1</s : Int64 >
165281 <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=CLASS/Order/@EntryValue" >2</s : Int64 >
282+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=complete/@KeyIndexDefined" >True</s : Boolean >
283+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=complete/Expression/@EntryValue" >completeSmart()</s : String >
284+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=complete/InitialRange/@EntryValue" >-1</s : Int64 >
285+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=complete/Order/@EntryValue" >4</s : Int64 >
166286 <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=diagnosticId/@KeyIndexDefined" >True</s : Boolean >
167287 <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=diagnosticId/InitialRange/@EntryValue" >1</s : Int64 >
168288 <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=diagnosticId/Order/@EntryValue" >3</s : Int64 >
@@ -190,19 +310,20 @@ using Microsoft.CodeAnalysis.CSharp;
190310using Microsoft.CodeAnalysis.CSharp.Syntax;
191311using Microsoft.CodeAnalysis.Formatting;
192312using Microsoft.CodeAnalysis.Simplification;
313+ using Microsoft.CodeAnalysis.Text;
193314
194315namespace $NAMESPACE$
195316{
196- [ExportCodeFixProvider(LanguageNames.CSharp, Name = "$diagnosticId $-$CLASS$"), Shared]
197- public class $CLASS$ : Amusoft.CodeAnalysis.Analyzers.Shared.CodeFixProviderBase 
317+ [ExportCodeFixProvider(LanguageNames.CSharp, Name = "$NAMESPACE $-$CLASS$"), Shared]
318+ public class $CLASS$ : Amusoft.CodeAnalysis.Analyzers.Shared.SingleDiagnosticDocumentCodeFixProviderBase 
198319 {
199320 /// < inheritdoc />
200- protected override string DiagnosticId { get; } = "$diagnosticId$" ;
321+ protected override string DiagnosticId { get; } = $SELSTART$Amusoft.CodeAnalysis.Analyzers.Shared.DiagnosticIds.$complete$$SELEND$ ;
201322
202323 /// < inheritdoc />
203324 protected override string GetEquivalenceKey(SyntaxNode rootNode)
204325 {
205- return "$diagnosticId$ -$CLASS$";
326+ return $"{DiagnosticId} -$CLASS$";
206327 }
207328
208329 /// < inheritdoc />
@@ -214,10 +335,16 @@ namespace $NAMESPACE$
214335 }
215336
216337 /// < inheritdoc />
217- protected override async Task< SyntaxNode > FixedDiagnosticAsync(SyntaxNode rootNode, SyntaxNode diagnosticNode, CodeFixContext context ,
338+ protected override async Task< Document > GetFixedDiagnosticAsync(Document document, TextSpan span ,
218339 CancellationToken cancellationToken)
219340 {
220- return rootNode;
341+ var semanticModel = await document.GetSemanticModelAsync(cancellationToken)
342+ .ConfigureAwait(false);
343+ var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken)
344+ .ConfigureAwait(false);
345+ var diagnosticNode = syntaxRoot.FindNode(span);
346+ 
347+ return document;
221348 }
222349 }
223350}</s : String >
@@ -246,4 +373,5 @@ namespace $NAMESPACE$
246373 $END$
247374 },
248375 }
249- }.RunAsync();</s : String ></wpf : ResourceDictionary >
376+ }.RunAsync();</s : String >
377+ <s : Boolean x : Key =" /Default/UserDictionary/Words/=Rewriter/@EntryIndexedValue" >True</s : Boolean ></wpf : ResourceDictionary >
0 commit comments