-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial work for analyzer tutorial * Make code fixes a separate project to match template * Update test project - test code file will be addressed in later commit * Fix paths * More edits to the article * Use var - address part of #17779 * Add sln and NuGet.config * More fixes * Move snippets.5000.json * Update dependabot.yml * More fixes * Make static * Address feedback and use snippets * Forward cancellation token * Update docs/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix.md * Update docs/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix.md Co-authored-by: Sam Harwell <[email protected]> Co-authored-by: Sam Harwell <[email protected]>
- Loading branch information
1 parent
2f5b6a2
commit 2308812
Showing
45 changed files
with
1,199 additions
and
1,368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
296 changes: 103 additions & 193 deletions
296
docs/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix.md
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
...torials/media/how-to-write-csharp-analyzer-code-fix/update-string-resources.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions
49
.../csharp/roslyn-sdk/tutorials/snippets/how-to-write-csharp-analyzer-code-fix/MakeConst.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30804.86 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeConst", "MakeConst\MakeConst\MakeConst.csproj", "{2CC0B384-3A66-4BC9-8506-CE6C0E2C62F0}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeConst.CodeFixes", "MakeConst\MakeConst.CodeFixes\MakeConst.CodeFixes.csproj", "{A575A3F6-AAE2-4F28-A118-DA7A71216F05}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeConst.Package", "MakeConst\MakeConst.Package\MakeConst.Package.csproj", "{CCD63038-DF8D-4BA1-B151-F78E2A8999AF}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeConst.Test", "MakeConst\MakeConst.Test\MakeConst.Test.csproj", "{5CA2BD3A-3B69-4FAB-9B80-4A9A518DF19B}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeConst.Vsix", "MakeConst\MakeConst.Vsix\MakeConst.Vsix.csproj", "{C10E2C7A-4425-4A92-958C-637CFA1053F6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2CC0B384-3A66-4BC9-8506-CE6C0E2C62F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2CC0B384-3A66-4BC9-8506-CE6C0E2C62F0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2CC0B384-3A66-4BC9-8506-CE6C0E2C62F0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2CC0B384-3A66-4BC9-8506-CE6C0E2C62F0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A575A3F6-AAE2-4F28-A118-DA7A71216F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A575A3F6-AAE2-4F28-A118-DA7A71216F05}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A575A3F6-AAE2-4F28-A118-DA7A71216F05}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A575A3F6-AAE2-4F28-A118-DA7A71216F05}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{CCD63038-DF8D-4BA1-B151-F78E2A8999AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CCD63038-DF8D-4BA1-B151-F78E2A8999AF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CCD63038-DF8D-4BA1-B151-F78E2A8999AF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CCD63038-DF8D-4BA1-B151-F78E2A8999AF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{5CA2BD3A-3B69-4FAB-9B80-4A9A518DF19B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5CA2BD3A-3B69-4FAB-9B80-4A9A518DF19B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5CA2BD3A-3B69-4FAB-9B80-4A9A518DF19B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5CA2BD3A-3B69-4FAB-9B80-4A9A518DF19B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{C10E2C7A-4425-4A92-958C-637CFA1053F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C10E2C7A-4425-4A92-958C-637CFA1053F6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C10E2C7A-4425-4A92-958C-637CFA1053F6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C10E2C7A-4425-4A92-958C-637CFA1053F6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {6113272F-D929-4E71-A537-A56340FDD4BF} | ||
EndGlobalSection | ||
EndGlobal |
72 changes: 72 additions & 0 deletions
72
...write-csharp-analyzer-code-fix/MakeConst/MakeConst.CodeFixes/CodeFixResources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
124 changes: 124 additions & 0 deletions
124
...how-to-write-csharp-analyzer-code-fix/MakeConst/MakeConst.CodeFixes/CodeFixResources.resx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<!-- | ||
Microsoft ResX Schema | ||
Version 2.0 | ||
The primary goals of this format is to allow a simple XML format | ||
that is mostly human readable. The generation and parsing of the | ||
various data types are done through the TypeConverter classes | ||
associated with the data types. | ||
Example: | ||
... ado.net/XML headers & schema ... | ||
<resheader name="resmimetype">text/microsoft-resx</resheader> | ||
<resheader name="version">2.0</resheader> | ||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | ||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | ||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | ||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | ||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | ||
<value>[base64 mime encoded serialized .NET Framework object]</value> | ||
</data> | ||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | ||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | ||
<comment>This is a comment</comment> | ||
</data> | ||
There are any number of "resheader" rows that contain simple | ||
name/value pairs. | ||
Each data row contains a name, and value. The row also contains a | ||
type or mimetype. Type corresponds to a .NET class that support | ||
text/value conversion through the TypeConverter architecture. | ||
Classes that don't support this are serialized and stored with the | ||
mimetype set. | ||
The mimetype is used for serialized objects, and tells the | ||
ResXResourceReader how to depersist the object. This is currently not | ||
extensible. For a given mimetype the value must be set accordingly: | ||
Note - application/x-microsoft.net.object.binary.base64 is the format | ||
that the ResXResourceWriter will generate, however the reader can | ||
read any of the formats listed below. | ||
mimetype: application/x-microsoft.net.object.binary.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.soap.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
value : The object must be serialized into a byte array | ||
: using a System.ComponentModel.TypeConverter | ||
: and then encoded with base64 encoding. | ||
--> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" use="required" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<data name="CodeFixTitle" xml:space="preserve"> | ||
<value>Make constant</value> | ||
<comment>The title of the code fix.</comment> | ||
</data> | ||
</root> |
22 changes: 22 additions & 0 deletions
22
...o-write-csharp-analyzer-code-fix/MakeConst/MakeConst.CodeFixes/MakeConst.CodeFixes.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<RootNamespace>MakeConst</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.3.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MakeConst\MakeConst.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="CodeFixResources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="CodeFixResources.resx" /> | ||
<EmbeddedResource Update="CodeFixResources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="CodeFixResources.Designer.cs" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.