-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add switch analyzer to the extension. * Add settings for analyzers shipped as the extension. * Update extension version. * Add documentation image. Add "how to configure" information to Readme
- Loading branch information
1 parent
954f722
commit 8f2f312
Showing
26 changed files
with
707 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard1.3</TargetFramework> | ||
<AssemblyName>CleanCode.NET.Common</AssemblyName> | ||
<RootNamespace>CleanCode.NET.Common</RootNamespace> | ||
<SignAssembly>true</SignAssembly> | ||
<DelaySign>false</DelaySign> | ||
<AssemblyOriginatorKeyFile>Signature.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
|
||
</Project> |
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,36 @@ | ||
using System; | ||
|
||
namespace CleanCode.NET.Common | ||
{ | ||
public class Settings | ||
{ | ||
private static Settings current = new Settings(); | ||
|
||
public static Settings Current => current; | ||
|
||
public bool IsInitialized { get; set; } | ||
|
||
public bool SwitchEnum { get; set; } | ||
|
||
public bool SwitchInterface { get; set; } | ||
|
||
public bool SwitchClass { get; set; } | ||
|
||
public bool ExceptionsNoCheck { get; set; } | ||
|
||
public bool ExceptionsRethrowSame { get; set; } | ||
|
||
public bool ExceptionsRwthrowWithoutInner { get; set; } | ||
|
||
public bool ConstructoNullCheck { get; set; } | ||
|
||
public bool NamedParameters { get; set; } | ||
|
||
/// <summary> | ||
/// If not initialized, then should process. Otherwise, use setting. | ||
/// </summary> | ||
/// <param name="getter">Setting getter.</param> | ||
/// <returns></returns> | ||
public bool ShouldProceed(Func<Settings, bool> getter) => getter.Invoke(this) || !IsInitialized; | ||
} | ||
} |
Binary file not shown.
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
Binary file not shown.
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,70 @@ | ||
using System.ComponentModel; | ||
using CleanCode.NET.Common; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace CleanCode.NET | ||
{ | ||
public class OptionPageGrid : DialogPage | ||
{ | ||
private const string Category = "Clean Code .NET"; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0001) Validate switch for enums")] | ||
public bool SwitchEnum { get; set; } = true; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0002) Validate switch for interfaces")] | ||
public bool SwitchInterface { get; set; } = true; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0003) Validate switch for classes")] | ||
public bool SwitchClass { get; set; } = true; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0011) Require constructors to have null checks for parameters")] | ||
public bool ConstructoNullCheck { get; set; } = true; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0021) Exceptions are not used in catch statement")] | ||
public bool ExceptionsNoCheck { get; set; } = true; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0022) Exceptions rethrow")] | ||
public bool ExceptionsRethrowSame { get; set; } = true; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0023) Exception rethrow without inner")] | ||
public bool ExceptionsRethrowWithoutInner { get; set; } = true; | ||
|
||
[Category(Category)] | ||
[DefaultValue(true)] | ||
[DisplayName("(CCN0041) Require to have parameter names")] | ||
public bool NamedParameters { get; set; } = true; | ||
|
||
protected override void OnApply(PageApplyEventArgs e) | ||
{ | ||
base.OnApply(e); | ||
ApplyToSettings(Settings.Current); | ||
} | ||
|
||
internal void ApplyToSettings(Settings settings) | ||
{ | ||
settings.SwitchEnum = SwitchEnum; | ||
settings.SwitchInterface= SwitchInterface; | ||
settings.SwitchClass = SwitchClass; | ||
settings.ExceptionsNoCheck = ExceptionsNoCheck; | ||
settings.ExceptionsRethrowSame = ExceptionsRethrowSame; | ||
settings.ExceptionsRwthrowWithoutInner = ExceptionsRethrowWithoutInner; | ||
settings.ConstructoNullCheck = ConstructoNullCheck; | ||
settings.NamedParameters = NamedParameters; | ||
settings.IsInitialized = true; | ||
} | ||
} | ||
} |
Oops, something went wrong.