Skip to content

Commit

Permalink
Bump version to 2.0.0 (#183)
Browse files Browse the repository at this point in the history
- Fix documents
  • Loading branch information
maroontress-tomohisa committed May 17, 2024
1 parent 2e11767 commit 7b94ec2
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 40 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
xsltproc transform.xslt StyleChecker/StyleChecker.Test/StyleChecker.Test.csproj > 2.xml
cp 1.xml StyleChecker/StyleChecker/StyleChecker.csproj
cp 2.xml StyleChecker/StyleChecker.Test/StyleChecker.Test.csproj
dotnet add StyleChecker/StyleChecker/StyleChecker.csproj package StyleChecker --version 2.0.0-alpha
dotnet add StyleChecker/StyleChecker.Test/StyleChecker.Test.csproj package StyleChecker --version 2.0.0-alpha
dotnet add StyleChecker/StyleChecker/StyleChecker.csproj package StyleChecker --version ${{ env.STYLECHECKER_VERSION }}
dotnet add StyleChecker/StyleChecker.Test/StyleChecker.Test.csproj package StyleChecker --version ${{ env.STYLECHECKER_VERSION }}
dotnet build --configuration Release
env:
STYLECHECKER_VERSION: 2.0.0-beta
39 changes: 21 additions & 18 deletions StyleChecker/StyleChecker.Test/Framework/BeliefExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ private static DiagnosticDescriptor NewRule()

private void AnalyzeSyntaxTree(SyntaxTreeAnalysisContext context)
{
static int GetLine(SyntaxTrivia trivia)
=> trivia.GetLocation()
.GetLineSpan()
.StartLinePosition
.Line;

static int GetCount(string s, char c)
{
var k = 0;
var n = s.Length;
while (k < n && s[k] == c)
{
++k;
}
return k;
}

static KeyValuePair<string, string?> ToPair(string key, string? value)
=> KeyValuePair.Create(key, value);

const string prefix = "//@";
var root = context.Tree.GetCompilationUnitRoot(
context.CancellationToken);
Expand All @@ -60,12 +80,6 @@ private void AnalyzeSyntaxTree(SyntaxTreeAnalysisContext context)
.Where(p => p.Comment.StartsWith(prefix, StringComparison.Ordinal))
.ToList();

static int GetLine(SyntaxTrivia trivia)
=> trivia.GetLocation()
.GetLineSpan()
.StartLinePosition
.Line;

List<(SyntaxTrivia, string, int)> ConcatLines()
{
var lines = expectations.Select(e => GetLine(e.Trivia))
Expand All @@ -89,17 +103,6 @@ static int GetLine(SyntaxTrivia trivia)
.ToList();
}

static int GetCount(string s, char c)
{
var k = 0;
var n = s.Length;
while (k < n && s[k] == c)
{
++k;
}
return k;
}

foreach (var (trivia, comment, line) in ConcatLines())
{
var where = trivia.GetLocation();
Expand Down Expand Up @@ -165,7 +168,7 @@ static int GetCount(string s, char c)
}

var parameters = ImmutableDictionary.CreateRange(
[KeyValuePair.Create("delta", delta.ToString())]);
[ToPair("delta", delta.ToString())]);
var diagnostic = Diagnostic.Create(
Rule, location, parameters, body);
context.ReportDiagnostic(diagnostic);
Expand Down
2 changes: 1 addition & 1 deletion StyleChecker/StyleChecker/StyleChecker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Copyright>Copyright (c) 2018 Maroontress Fast Software</Copyright>
<PackageTags>csharp, visual-studio, roslyn, analyzer, roslyn-analyzer, roslyn-codefix, stylechecker</PackageTags>
<NoPackageAnalysis>true</NoPackageAnalysis>
<Version>2.0.0-beta</Version>
<Version>2.0.0</Version>
<RepositoryType />
<Company>Maroontress Fast Software</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
12 changes: 6 additions & 6 deletions doc/rules/NoSpaceAfterBrace.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ an opening bracket (&lsquo;`[`&rsquo;), a comma (&lsquo;`,`&rsquo;), a period
(&lsquo;`.`&rsquo;), an exclamation mark (&lsquo;`!`&rsquo;), a question mark
(&lsquo;`?`&rsquo;), or a semicolon (&lsquo;`;`&rsquo;).

Note that this analyzer and [NoSpaceBeforeBrace](NoSpaceBeforeBrace.md)
analyzer are designed to use them together and replace [SA1012][sa1012] and
[SA1013][sa1013] with them, allowing us to write empty braces
(&ldquo;`{}`&rdquo;) as follows:
Note that this analyzer and the [NoSpaceBeforeBrace][] analyzer are intended to
be used together and replace [SA1012][] and [SA1013][] with them, allowing us to
write empty braces (`{}`) as follows:

```csharp
Action doNothing = () => {};
Expand Down Expand Up @@ -73,9 +72,10 @@ if (array is { Length: 0 } z)
}
```

[sa1012]:
[SA1012]:
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1012.md
[sa1013]:
[SA1013]:
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1013.md
[fig-NoSpaceAfterBrace]:
https://maroontress.github.io/StyleChecker/images/NoSpaceAfterBrace.png
[NoSpaceBeforeBrace]: NoSpaceBeforeBrace.md
9 changes: 5 additions & 4 deletions doc/rules/NoSpaceAfterSemicolon.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ for (;;)
}
```

Note that it is intended that this analyzer and
[SpaceBeforeSemicolon](SpaceBeforeSemicolon.md)
analyzer are used together, and [SA1002][sa1002] is replaced with them.
Note that this analyzer and the [SpaceBeforeSemicolon][] analyzer are intended
to be used together and replace [SA1002][] with them, allowing us to write an
infinite `for` loop with `for (;;)`.

## Code fix

Expand Down Expand Up @@ -70,7 +70,8 @@ public void Method()
}
```

