1+ <wpf : ResourceDictionary xml : space =" preserve" xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml" xmlns : s =" clr-namespace:System;assembly=mscorlib" xmlns : ss =" urn:shemas-jetbrains-com:settings-storage-xaml" xmlns : wpf =" http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
2+ <s : String x : Key =" /Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue" >Copyright $CREATED_YEAR$ Andreas Müller
3+ This file is a part of Amusoft.CodeAnalysis.Analyzers and is licensed under Apache 2.0
4+ See https://github.com/taori/Amusoft.CodeAnalysis.Analyzers/blob/master/LICENSE for details</s : String >
5+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/@KeyIndexDefined" >True</s : Boolean >
6+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Description/@EntryValue" >& CodeFixTest</s : String >
7+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=CLASS/Expression/@EntryValue" >getAlphaNumericFileNameWithoutExtension()</s : String >
8+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=CLASS/InitialRange/@EntryValue" >-1</s : Int64 >
9+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=FixerProviderType/@KeyIndexDefined" >True</s : Boolean >
10+
11+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=FixerProviderType/Order/@EntryValue" >3</s : Int64 >
12+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=HEADER/InitialRange/@EntryValue" >-1</s : Int64 >
13+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=NAMESPACE/Expression/@EntryValue" >fileDefaultNamespace()</s : String >
14+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=NAMESPACE/InitialRange/@EntryValue" >-1</s : Int64 >
15+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Text/@EntryValue" >$HEADER$using System.Threading.Tasks;
16+ using Microsoft.CodeAnalysis.CSharp.Testing.MSTest;
17+ using Microsoft.CodeAnalysis.Testing;
18+ using Microsoft.VisualStudio.TestTools.UnitTesting;
19+ using static Microsoft.CodeAnalysis.Testing.DiagnosticResult;
20+ using Verifier = Microsoft.CodeAnalysis.CSharp.Testing.MSTest.CodeFixVerifier< Microsoft.CodeAnalysis.Testing.EmptyDiagnosticAnalyzer, $FixerProviderType$> ;
21+ 
22+ namespace $NAMESPACE$
23+ {
24+ [TestClass]
25+ public class $CLASS$
26+ {
27+ [TestMethod]
28+ public async Task EmptySourceNoAction()
29+ {
30+ await Verifier.VerifyCodeFixAsync(string.Empty, string.Empty);
31+ }
32+ 
33+ [TestMethod]
34+ public async Task DiagnosticAtObjectCreationExpression()
35+ {
36+ $END$
37+ var test = @"
38+ using System;
39+ using System.Collections.Generic;
40+ using System.Linq;
41+ using System.Text;
42+ using System.Threading.Tasks;
43+ using System.Diagnostics;
44+ 
45+ namespace ConsoleApplication1
46+ {
47+ class TypeName
48+ {
49+ TypeName()
50+ {
51+ var action = new Func< int, string> (TestMethod);
52+ }
53+ 
54+ private int TestMethod(int arg)
55+ {
56+ throw new NotImplementedException();
57+ }
58+ }
59+ }";
60+ 
61+ 
62+ var fixtest = @"
63+ using System;
64+ using System.Collections.Generic;
65+ using System.Linq;
66+ using System.Text;
67+ using System.Threading.Tasks;
68+ using System.Diagnostics;
69+ 
70+ namespace ConsoleApplication1
71+ {
72+ class TypeName
73+ {
74+ TypeName()
75+ {
76+ var action = new Func< int, string> (TestMethod);
77+ }
78+ 
79+ private string TestMethod(int arg)
80+ {
81+ throw new NotImplementedException();
82+ }
83+ }
84+ }";
85+ var diagnostics = new[]
86+ {
87+ CompilerError("CS0407").WithLocation(15, 48),
88+ };
89+ 
90+ await Verifier.VerifyCodeFixAsync(test, diagnostics, fixtest);
91+ }
92+ }
93+ }</s : String >
94+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Reformat/@EntryValue" >True</s : Boolean >
95+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/ShortenQualifiedReferences/@EntryValue" >True</s : Boolean >
96+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/CustomProperties/=FileName/@EntryIndexedValue" >CodeFixTest</s : String >
97+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/CustomProperties/=Extension/@EntryIndexedValue" >cs</s : String >
98+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/CustomProperties/=ValidateFileName/@EntryIndexedValue" >True</s : String >
99+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Applicability/=File/@EntryIndexedValue" >True</s : Boolean >
100+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Scope/=E8F0594528C33E45BBFEC6CFE851095D/@KeyIndexDefined" >True</s : Boolean >
101+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Scope/=E8F0594528C33E45BBFEC6CFE851095D/Type/@EntryValue" >InCSharpProjectFile</s : String >
102+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=HEADER/@KeyIndexDefined" >True</s : Boolean >
103+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=HEADER/Expression/@EntryValue" >fileheader()</s : String >
104+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=HEADER/Order/@EntryValue" >0</s : Int64 >
105+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=NAMESPACE/@KeyIndexDefined" >True</s : Boolean >
106+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=NAMESPACE/Order/@EntryValue" >1</s : Int64 >
107+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=CLASS/@KeyIndexDefined" >True</s : Boolean >
108+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=21CCC48EE521CF46B74D3A0C28EEFF1E/Field/=CLASS/Order/@EntryValue" >2</s : Int64 >
109+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/@KeyIndexDefined" >True</s : Boolean >
110+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Applicability/=File/@EntryIndexedValue" >True</s : Boolean >
111+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/CustomProperties/=Extension/@EntryIndexedValue" >cs</s : String >
112+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/CustomProperties/=FileName/@EntryIndexedValue" >CodeFix</s : String >
113+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/CustomProperties/=ValidateFileName/@EntryIndexedValue" >True</s : String >
114+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Description/@EntryValue" >& CodeFix</s : String >
115+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=CLASS/@KeyIndexDefined" >True</s : Boolean >
116+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=CLASS/Expression/@EntryValue" >getAlphaNumericFileNameWithoutExtension()</s : String >
117+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=CLASS/InitialRange/@EntryValue" >-1</s : Int64 >
118+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=CLASS/Order/@EntryValue" >2</s : Int64 >
119+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=diagnosticId/@KeyIndexDefined" >True</s : Boolean >
120+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=diagnosticId/InitialRange/@EntryValue" >1</s : Int64 >
121+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=diagnosticId/Order/@EntryValue" >3</s : Int64 >
122+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=HEADER/@KeyIndexDefined" >True</s : Boolean >
123+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=HEADER/Expression/@EntryValue" >fileheader()</s : String >
124+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=HEADER/InitialRange/@EntryValue" >-1</s : Int64 >
125+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=HEADER/Order/@EntryValue" >0</s : Int64 >
126+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=NAMESPACE/@KeyIndexDefined" >True</s : Boolean >
127+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=NAMESPACE/Expression/@EntryValue" >fileDefaultNamespace()</s : String >
128+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=NAMESPACE/InitialRange/@EntryValue" >-1</s : Int64 >
129+ <s : Int64 x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Field/=NAMESPACE/Order/@EntryValue" >1</s : Int64 >
130+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Reformat/@EntryValue" >True</s : Boolean >
131+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Scope/=E8F0594528C33E45BBFEC6CFE851095D/@KeyIndexDefined" >True</s : Boolean >
132+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Scope/=E8F0594528C33E45BBFEC6CFE851095D/Type/@EntryValue" >InCSharpProjectFile</s : String >
133+ <s : Boolean x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/ShortenQualifiedReferences/@EntryValue" >True</s : Boolean >
134+ <s : String x : Key =" /Default/PatternsAndTemplates/LiveTemplates/Template/=EF22B9F0D1F98943AB7B20E28E6E8504/Text/@EntryValue" >$HEADER$using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
135+ using System.Composition;
136+ using System.Linq;
137+ using System.Threading;
138+ using System.Threading.Tasks;
139+ using Amusoft.CodeAnalysis.Analyzers.Shared;
140+ using Microsoft.CodeAnalysis;
141+ using Microsoft.CodeAnalysis.CodeFixes;
142+ using Microsoft.CodeAnalysis.CSharp;
143+ using Microsoft.CodeAnalysis.CSharp.Syntax;
144+ using Microsoft.CodeAnalysis.Formatting;
145+ using Microsoft.CodeAnalysis.Simplification;
146+ 
147+ namespace $NAMESPACE$
148+ {
149+ [ExportCodeFixProvider(LanguageNames.CSharp, Name = "$diagnosticId$-$CLASS$"), Shared]
150+ public class $CLASS$ : Amusoft.CodeAnalysis.Analyzers.Shared.CodeFixProviderBase
151+ {
152+ /// < inheritdoc />
153+ protected override string DiagnosticId { get; } = "$diagnosticId$";
154+ 
155+ /// < inheritdoc />
156+ protected override string GetEquivalenceKey(SyntaxNode rootNode)
157+ {
158+ return "$diagnosticId$-$CLASS$";
159+ }
160+ 
161+ /// < inheritdoc />
162+ protected override string GetTitle(SyntaxNode rootNode)
163+ {
164+ var member = GetAnnotationValue(rootNode, MemberAnnotation);
165+ var typeName = GetAnnotationValue(rootNode, TypeAnnotation);
166+ return string.Format(Resources.$SELSTART$MessageFormat_$diagnosticId$_$CLASS$$SELEND$, member, typeName);
167+ }
168+ 
169+ /// < inheritdoc />
170+ protected override async Task< SyntaxNode> FixedDiagnosticAsync(SyntaxNode rootNode, SyntaxNode diagnosticNode, CodeFixContext context,
171+ CancellationToken cancellationToken)
172+ {
173+ return rootNode;
174+ }
175+ }
176+ }</s : String ></wpf : ResourceDictionary >
0 commit comments