Skip to content

Commit a9cfb8d

Browse files
committed
fixed File fix all code
1 parent 196d2c6 commit a9cfb8d

File tree

4 files changed

+24
-29
lines changed

4 files changed

+24
-29
lines changed
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
using CodeDocumentor.Helper;
2-
using CodeDocumentor.Vsix2022;
1+
using CodeDocumentor.Analyzers;
2+
using CodeDocumentor.Common;
33
using Microsoft.CodeAnalysis;
44

55
namespace CodeDocumentor
66
{
7-
internal class FileAnalyzerSettings
7+
internal class FileAnalyzerSettings: BaseAnalyzerSettings
88
{
99
/// <summary>
1010
/// The title.
1111
/// </summary>
1212
internal const string Title = "The file needs documentation headers.";
1313

14-
/// <summary>
15-
/// The category.
16-
/// </summary>
17-
internal const string Category = DocumentationHeaderHelper.CATEGORY;
18-
1914
/// <summary>
2015
/// The diagnostic id.
2116
/// </summary>
@@ -29,8 +24,8 @@ internal class FileAnalyzerSettings
2924
internal static DiagnosticDescriptor GetRule()
3025
{
3126
//we dont need to show this to still show the option to decorate the whole file. Setting DiagnosticSeverity.Hidden
32-
return new DiagnosticDescriptor(FileAnalyzerSettings.DiagnosticId, FileAnalyzerSettings.Title,
33-
FileAnalyzerSettings.MessageFormat, FileAnalyzerSettings.Category, DiagnosticSeverity.Hidden, true);
27+
return new DiagnosticDescriptor(DiagnosticId, Title,
28+
MessageFormat, Category, DiagnosticSeverity.Hidden, true);
3429
}
3530
}
3631
}

CodeDocumentor/Analyzers/Files/FileCodeFixProvider.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Linq;
66
using System.Threading;
77
using System.Threading.Tasks;
8-
using CodeDocumentor.Vsix2022;
8+
using CodeDocumentor.Helper;
99
using Microsoft.CodeAnalysis;
1010
using Microsoft.CodeAnalysis.CodeActions;
1111
using Microsoft.CodeAnalysis.CodeFixes;
@@ -18,12 +18,12 @@ namespace CodeDocumentor
1818
/// The class code fix provider.
1919
/// </summary>
2020
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(FileCodeFixProvider)), Shared]
21-
public class FileCodeFixProvider : CodeFixProvider
21+
public class FileCodeFixProvider : BaseCodeFixProvider
2222
{
2323
/// <summary>
2424
/// The title.
2525
/// </summary>
26-
private const string title = "Code Documentor this whole file";
26+
private const string Title = "Code Documentor this whole file";
2727

2828
/// <summary>
2929
/// Gets the fixable diagnostic ids.
@@ -61,26 +61,26 @@ public override sealed async Task RegisterCodeFixesAsync(CodeFixContext context)
6161
return;
6262
#endif
6363
Diagnostic diagnostic = context.Diagnostics.First();
64-
64+
var settings = await context.BuildSettingsAsync(StaticSettings);
6565
//build it up, but check for counts if anything actually needs to be shown
6666
var _nodesTempToReplace = new Dictionary<CSharpSyntaxNode, CSharpSyntaxNode>();
6767
Document tempDoc = context.Document;
6868
SyntaxNode root = await tempDoc.GetSyntaxRootAsync(context.CancellationToken);
6969
//Order Matters
7070
var neededCommentCount = 0;
71-
neededCommentCount += PropertyCodeFixProvider.BuildComments(root, _nodesTempToReplace);
72-
neededCommentCount += ConstructorCodeFixProvider.BuildComments(root, _nodesTempToReplace);
73-
neededCommentCount += EnumCodeFixProvider.BuildComments(root, _nodesTempToReplace);
74-
neededCommentCount += FieldCodeFixProvider.BuildComments(root, _nodesTempToReplace);
75-
neededCommentCount += MethodCodeFixProvider.BuildComments(root, _nodesTempToReplace);
71+
neededCommentCount += PropertyCodeFixProvider.BuildComments(settings,root, _nodesTempToReplace);
72+
neededCommentCount += ConstructorCodeFixProvider.BuildComments(settings, root, _nodesTempToReplace);
73+
neededCommentCount += EnumCodeFixProvider.BuildComments(settings, root, _nodesTempToReplace);
74+
neededCommentCount += FieldCodeFixProvider.BuildComments(settings, root, _nodesTempToReplace);
75+
neededCommentCount += MethodCodeFixProvider.BuildComments(settings, root, _nodesTempToReplace);
7676
root = root.ReplaceNodes(_nodesTempToReplace.Keys, (n1, n2) =>
7777
{
7878
return _nodesTempToReplace[n1];
7979
});
8080
_nodesTempToReplace.Clear();
81-
neededCommentCount += InterfaceCodeFixProvider.BuildComments(root, _nodesTempToReplace);
82-
neededCommentCount += ClassCodeFixProvider.BuildComments(root, _nodesTempToReplace);
83-
neededCommentCount += RecordCodeFixProvider.BuildComments(root, _nodesTempToReplace);
81+
neededCommentCount += InterfaceCodeFixProvider.BuildComments(settings, root, _nodesTempToReplace);
82+
neededCommentCount += ClassCodeFixProvider.BuildComments(settings, root, _nodesTempToReplace);
83+
neededCommentCount += RecordCodeFixProvider.BuildComments(settings, root, _nodesTempToReplace);
8484
var newRoot = root.ReplaceNodes(_nodesTempToReplace.Keys, (n1, n2) =>
8585
{
8686
return _nodesTempToReplace[n1];
@@ -92,11 +92,10 @@ public override sealed async Task RegisterCodeFixesAsync(CodeFixContext context)
9292

9393
context.RegisterCodeFix(
9494
CodeAction.Create(
95-
title: title,
95+
title: Title,
9696
createChangedDocument: (c) => Task.Run(() => context.Document.WithSyntaxRoot(newRoot), c),
97-
equivalenceKey: title),
97+
equivalenceKey: Title),
9898
diagnostic);
9999
}
100-
101100
}
102101
}

