Skip to content

Commit a87a29b

Browse files
Upgrade solution to C# 10 and .NET 6
1 parent ab5de81 commit a87a29b

Some content is hidden

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

57 files changed

+2746
-2802
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ trim_trailing_whitespace = false
3030
end_of_line = lf
3131

3232
[*.cs]
33+
# Prefer file scoped namespace declarations
34+
csharp_style_namespace_declarations = file_scoped:warning
35+
3336
# Sort using and Import directives with System.* appearing first
3437
dotnet_sort_system_directives_first = true
3538
dotnet_separate_import_directive_groups = false

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ jobs:
3939

4040
- name: Setup .NET SDK
4141
uses: actions/setup-dotnet@v1
42-
with:
43-
dotnet-version: 6.0.101
4442

4543
- name: Build
4644
shell: bash

.github/workflows/publish.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ jobs:
4545

4646
- name: Setup .NET SDK
4747
uses: actions/setup-dotnet@v1
48-
with:
49-
dotnet-version: 6.0.101
5048

5149
- name: Build
5250
shell: bash
@@ -75,8 +73,6 @@ jobs:
7573

7674
- name: Setup .NET SDK
7775
uses: actions/setup-dotnet@v1
78-
with:
79-
dotnet-version: 6.0.101
8076

8177
- name: Publish
8278
shell: bash

dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "2.0.0",
6+
"version": "2.2.0",
77
"commands": [
88
"dotnet-cake"
99
]

examples/Demo/Program.cs

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
11
using Errata;
22
using Spectre.Console;
33

