Skip to content

Commit 52e460a

Browse files
Update version 1.0.7. (#11)
* Add document of the StaticGenericClass analyzer.
1 parent a472512 commit 52e460a

5 files changed

Lines changed: 54 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ It is supposed to be used with StyleCop Analyzers.
1919
local variables.
2020
- Remove unnecessary using directives.
2121
- Use `T` as a type parameter name if the type parameter is single.
22+
- Move type parameters from the static class to its methods if possible.
2223

2324
## Configuration
2425

StyleChecker/StyleChecker.Vsix/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="StyleChecker.54813f7f-54ef-470a-ab56-833e37fbe4ec" Version="1.0.6" Language="en-US" Publisher="tomohisa"/>
4+
<Identity Id="StyleChecker.54813f7f-54ef-470a-ab56-833e37fbe4ec" Version="1.0.7" Language="en-US" Publisher="tomohisa"/>
55
<DisplayName>StyleChecker</DisplayName>
66
<Description xml:space="preserve">StyleChecker is yet another style checker for C#.</Description>
77
</Metadata>

StyleChecker/StyleChecker/StyleChecker.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard1.3</TargetFramework>
@@ -8,7 +8,7 @@
88

99
<PropertyGroup>
1010
<PackageId>StyleChecker</PackageId>
11-
<PackageVersion>1.0.6.0</PackageVersion>
11+
<PackageVersion>1.0.7.0</PackageVersion>
1212
<Authors>Tomohisa Tanaka</Authors>
1313
<PackageLicenseUrl></PackageLicenseUrl>
1414
<PackageProjectUrl>https://maroontress.github.io/StyleChecker/</PackageProjectUrl>
@@ -19,7 +19,7 @@
1919
<Copyright>Copyright (c) 2018 Maroontress Fast Software</Copyright>
2020
<PackageTags>StyleChecker, analyzers</PackageTags>
2121
<NoPackageAnalysis>true</NoPackageAnalysis>
22-
<Version>1.0.6.0</Version>
22+
<Version>1.0.7.0</Version>
2323
<RepositoryType />
2424
<Company>Maroontress Fast Software</Company>
2525
<LangVersion>7.3</LangVersion>

doc/rules/InvalidConfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Summary
44

5-
Validate the config file `StyleChecker.xml`.
5+
Validate the configuration file `StyleChecker.xml`.
66

77
## Description
88

doc/rules/StaticGenericClass.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# StaticGenericClass
2+
3+
## Summary
4+
5+
Move type parameters from the static class to its methods if possible.
6+
7+
## Description
8+
9+
Replace `Class<T>.Method()` with `Class.Method<T>()` so that the data type of
10+
the type parameter `T` can be inferred from the argument or return value.
11+
12+
## Code fix
13+
14+
The code fix provides an option moving the type parameters from the static
15+
class to its methods. _Note that the callers of the methods is not fixed
16+
with the code fix providers, so the callers have to be fixed manually._
17+
18+
## Example
19+
20+
### Diagnostic
21+
22+
```csharp
23+
/// <summary>Class Summary.</summary>
24+
/// <typeparam name="T">Type parameter.</typeparam>
25+
public static class Code<T> where T : class
26+
{
27+
/// <summary>Method summary.</summary>
28+
/// <param name="instance">Parameter.</param>
29+
public static void Method(T instance)
30+
{
31+
}
32+
}
33+
```
34+
35+
### Code fix
36+
37+
```csharp
38+
/// <summary>Class Summary.</summary>
39+
public static class Code
40+
{
41+
/// <summary>Method summary.</summary>
42+
/// <param name="instance">Parameter.</param>
43+
/// <typeparam name="T">Type parameter.</typeparam>
44+
public static void Method<T>(T instance) where T : class
45+
{
46+
}
47+
}
48+
```

0 commit comments

Comments
 (0)