Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
using CodeDocumentor.Analyzers.Locators;
using CodeDocumentor.Common;
using CodeDocumentor.Common.Helpers;
using CodeDocumentor.Common.Interfaces;
using CodeDocumentor.Locators;
using Microsoft.CodeAnalysis;

namespace CodeDocumentor.Analyzers
{
internal class BaseAnalyzerSettings
public class BaseAnalyzerSettings
{
/// <summary>
/// The category.
/// </summary>
internal const string Category = Constants.CATEGORY;
public const string Category = Constants.CATEGORY;

protected IEventLogger EventLogger = ServiceLocator.Logger;

internal DiagnosticSeverity LookupSeverity(string diagnosticId, ISettings settings)
public DiagnosticSeverity LookupSeverity(string diagnosticId, ISettings settings)
{
if (settings == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
using System.Collections.Immutable;
using CodeDocumentor.Builders;
using CodeDocumentor.Helper;
using CodeDocumentor.Analyzers.Builders;
using CodeDocumentor.Analyzers.Helper;
using CodeDocumentor.Analyzers.Locators;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace CodeDocumentor
namespace CodeDocumentor.Analyzers.Classes
{
/// <summary>
/// The class analyzer.
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ClassAnalyzer : BaseDiagnosticAnalyzer
public class ClassAnalyzer : DiagnosticAnalyzer
{
private readonly ClassAnalyzerSettings _analyzerSettings;

public ClassAnalyzer()
{
_analyzerSettings = new ClassAnalyzerSettings();
}

/// <summary>
/// Gets the supported diagnostics.
/// </summary>
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
{
get
{
var _analyzerSettings = new ClassAnalyzerSettings();
return ImmutableArray.Create(_analyzerSettings.GetSupportedDiagnosticRule());
}
}
Expand All @@ -47,7 +42,7 @@ public override void Initialize(AnalysisContext context)
/// Analyzes node.
/// </summary>
/// <param name="context"> The context. </param>
public void AnalyzeNode(SyntaxNodeAnalysisContext context)
private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
if (!(context.Node is ClassDeclarationSyntax node))
{
Expand All @@ -57,13 +52,13 @@ public void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
return;
}
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
if (excludeAnanlyzer)
{
return;
}
var settings = context.BuildSettings(StaticSettings);

var settings = ServiceLocator.SettingService.BuildSettings(context);
var _analyzerSettings = new ClassAnalyzerSettings();
context.BuildDiagnostic(node, node.Identifier, (alreadyHasComment) => _analyzerSettings.GetRule(alreadyHasComment, settings));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
using CodeDocumentor.Analyzers;
using CodeDocumentor.Common;
using CodeDocumentor.Common.Interfaces;
using Microsoft.CodeAnalysis;

namespace CodeDocumentor
namespace CodeDocumentor.Analyzers
{
internal class ClassAnalyzerSettings: BaseAnalyzerSettings
public class ClassAnalyzerSettings : BaseAnalyzerSettings
{
/// <summary>
/// The diagnostic id.
/// </summary>
internal const string DiagnosticId = Constants.DiagnosticIds.CLASS_DIAGNOSTIC_ID;
public const string DiagnosticId = Constants.DiagnosticIds.CLASS_DIAGNOSTIC_ID;

/// <summary>
/// The message format.
/// </summary>
internal const string MessageFormat = Title;
public const string MessageFormat = Title;

/// <summary>
/// The title.
/// </summary>
internal const string Title = "The class must have a documentation header.";
public const string Title = "The class must have a documentation header.";

internal DiagnosticDescriptor GetSupportedDiagnosticRule()
public DiagnosticDescriptor GetSupportedDiagnosticRule()
{
return new DiagnosticDescriptor(DiagnosticId, Title,
MessageFormat, Category,
DiagnosticSeverity.Info,
true);
}

internal DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
public DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
{
return new DiagnosticDescriptor(DiagnosticId, Title,
MessageFormat, Category,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using System.Collections.Immutable;
using CodeDocumentor.Builders;
using CodeDocumentor.Helper;
using CodeDocumentor.Analyzers.Builders;
using CodeDocumentor.Analyzers.Helper;
using CodeDocumentor.Analyzers.Locators;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace CodeDocumentor
namespace CodeDocumentor.Analyzers.Classes
{
/// <summary>
/// The class analyzer.
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class NonPublicClassAnalyzer : BaseDiagnosticAnalyzer
public class NonPublicClassAnalyzer : DiagnosticAnalyzer
{
private readonly ClassAnalyzerSettings _analyzerSettings;

Expand Down Expand Up @@ -53,13 +54,13 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
return;
}
var settings = context.BuildSettings(StaticSettings);
var settings = ServiceLocator.SettingService.BuildSettings(context);

if (settings.IsEnabledForPublicMembersOnly)
{
return;
}
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
if (excludeAnanlyzer)
{
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
using System.Collections.Immutable;
using CodeDocumentor.Builders;
using CodeDocumentor.Helper;
using CodeDocumentor.Analyzers.Builders;
using CodeDocumentor.Analyzers.Helper;
using CodeDocumentor.Analyzers.Locators;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace CodeDocumentor
namespace CodeDocumentor.Analyzers.Constructors
{
/// <summary>
/// The constructor analyzer.
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ConstructorAnalyzer : BaseDiagnosticAnalyzer
public class ConstructorAnalyzer : DiagnosticAnalyzer
{
private readonly ConstructorAnalyzerSettings _analyzerSettings;

public ConstructorAnalyzer()
{
_analyzerSettings = new ConstructorAnalyzerSettings();
_analyzerSettings = new ConstructorAnalyzerSettings();
}
/// <summary>
/// Gets the supported diagnostics.
Expand Down Expand Up @@ -46,7 +47,7 @@ public override void Initialize(AnalysisContext context)
/// Analyzes node.
/// </summary>
/// <param name="context"> The context. </param>
internal void AnalyzeNode(SyntaxNodeAnalysisContext context)
public void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
if (!(context.Node is ConstructorDeclarationSyntax node))
{
Expand All @@ -56,12 +57,12 @@ internal void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
return;
}
var settings = context.BuildSettings(StaticSettings);
var settings = ServiceLocator.SettingService.BuildSettings(context);
if (settings.IsEnabledForPublicMembersOnly && PrivateMemberVerifier.IsPrivateMember(node))
{
return;
}
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
if (excludeAnanlyzer)
{
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
using CodeDocumentor.Analyzers;
using CodeDocumentor.Common;
using CodeDocumentor.Common.Interfaces;
using Microsoft.CodeAnalysis;

namespace CodeDocumentor
namespace CodeDocumentor.Analyzers
{
internal class ConstructorAnalyzerSettings: BaseAnalyzerSettings
public class ConstructorAnalyzerSettings : BaseAnalyzerSettings
{
/// <summary>
/// The diagnostic id.
/// </summary>
internal const string DiagnosticId = Constants.DiagnosticIds.CONSTRUCTOR_DIAGNOSTIC_ID;
public const string DiagnosticId = Constants.DiagnosticIds.CONSTRUCTOR_DIAGNOSTIC_ID;

/// <summary>
/// The message format.
/// </summary>
internal const string MessageFormat = Title;
public const string MessageFormat = Title;

/// <summary>
/// The title.
/// </summary>
internal const string Title = "The constructor must have a documentation header.";
internal DiagnosticDescriptor GetSupportedDiagnosticRule()
public const string Title = "The constructor must have a documentation header.";

public DiagnosticDescriptor GetSupportedDiagnosticRule()
{
return new DiagnosticDescriptor(DiagnosticId, Title,
MessageFormat, Category,
Expand All @@ -31,7 +30,7 @@ internal DiagnosticDescriptor GetSupportedDiagnosticRule()
}


internal DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
public DiagnosticDescriptor GetRule(bool hideDiagnosticSeverity, ISettings settings)
{
return new DiagnosticDescriptor(DiagnosticId, Title,
MessageFormat, Category,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System.Collections.Immutable;
using CodeDocumentor.Builders;
using CodeDocumentor.Helper;
using CodeDocumentor.Analyzers.Builders;
using CodeDocumentor.Analyzers.Helper;
using CodeDocumentor.Analyzers.Locators;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace CodeDocumentor
namespace CodeDocumentor.Analyzers.Constructors
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class NonPublicConstructorAnalyzer : BaseDiagnosticAnalyzer
public class NonPublicConstructorAnalyzer : DiagnosticAnalyzer
{
private readonly ConstructorAnalyzerSettings _analyzerSettings;

Expand Down Expand Up @@ -50,12 +51,12 @@ private void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
return;
}
var settings = context.BuildSettings(StaticSettings);
var settings = ServiceLocator.SettingService.BuildSettings(context);
if (settings.IsEnabledForPublicMembersOnly)
{
return;
}
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
if (excludeAnanlyzer)
{
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System.Collections.Immutable;
using CodeDocumentor.Builders;
using CodeDocumentor.Helper;
using CodeDocumentor.Analyzers.Builders;
using CodeDocumentor.Analyzers.Locators;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;

namespace CodeDocumentor
namespace CodeDocumentor.Analyzers.Enums
{
/// <summary>
/// The enum analyzer.
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class EnumAnalyzer : BaseDiagnosticAnalyzer
public class EnumAnalyzer : DiagnosticAnalyzer
{
private readonly EnumAnalyzerSettings _analyzerSettings;

Expand Down Expand Up @@ -40,18 +40,18 @@ public override void Initialize(AnalysisContext context)
/// Analyzes node.
/// </summary>
/// <param name="context"> The context. </param>
internal void AnalyzeNode(SyntaxNodeAnalysisContext context)
public void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
if (!(context.Node is EnumDeclarationSyntax node))
{
return;
}
var excludeAnanlyzer = DocumentationHeaderHelper.HasAnalyzerExclusion(node);
var excludeAnanlyzer = ServiceLocator.DocumentationHeaderHelper.HasAnalyzerExclusion(node);
if (excludeAnanlyzer)
{
return;
}
var settings = context.BuildSettings(StaticSettings);
var settings = ServiceLocator.SettingService.BuildSettings(context);
context.BuildDiagnostic(node, node.Identifier, (alreadyHasComment) => _analyzerSettings.GetRule(alreadyHasComment, settings));
}
}
Expand Down
Loading