4-
namespace Example
4+
namespace Example;
5+
6+
public static class Program
57
{
6-
public static class Program
8+
public static void Main()
79
{
8-
public static void Main()
9-
{
10-
// Create a new report
11-
var report = new Report(
12-
new EmbeddedResourceRepository(
13-
typeof(Program).Assembly));
10+
// Create a new report
11+
var report = new Report(
12+
new EmbeddedResourceRepository(
13+
typeof(Program).Assembly));
1414

15-
// C#
16-
report.AddDiagnostic(
17-
Diagnostic.Error("Operator '/' cannot be applied to operands of type 'string' and 'int'")
18-
.WithCode("CS0019")
19-
.WithNote("Try changing the type")
20-
.WithLabel(new Label("Demo/Files/Program.cs", new Location(15, 23), "This is of type 'int'")
21-
.WithLength(3)
22-
.WithPriority(1)
23-
.WithColor(Color.Yellow))
24-
.WithLabel(new Label("Demo/Files/Program.cs", new Location(15, 27), "Division is not possible")
25-
.WithPriority(3)
26-
.WithColor(Color.Red))
27-
.WithLabel(new Label("Demo/Files/Program.cs", new Location(15, 29), "This is of type 'string'")
28-
.WithLength(3)
29-
.WithPriority(2)
30-
.WithColor(Color.Blue)));
15+
// C#
16+
report.AddDiagnostic(
17+
Diagnostic.Error("Operator '/' cannot be applied to operands of type 'string' and 'int'")
18+
.WithCode("CS0019")
19+
.WithNote("Try changing the type")
20+
.WithLabel(new Label("Demo/Files/Program.cs", new Location(15, 23), "This is of type 'int'")
21+
.WithLength(3)
22+
.WithPriority(1)
23+
.WithColor(Color.Yellow))
24+
.WithLabel(new Label("Demo/Files/Program.cs", new Location(15, 27), "Division is not possible")
25+
.WithPriority(3)
26+
.WithColor(Color.Red))
27+
.WithLabel(new Label("Demo/Files/Program.cs", new Location(15, 29), "This is of type 'string'")
28+
.WithLength(3)
29+
.WithPriority(2)
30+
.WithColor(Color.Blue)));
3131

32-
report.AddDiagnostic(
33-
Diagnostic.Info("Fix formatting")
34-
.WithCode("IDE0055"))
35-
.WithLabel(new Label("Demo/Files/Program.cs", 174..176, "Code should not contain trailing whitespace")
36-
.WithColor(Color.Blue));
32+
report.AddDiagnostic(
33+
Diagnostic.Info("Fix formatting")
34+
.WithCode("IDE0055"))
35+
.WithLabel(new Label("Demo/Files/Program.cs", 174..176, "Code should not contain trailing whitespace")
36+
.WithColor(Color.Blue));
3737

38-
// Markdown
39-
report.AddDiagnostic(
40-
Diagnostic.Error("There were markdown errors")
41-
.WithCode("MARKDOWN001")
42-
.WithLabel(new Label("Demo/Files/Example.md", 24..27, "Did you mean 'just'?")
43-
.WithColor(Color.Yellow))
44-
.WithLabel(new Label("Demo/Files/Example.md", 31..41, "Invalid markdown")
45-
.WithColor(Color.Red))
46-
.WithLabel(new Label("Demo/Files/Example.md", 251..270, "Did you mean 'Yabba dabba doo'?")
47-
.WithColor(Color.Yellow)));
38+
// Markdown
39+
report.AddDiagnostic(
40+
Diagnostic.Error("There were markdown errors")
41+
.WithCode("MARKDOWN001")
42+
.WithLabel(new Label("Demo/Files/Example.md", 24..27, "Did you mean 'just'?")
43+
.WithColor(Color.Yellow))
44+
.WithLabel(new Label("Demo/Files/Example.md", 31..41, "Invalid markdown")
45+
.WithColor(Color.Red))
46+
.WithLabel(new Label("Demo/Files/Example.md", 251..270, "Did you mean 'Yabba dabba doo'?")
47+
.WithColor(Color.Yellow)));
4848

49-
// C++
50-
report.AddDiagnostic(
51-
Diagnostic.Error("Compiler error")
52-
.WithCode("C2084")
53-
.WithNote("Overloaded member not found")
54-
.WithLabel(new Label("Demo/Files/Foo.cpp", 22..37, " 'void Foo::bar(float)': overloaded member function not found in 'Foo'")
55-
.WithColor(Color.Red)
56-
.WithNote("See declaration of 'Foo' in Foo.h"))
57-
.WithLabel(new Label("Demo/Files/Foo.h", 24..38, "See declaration of 'Foo'")
58-
.WithColor(Color.Blue)));
49+
// C++
50+
report.AddDiagnostic(
51+
Diagnostic.Error("Compiler error")
52+
.WithCode("C2084")
53+
.WithNote("Overloaded member not found")
54+
.WithLabel(new Label("Demo/Files/Foo.cpp", 22..37, " 'void Foo::bar(float)': overloaded member function not found in 'Foo'")
55+
.WithColor(Color.Red)
56+
.WithNote("See declaration of 'Foo' in Foo.h"))
57+
.WithLabel(new Label("Demo/Files/Foo.h", 24..38, "See declaration of 'Foo'")
58+
.WithColor(Color.Blue)));
5959

60-
// Render the report
61-
report.Render(AnsiConsole.Console);
62-
}
60+
// Render the report
61+
report.Render(AnsiConsole.Console);
6362
}
6463
}

examples/Shared/EmbeddedResourceReader.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22
using System.IO;
33
using System.Reflection;
44

