Skip to content

Commit 74626b4

Browse files
authored
Upgrade vs2022 (#44)
* checkpoint * code cleanup null guards * cleaned up ServiceLocator and base class patterns * cleanup and refactor * updated readme * update
1 parent a9cfb8d commit 74626b4

File tree

97 files changed

+775
-647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+775
-647
lines changed

CodeDocumentor/Analyzers/BaseAnalyzerSettings.cs renamed to CodeDocumentor.Analyzers/Analyzers/BaseAnalyzerSettings.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
using CodeDocumentor.Analyzers.Locators;
12
using CodeDocumentor.Common;
3+
using CodeDocumentor.Common.Helpers;
24
using CodeDocumentor.Common.Interfaces;
3-
using CodeDocumentor.Locators;
45
using Microsoft.CodeAnalysis;
56

67
namespace CodeDocumentor.Analyzers
78
{
8-
internal class BaseAnalyzerSettings
9+
public class BaseAnalyzerSettings
910
{
1011
/// <summary>
1112
/// The category.
1213
/// </summary>
13-
internal const string Category = Constants.CATEGORY;
14+
public const string Category = Constants.CATEGORY;
1415

1516
protected IEventLogger EventLogger = ServiceLocator.Logger;
1617

17-
internal DiagnosticSeverity LookupSeverity(string diagnosticId, ISettings settings)
18+
public DiagnosticSeverity LookupSeverity(string diagnosticId, ISettings settings)
1819
{
1920
if (settings == null)
2021
{

CodeDocumentor/Analyzers/Classes/ClassAnalyzer.cs renamed to CodeDocumentor.Analyzers/Analyzers/Classes/ClassAnalyzer.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
using System.Collections.Immutable;
2-
using CodeDocumentor.Builders;
3-
using CodeDocumentor.Helper;
2+
using CodeDocumentor.Analyzers.Builders;
3+
using CodeDocumentor.Analyzers.Helper;
4+
using CodeDocumentor.Analyzers.Locators;
45
using Microsoft.CodeAnalysis;
56
using Microsoft.CodeAnalysis.CSharp;
67
using Microsoft.CodeAnalysis.CSharp.Syntax;
78
using Microsoft.CodeAnalysis.Diagnostics;
89

9-
namespace CodeDocumentor
10+
namespace CodeDocumentor.Analyzers.Classes
1011
{
1112
/// <summary>
1213
/// The class analyzer.
1314
/// </summary>
1415
[DiagnosticAnalyzer(LanguageNames.CSharp)]
15-
public class ClassAnalyzer : BaseDiagnosticAnalyzer
16+
public class ClassAnalyzer : DiagnosticAnalyzer
1617
{
17-
private readonly ClassAnalyzerSettings _analyzerSettings;
18-
19-
public ClassAnalyzer()
20-
{
21-
_analyzerSettings = new ClassAnalyzerSettings();
22-
}
23-
2418
/// <summary>
2519
/// Gets the supported diagnostics.
2620
/// </summary>
2721
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
2822
{
2923
get
3024
{
25+
var _analyzerSettings = new ClassAnalyzerSettings();
3126
return ImmutableArray.Create(_analyzerSettings.GetSupportedDiagnosticRule());
3227
}
3328
}
@@ -47,7 +42,7 @@ public override void Initialize(AnalysisContext context)
4742
/// Analyzes node.
4843
/// </summary>
4944
/// <param name="context"> The context. </param>
50-
public void AnalyzeNode(SyntaxNodeAnalysisContext context)
45+
private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
5146
{
5247
if (!(context.Node is ClassDeclarationSyntax node))
5348
{
@@ -57,13 +52,13 @@ public void AnalyzeNode(SyntaxNodeAnalysisContext context)
5752
{
5853
return;
5954
}
60-
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
55+
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
6156
if (excludeAnanlyzer)
6257
{
6358
return;
6459
}
65-
var settings = context.BuildSettings(StaticSettings);
66-
60+
var settings = ServiceLocator.SettingService.BuildSettings(context);
61+
var _analyzerSettings = new ClassAnalyzerSettings();
6762
context.BuildDiagnostic(node, node.Identifier, (alreadyHasComment) => _analyzerSettings.GetRule(alreadyHasComment, settings));
6863
}
6964
}

CodeDocumentor/Analyzers/Classes/ClassAnalyzerSettings.cs renamed to CodeDocumentor.Analyzers/Analyzers/Classes/ClassAnalyzerSettings.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
using CodeDocumentor.Analyzers;
21
using CodeDocumentor.Common;
32
using CodeDocumentor.Common.Interfaces;
43
using Microsoft.CodeAnalysis;
54

6-
namespace CodeDocumentor
5+
namespace CodeDocumentor.Analyzers
76
{
8-
internal class ClassAnalyzerSettings: BaseAnalyzerSettings
7+
public class ClassAnalyzerSettings : BaseAnalyzerSettings
98
{
109
/// <summary>
1110
/// The diagnostic id.
1211
/// </summary>
13-
internal const string DiagnosticId = Constants.DiagnosticIds.CLASS_DIAGNOSTIC_ID;
12+
public const string DiagnosticId = Constants.DiagnosticIds.CLASS_DIAGNOSTIC_ID;
1413

1514
/// <summary>
1615
/// The message format.
1716
/// </summary>
18-
internal const string MessageFormat = Title;
17+
public const string MessageFormat = Title;
1918

2019
/// <summary>
2120
/// The title.
2221
/// </summary>
23-
internal const string Title = "The class must have a documentation header.";
22+
public const string Title = "The class must have a documentation header.";
2423

25-
internal DiagnosticDescriptor GetSupportedDiagnosticRule()
24+
public DiagnosticDescriptor GetSupportedDiagnosticRule()
2625
{
2726
return new DiagnosticDescriptor(DiagnosticId, Title,
2827
MessageFormat, Category,
2928
DiagnosticSeverity.Info,
3029
true);
3130
}
3231

33-
internal DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
32+
public DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
3433
{
3534
return new DiagnosticDescriptor(DiagnosticId, Title,
3635
MessageFormat, Category,

CodeDocumentor/Analyzers/Classes/NonPublicClassAnalyzer.cs renamed to CodeDocumentor.Analyzers/Analyzers/Classes/NonPublicClassAnalyzer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
using System.Collections.Immutable;
2-
using CodeDocumentor.Builders;
3-
using CodeDocumentor.Helper;
2+
using CodeDocumentor.Analyzers.Builders;
3+
using CodeDocumentor.Analyzers.Helper;
4+
using CodeDocumentor.Analyzers.Locators;
45
using Microsoft.CodeAnalysis;
56
using Microsoft.CodeAnalysis.CSharp;
67
using Microsoft.CodeAnalysis.CSharp.Syntax;
78
using Microsoft.CodeAnalysis.Diagnostics;
89

9-
namespace CodeDocumentor
10+
namespace CodeDocumentor.Analyzers.Classes
1011
{
1112
/// <summary>
1213
/// The class analyzer.
1314
/// </summary>
1415
[DiagnosticAnalyzer(LanguageNames.CSharp)]
15-
public class NonPublicClassAnalyzer : BaseDiagnosticAnalyzer
16+
public class NonPublicClassAnalyzer : DiagnosticAnalyzer
1617
{
1718
private readonly ClassAnalyzerSettings _analyzerSettings;
1819

@@ -53,13 +54,13 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context)
5354
{
5455
return;
5556
}
56-
var settings = context.BuildSettings(StaticSettings);
57+
var settings = ServiceLocator.SettingService.BuildSettings(context);
5758

5859
if (settings.IsEnabledForPublicMembersOnly)
5960
{
6061
return;
6162
}
62-
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
63+
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
6364
if (excludeAnanlyzer)
6465
{
6566
return;

CodeDocumentor/Analyzers/Constructors/ConstructorAnalyzer.cs renamed to CodeDocumentor.Analyzers/Analyzers/Constructors/ConstructorAnalyzer.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
using System.Collections.Immutable;
2-
using CodeDocumentor.Builders;
3-
using CodeDocumentor.Helper;
2+
using CodeDocumentor.Analyzers.Builders;
3+
using CodeDocumentor.Analyzers.Helper;
4+
using CodeDocumentor.Analyzers.Locators;
45
using Microsoft.CodeAnalysis;
56
using Microsoft.CodeAnalysis.CSharp;
67
using Microsoft.CodeAnalysis.CSharp.Syntax;
78
using Microsoft.CodeAnalysis.Diagnostics;
89

9-
namespace CodeDocumentor
10+
namespace CodeDocumentor.Analyzers.Constructors
1011
{
1112
/// <summary>
1213
/// The constructor analyzer.
1314
/// </summary>
1415
[DiagnosticAnalyzer(LanguageNames.CSharp)]
15-
public class ConstructorAnalyzer : BaseDiagnosticAnalyzer
16+
public class ConstructorAnalyzer : DiagnosticAnalyzer
1617
{
1718
private readonly ConstructorAnalyzerSettings _analyzerSettings;
1819

1920
public ConstructorAnalyzer()
2021
{
21-
_analyzerSettings = new ConstructorAnalyzerSettings();
22+
_analyzerSettings = new ConstructorAnalyzerSettings();
2223
}
2324
/// <summary>
2425
/// Gets the supported diagnostics.
@@ -46,7 +47,7 @@ public override void Initialize(AnalysisContext context)
4647
/// Analyzes node.
4748
/// </summary>
4849
/// <param name="context"> The context. </param>
49-
internal void AnalyzeNode(SyntaxNodeAnalysisContext context)
50+
public void AnalyzeNode(SyntaxNodeAnalysisContext context)
5051
{
5152
if (!(context.Node is ConstructorDeclarationSyntax node))
5253
{
@@ -56,12 +57,12 @@ internal void AnalyzeNode(SyntaxNodeAnalysisContext context)
5657
{
5758
return;
5859
}
59-
var settings = context.BuildSettings(StaticSettings);
60+
var settings = ServiceLocator.SettingService.BuildSettings(context);
6061
if (settings.IsEnabledForPublicMembersOnly && PrivateMemberVerifier.IsPrivateMember(node))
6162
{
6263
return;
6364
}
64-
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
65+
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
6566
if (excludeAnanlyzer)
6667
{
6768
return;

CodeDocumentor/Analyzers/Constructors/ConstructorAnalyzerSettings.cs renamed to CodeDocumentor.Analyzers/Analyzers/Constructors/ConstructorAnalyzerSettings.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
using CodeDocumentor.Analyzers;
21
using CodeDocumentor.Common;
32
using CodeDocumentor.Common.Interfaces;
43
using Microsoft.CodeAnalysis;
54

6-
namespace CodeDocumentor
5+
namespace CodeDocumentor.Analyzers
76
{
8-
internal class ConstructorAnalyzerSettings: BaseAnalyzerSettings
7+
public class ConstructorAnalyzerSettings : BaseAnalyzerSettings
98
{
109
/// <summary>
1110
/// The diagnostic id.
1211
/// </summary>
13-
internal const string DiagnosticId = Constants.DiagnosticIds.CONSTRUCTOR_DIAGNOSTIC_ID;
12+
public const string DiagnosticId = Constants.DiagnosticIds.CONSTRUCTOR_DIAGNOSTIC_ID;
1413

1514
/// <summary>
1615
/// The message format.
1716
/// </summary>
18-
internal const string MessageFormat = Title;
17+
public const string MessageFormat = Title;
1918

2019
/// <summary>
2120
/// The title.
2221
/// </summary>
23-
internal const string Title = "The constructor must have a documentation header.";
24-
25-
internal DiagnosticDescriptor GetSupportedDiagnosticRule()
22+
public const string Title = "The constructor must have a documentation header.";
23+
24+
public DiagnosticDescriptor GetSupportedDiagnosticRule()
2625
{
2726
return new DiagnosticDescriptor(DiagnosticId, Title,
2827
MessageFormat, Category,
@@ -31,7 +30,7 @@ internal DiagnosticDescriptor GetSupportedDiagnosticRule()
3130
}
3231

3332

34-
internal DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
33+
public DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
3534
{
3635
return new DiagnosticDescriptor(DiagnosticId, Title,
3736
MessageFormat, Category,

CodeDocumentor/Analyzers/Constructors/NonPublicConstructorAnalyzer.cs renamed to CodeDocumentor.Analyzers/Analyzers/Constructors/NonPublicConstructorAnalyzer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
using System.Collections.Immutable;
2-
using CodeDocumentor.Builders;
3-
using CodeDocumentor.Helper;
2+
using CodeDocumentor.Analyzers.Builders;
3+
using CodeDocumentor.Analyzers.Helper;
4+
using CodeDocumentor.Analyzers.Locators;
45
using Microsoft.CodeAnalysis;
56
using Microsoft.CodeAnalysis.CSharp;
67
using Microsoft.CodeAnalysis.CSharp.Syntax;
78
using Microsoft.CodeAnalysis.Diagnostics;
89

9-
namespace CodeDocumentor
10+
namespace CodeDocumentor.Analyzers.Constructors
1011
{
1112
[DiagnosticAnalyzer(LanguageNames.CSharp)]
12-
public class NonPublicConstructorAnalyzer : BaseDiagnosticAnalyzer
13+
public class NonPublicConstructorAnalyzer : DiagnosticAnalyzer
1314
{
1415
private readonly ConstructorAnalyzerSettings _analyzerSettings;
1516

@@ -50,12 +51,12 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context)
5051
{
5152
return;
5253
}
53-
var settings = context.BuildSettings(StaticSettings);
54+
var settings = ServiceLocator.SettingService.BuildSettings(context);
5455
if (settings.IsEnabledForPublicMembersOnly)
5556
{
5657
return;
5758
}
58-
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
59+
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
5960
if (excludeAnanlyzer)
6061
{
6162
return;

CodeDocumentor/Analyzers/Enums/EnumAnalyzer.cs renamed to CodeDocumentor.Analyzers/Analyzers/Enums/EnumAnalyzer.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
using System.Collections.Immutable;
2-
using CodeDocumentor.Builders;
3-
using CodeDocumentor.Helper;
2+
using CodeDocumentor.Analyzers.Builders;
3+
using CodeDocumentor.Analyzers.Locators;
44
using Microsoft.CodeAnalysis;
55
using Microsoft.CodeAnalysis.CSharp;
66
using Microsoft.CodeAnalysis.CSharp.Syntax;
77
using Microsoft.CodeAnalysis.Diagnostics;
88

9-
namespace CodeDocumentor
9+
namespace CodeDocumentor.Analyzers.Enums
1010
{
1111
/// <summary>
1212
/// The enum analyzer.
1313
/// </summary>
1414
[DiagnosticAnalyzer(LanguageNames.CSharp)]
15-
public class EnumAnalyzer : BaseDiagnosticAnalyzer
15+
public class EnumAnalyzer : DiagnosticAnalyzer
1616
{
1717
private readonly EnumAnalyzerSettings _analyzerSettings;
1818

@@ -40,18 +40,18 @@ public override void Initialize(AnalysisContext context)
4040
/// Analyzes node.
4141
/// </summary>
4242
/// <param name="context"> The context. </param>
43-
internal void AnalyzeNode(SyntaxNodeAnalysisContext context)
43+
public void AnalyzeNode(SyntaxNodeAnalysisContext context)
4444
{
4545
if (!(context.Node is EnumDeclarationSyntax node))
4646
{
4747
return;
4848
}
49-
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
49+
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
5050
if (excludeAnanlyzer)
5151
{
5252
return;
5353
}
54-
var settings = context.BuildSettings(StaticSettings);
54+
var settings = ServiceLocator.SettingService.BuildSettings(context);
5555
context.BuildDiagnostic(node, node.Identifier, (alreadyHasComment) => _analyzerSettings.GetRule(alreadyHasComment, settings));
5656
}
5757
}

0 commit comments

Comments
 (0)