[sa1002]:
[SA1002]:
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1002.md
[fig-NoSpaceAfterSemicolon]:
https://maroontress.github.io/StyleChecker/images/NoSpaceAfterSemicolon.png
[SpaceBeforeSemicolon]: SpaceBeforeSemicolon.md
8 changes: 4 additions & 4 deletions doc/rules/NoSpaceBeforeBrace.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ line must be preceded by a single space or an opening parenthesis
A closing brace (&lsquo;`}`&rsquo;) that is not the first character on the line
must be preceded by a single space or an opening brace (&lsquo;`{`&rsquo;).

Note that this analyzer and [NoSpaceAfterBrace](NoSpaceAfterBrace.md) analyzer
are designed to use them together and replace [SA1012][sa1012] and
[SA1013][sa1013] with them, allowing us to write empty braces
(&ldquo;`{}`&rdquo;) as follows:
Note that this analyzer and the [NoSpaceAfterBrace][] analyzer are intended to
be used together and replace [SA1012][] and [SA1013][] with them, allowing us to
write empty braces (`{}`) as follows:

```csharp
Action doNothing = () => {};
Expand Down Expand Up @@ -77,3 +76,4 @@ if (array is { Length: 0 } z)
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1013.md
[fig-NoSpaceBeforeBrace]:
https://maroontress.github.io/StyleChecker/images/NoSpaceBeforeBrace.png
[NoSpaceAfterBrace]: NoSpaceAfterBrace.md
2 changes: 1 addition & 1 deletion doc/rules/SingleTypeParameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Warning
However, the following cases are excluded because renaming to `T` may cause a
compile error or change the meaning:

- If the type name is `T` and it has one type parameter
- The type name is `T` and it has one type parameter
- The type `T` is already contained in the type or member

## Code fix
Expand Down
9 changes: 5 additions & 4 deletions doc/rules/SpaceBeforeSemicolon.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Warning

In general, semicolons are not preceded by a space.

Note that it is intended that this analyzer and
[NoSpaceAfterSemicolon](NoSpaceAfterSemicolon.md)
analyzer are used together, and [SA1002][sa1002] is replaced with them.
Note that this analyzer and the [NoSpaceAfterSemicolon][] analyzer are intended
to be used together and replace [SA1002][] with them, allowing us to write an
infinite `for` loop with `for (;;)`.

## Code fix

Expand Down Expand Up @@ -66,7 +66,8 @@ public void Method()
}
```

[sa1002]:
[SA1002]:
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1002.md
[fig-SpaceBeforeSemicolon]:
https://maroontress.github.io/StyleChecker/images/SpaceBeforeSemicolon.png
[NoSpaceAfterSemicolon]: NoSpaceAfterSemicolon.md

0 comments on commit 7b94ec2

Please sign in to comment.