5-
namespace Example
5+
namespace Example;
6+
7+
public static class EmbeddedResourceReader
68
{
7-
public static class EmbeddedResourceReader
9+
public static Stream LoadResourceStream(Assembly assembly, string resourceName)
810
{
9-
public static Stream LoadResourceStream(Assembly assembly, string resourceName)
11+
if (assembly is null)
1012
{
11-
if (assembly is null)
12-
{
13-
throw new ArgumentNullException(nameof(assembly));
14-
}
15-
16-
if (resourceName is null)
17-
{
18-
throw new ArgumentNullException(nameof(resourceName));
19-
}
13+
throw new ArgumentNullException(nameof(assembly));
14+
}
2015

21-
resourceName = resourceName.Replace("/", ".");
22-
return assembly.GetManifestResourceStream(resourceName);
16+
if (resourceName is null)
17+
{
18+
throw new ArgumentNullException(nameof(resourceName));
2319
}
20+
21+
resourceName = resourceName.Replace("/", ".");
22+
return assembly.GetManifestResourceStream(resourceName);
2423
}
2524
}

examples/Shared/EmbeddedResourceRepository.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,31 @@
55
using System.Reflection;
66
using Errata;
77

8-
namespace Example
8+
namespace Example;
9+
10+
public sealed class EmbeddedResourceRepository : ISourceRepository
911
{
10-
public sealed class EmbeddedResourceRepository : ISourceRepository
11-
{
12-
private readonly Dictionary<string, Source> _lookup;
13-
private readonly Assembly _assembly;
12+
private readonly Dictionary<string, Source> _lookup;
13+
private readonly Assembly _assembly;
1414

15-
public EmbeddedResourceRepository(Assembly assembly)
16-
{
17-
_lookup = new Dictionary<string, Source>(StringComparer.OrdinalIgnoreCase);
18-
_assembly = assembly;
19-
}
15+
public EmbeddedResourceRepository(Assembly assembly)
16+
{
17+
_lookup = new Dictionary<string, Source>(StringComparer.OrdinalIgnoreCase);
18+
_assembly = assembly;
19+
}
2020

21-
public bool TryGet(string id, [NotNullWhen(true)] out Source source)
21+
public bool TryGet(string id, [NotNullWhen(true)] out Source source)
22+
{
23+
if (!_lookup.TryGetValue(id, out source))
2224
{
23-
if (!_lookup.TryGetValue(id, out source))
25+
using (var stream = EmbeddedResourceReader.LoadResourceStream(_assembly, id))
26+
using (var reader = new StreamReader(stream))
2427
{
25-
using (var stream = EmbeddedResourceReader.LoadResourceStream(_assembly, id))
26-
using (var reader = new StreamReader(stream))
27-
{
28-
source = new Source(id, reader.ReadToEnd().Replace("\r\n", "\n"));
29-
_lookup[id] = source;
30-
}
28+
source = new Source(id, reader.ReadToEnd().Replace("\r\n", "\n"));
29+
_lookup[id] = source;
3130
}
32-
33-
return true;
3431
}
32+
33+
return true;
3534
}
3635
}

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"projects": [ "src" ],
33
"sdk": {
4-
"version": "6.0.101",
4+
"version": "6.0.300",
55
"rollForward": "latestFeature"
66
}
77
}

src/Errata.Tests/CharacterSetTests.cs

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,55 @@
11
using Shouldly;
22
using Xunit;
33