CodeDocumentor/CodeDocumentor.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
<Compile Include="Analyzers\BaseAnalyzerSettings.cs" />
5757
<Compile Include="Analyzers\BaseCodeFixProvider.cs" />
5858
<Compile Include="Analyzers\BaseDiagnosticAnalyzer.cs" />
59+
<Compile Include="Analyzers\Files\FileAnalyzer.cs" />
60+
<Compile Include="Analyzers\Files\FileAnalyzerSettings.cs" />
61+
<Compile Include="Analyzers\Files\FileCodeFixProvider.cs" />
5962
<Compile Include="Analyzers\Records\RecordAnalyzer.cs" />
6063
<Compile Include="Analyzers\Records\RecordAnalyzerSettings.cs" />
6164
<Compile Include="Analyzers\Records\RecordCodeFixProvider.cs" />
@@ -148,9 +151,7 @@
148151
<IncludeInVSIX>true</IncludeInVSIX>
149152
</Content>
150153
</ItemGroup>
151-
<ItemGroup>
152-
<Folder Include="Analyzers\Files\" />
153-
</ItemGroup>
154+
<ItemGroup />
154155
<ItemGroup>
155156
<ProjectReference Include="..\CodeDocumentor.Common\CodeDocumentor.Common.csproj">
156157
<Project>{7cc64cdf-a7ff-463b-8f05-c37a6c0a820c}</Project>

Manifests/vs2022/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="CodeDocumentor.2022.88F29096-CA4C-4F88-A260-705D8BBFCF2A" Version="3.0.1.0" Language="en-US" Publisher="Dan Turco"/>
4+
<Identity Id="CodeDocumentor.2022.88F29096-CA4C-4F88-A260-705D8BBFCF2A" Version="3.0.1.1" Language="en-US" Publisher="Dan Turco"/>
55
<DisplayName>CodeDocumentor</DisplayName>
66
<Description xml:space="preserve">An Extension to generate XML documentation automatically using IntelliSense for interface,class,enum, field, constructor, property and method.</Description>
77
<Icon>logo.png</Icon>

0 commit comments

Comments
 (0)