4-
namespace Errata.Tests
4+
namespace Errata.Tests;
5+
6+
public sealed class CharacterSetTests
57
{
6-
public sealed class CharacterSetTests
8+
public sealed class Ansi
79
{
8-
public sealed class Ansi
10+
[Theory]
11+
[InlineData(Character.Anchor, '┬')]
12+
[InlineData(Character.AnchorHorizontalLine, '─')]
13+
[InlineData(Character.AnchorVerticalLine, '│')]
14+
[InlineData(Character.BottomLeftCornerHard, '└')]
15+
[InlineData(Character.BottomLeftCornerRound, '╰')]
16+
[InlineData(Character.Colon, ':')]
17+
[InlineData(Character.Dot, '·')]
18+
[InlineData(Character.HorizontalLine, '─')]
19+
[InlineData(Character.LeftConnector, '├')]
20+
[InlineData(Character.TopLeftCornerHard, '┌')]
21+
[InlineData(Character.VerticalLine, '│')]
22+
public void Should_Return_Expected_Characters(Character character, char expected)
923
{
10-
[Theory]
11-
[InlineData(Character.Anchor, '┬')]
12-
[InlineData(Character.AnchorHorizontalLine, '─')]
13-
[InlineData(Character.AnchorVerticalLine, '│')]
14-
[InlineData(Character.BottomLeftCornerHard, '└')]
15-
[InlineData(Character.BottomLeftCornerRound, '╰')]
16-
[InlineData(Character.Colon, ':')]
17-
[InlineData(Character.Dot, '·')]
18-
[InlineData(Character.HorizontalLine, '─')]
19-
[InlineData(Character.LeftConnector, '├')]
20-
[InlineData(Character.TopLeftCornerHard, '┌')]
21-
[InlineData(Character.VerticalLine, '│')]
22-
public void Should_Return_Expected_Characters(Character character, char expected)
23-
{
24-
// Given, When
25-
var result = CharacterSet.Unicode.Get(character);
24+
// Given, When
25+
var result = CharacterSet.Unicode.Get(character);
2626

27-
// Then
28-
result.ShouldBe(expected);
29-
}
27+
// Then
28+
result.ShouldBe(expected);
3029
}
30+
}
3131

32-
public sealed class Ascii
32+
public sealed class Ascii
33+
{
34+
[Theory]
35+
[InlineData(Character.Anchor, '┬')]
36+
[InlineData(Character.AnchorHorizontalLine, '─')]
37+
[InlineData(Character.AnchorVerticalLine, '│')]
38+
[InlineData(Character.BottomLeftCornerHard, '└')]
39+
[InlineData(Character.BottomLeftCornerRound, '└')]
40+
[InlineData(Character.Colon, ':')]
41+
[InlineData(Character.Dot, '·')]
42+
[InlineData(Character.HorizontalLine, '─')]
43+
[InlineData(Character.LeftConnector, '├')]
44+
[InlineData(Character.TopLeftCornerHard, '┌')]
45+
[InlineData(Character.VerticalLine, '│')]
46+
public void Should_Return_Expected_Characters(Character character, char expected)
3347
{
34-
[Theory]
35-
[InlineData(Character.Anchor, '┬')]
36-
[InlineData(Character.AnchorHorizontalLine, '─')]
37-
[InlineData(Character.AnchorVerticalLine, '│')]
38-
[InlineData(Character.BottomLeftCornerHard, '└')]
39-
[InlineData(Character.BottomLeftCornerRound, '└')]
40-
[InlineData(Character.Colon, ':')]
41-
[InlineData(Character.Dot, '·')]
42-
[InlineData(Character.HorizontalLine, '─')]
43-
[InlineData(Character.LeftConnector, '├')]
44-
[InlineData(Character.TopLeftCornerHard, '┌')]
45-
[InlineData(Character.VerticalLine, '│')]
46-
public void Should_Return_Expected_Characters(Character character, char expected)
47-
{
48-
// Given, When
49-
var result = CharacterSet.Ascii.Get(character);
48+
// Given, When
49+
var result = CharacterSet.Ascii.Get(character);
5050

51-
// Then
52-
result.ShouldBe(expected);
53-
}
51+
// Then
52+
result.ShouldBe(expected);
5453
}
5554
}
5655
}

src/Errata.Tests/Errata.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ItemGroup>
2424
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
2525
<PackageReference Include="Shouldly" Version="4.0.3" />
26-
<PackageReference Include="Spectre.Console.Testing" Version="0.43.0" />
26+
<PackageReference Include="Spectre.Console.Testing" Version="0.44.0" />
2727
<PackageReference Include="Spectre.Verify.Extensions" Version="0.5.0" />
2828
<PackageReference Include="Verify.Xunit" Version="16.1.1" />
2929
<PackageReference Include="xunit" Version="2.4.1" />

0 commit comments

Comments
 (0)