Skip to content

Commit 3f06adb

Browse files
authored
Upgrade to .NET 9 (#20)
- file scoped ns everywhere - editorconfig: format entire sln - remove .net 7, add .net 9 TFMs - primary ctors and records where relevant - add support for Microsoft Test Platform (xunit-v3) - update gh actions +semver:major
1 parent 5e321e0 commit 3f06adb

37 files changed

+2115
-1925
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on: [ push, pull_request ]
44

55
jobs:
66
build:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
- name: Setup .NET
12-
uses: actions/setup-dotnet@v3
12+
uses: actions/setup-dotnet@v4
1313
with:
14-
dotnet-version: 8.0.x
14+
dotnet-version: 9.0.x
1515
- name: Restore dependencies
1616
run: dotnet restore source
1717
- name: Build

.github/workflows/Release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414
- name: Setup .NET
15-
uses: actions/setup-dotnet@v3
15+
uses: actions/setup-dotnet@v4
1616
with:
17-
dotnet-version: 8.0.x
17+
dotnet-version: 9.0.x
1818
- run: echo "ACTIONS_ALLOW_UNSECURE_COMMANDS=true" >> $GITHUB_ENV
1919
- name: Install GitVersion
2020
uses: gittools/actions/gitversion/setup@v0

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ NoCommonsNET
88

99
Port av NoCommons-biblioteket for .NET
1010

11-
* https://github.com/bekkopen/NoCommons
11+
* https://github.com/bekkopen/NoCommons
1212

13-
Sample apps can be found [in the samples repo](https://github.com/johnkors/NoCommonsNET.Samples)
13+
Sample apps can be found [in the samples repo](https://github.com/johnkors/NoCommonsNET.Samples)

source/.editorconfig

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Remove the line below if you want to inherit .editorconfig settings from higher directories
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
insert_final_newline = true
7+
8+
# C# files
9+
[*.cs]
10+
11+
#### Core EditorConfig Options ####
12+
13+
# Indentation and spacing
14+
indent_size = 4
15+
indent_style = space
16+
tab_width = 4
17+
18+
# New line preferences
19+
insert_final_newline = true
20+
trim_trailing_whitespace = true
21+
22+
23+
#### .NET Coding Conventions ####
24+
25+
# this. and Me. preferences
26+
dotnet_style_qualification_for_event = false:warning
27+
dotnet_style_qualification_for_field = false:warning
28+
dotnet_style_qualification_for_method = false:warning
29+
dotnet_style_qualification_for_property = false:warning
30+
31+
# Language keywords vs BCL types preferences
32+
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
33+
dotnet_style_predefined_type_for_member_access = true:silent
34+
35+
# Parentheses preferences
36+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
37+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
38+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
39+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
40+
41+
# Modifier preferences
42+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
43+
44+
# Expression-level preferences
45+
csharp_style_deconstructed_variable_declaration = true:suggestion
46+
csharp_style_inlined_variable_declaration = true:suggestion
47+
csharp_style_throw_expression = true:suggestion
48+
dotnet_style_coalesce_expression = true:suggestion
49+
dotnet_style_collection_initializer = true:suggestion
50+
dotnet_style_explicit_tuple_names = true:suggestion
51+
dotnet_style_null_propagation = true:suggestion
52+
dotnet_style_object_initializer = true:suggestion
53+
dotnet_style_prefer_auto_properties = true:silent
54+
dotnet_style_prefer_compound_assignment = true:suggestion
55+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
56+
dotnet_style_prefer_conditional_expression_over_return = true:silent
57+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
58+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
59+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
60+
61+
# Field preferences
62+
dotnet_style_readonly_field = true:suggestion
63+
64+
# Parameter preferences
65+
dotnet_code_quality_unused_parameters = all:suggestion
66+
67+
#### C# Coding Conventions ####
68+
69+
# var preferences
70+
csharp_style_var_elsewhere = false:silent
71+
csharp_style_var_for_built_in_types = false:silent
72+
csharp_style_var_when_type_is_apparent = false:silent
73+
74+
# Expression-bodied members
75+
csharp_style_expression_bodied_accessors = true:silent
76+
csharp_style_expression_bodied_constructors = false:silent
77+
csharp_style_expression_bodied_indexers = true:silent
78+
csharp_style_expression_bodied_lambdas = true:silent
79+
csharp_style_expression_bodied_local_functions = false:silent
80+
csharp_style_expression_bodied_methods = false:silent
81+
csharp_style_expression_bodied_operators = false:silent
82+
csharp_style_expression_bodied_properties = true:silent
83+
84+
# Pattern matching preferences
85+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
86+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
87+
88+
# Null-checking preferences
89+
csharp_style_conditional_delegate_call = true:suggestion
90+
91+
# Modifier preferences
92+
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async
93+
94+
# Code-block preferences
95+
csharp_prefer_braces = true:silent
96+
97+
# Expression-level preferences
98+
csharp_prefer_simple_default_expression = true:suggestion
99+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
100+
csharp_style_prefer_index_operator = true:suggestion
101+
csharp_style_prefer_range_operator = true:suggestion
102+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
103+
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
104+
105+
# C# 10
106+
csharp_style_namespace_declarations = file_scoped:error
107+
csharp_style_prefer_primary_constructors = true
108+
dotnet_diagnostic.IDE0290.severity = error
109+
110+
111+
#### C# Formatting Rules ####
112+
113+
# New line preferences
114+
csharp_new_line_before_catch = true
115+
csharp_new_line_before_else = true
116+
csharp_new_line_before_finally = true
117+
csharp_new_line_before_members_in_anonymous_types = true
118+
csharp_new_line_before_members_in_object_initializers = true
119+
csharp_new_line_before_open_brace = all
120+
csharp_new_line_between_query_expression_clauses = true
121+
122+
# Indentation preferences
123+
csharp_indent_block_contents = true
124+
csharp_indent_braces = false
125+
csharp_indent_case_contents = true
126+
csharp_indent_case_contents_when_block = true
127+
csharp_indent_labels = one_less_than_current
128+
csharp_indent_switch_labels = true
129+
130+
# Space preferences
131+
csharp_space_after_cast = false
132+
csharp_space_after_colon_in_inheritance_clause = true
133+
csharp_space_after_comma = true
134+
csharp_space_after_dot = false
135+
csharp_space_after_keywords_in_control_flow_statements = true
136+
csharp_space_after_semicolon_in_for_statement = true
137+
csharp_space_around_binary_operators = before_and_after
138+
csharp_space_around_declaration_statements = false
139+
csharp_space_before_colon_in_inheritance_clause = true
140+
csharp_space_before_comma = false
141+
csharp_space_before_dot = false
142+
csharp_space_before_open_square_brackets = false
143+
csharp_space_before_semicolon_in_for_statement = false
144+
csharp_space_between_empty_square_brackets = false
145+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
146+
csharp_space_between_method_call_name_and_opening_parenthesis = false
147+
csharp_space_between_method_call_parameter_list_parentheses = false
148+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
149+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
150+
csharp_space_between_method_declaration_parameter_list_parentheses = false
151+
csharp_space_between_parentheses = false
152+
csharp_space_between_square_brackets = false
153+
154+
# Wrapping preferences
155+
csharp_preserve_single_line_blocks = true
156+
csharp_preserve_single_line_statements = true
157+
158+
159+
[*.csproj]
160+
indent_size = 2
161+
indent_style = space
162+
tab_width = 2

source/NoCommons.NET.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ ProjectSection(SolutionItems) = preProject
1212
.github\FUNDING.yml = ..\.github\\FUNDING.yml
1313
.github\workflows\CI.yml = ..\.github\workflows\CI.yml
1414
.github\workflows\Release.yml = ..\.github\workflows\Release.yml
15+
.github\workflows\PreRelease.yml = ..\.github\workflows\PreRelease.yml
1516
GitVersion.yml = ..\GitVersion.yml
17+
.editorconfig = .editorconfig
1618
EndProjectSection
1719
EndProject
1820
Global
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
using System;
2-
using Xunit;
1+
namespace NoCommons.Tests;
32

4-
namespace NoCommons.Tests
3+
public class AssertionUtils
54
{
6-
public class AssertionUtils
5+
public static void AssertMessageContains(ArgumentException argumentException, string errorSyntax)
76
{
8-
public static void AssertMessageContains(ArgumentException argumentException, string errorSyntax)
9-
{
10-
bool containsText = argumentException.Message.Contains(errorSyntax);
11-
Assert.True(containsText);
12-
}
13-
14-
7+
bool containsText = argumentException.Message.Contains(errorSyntax);
8+
Assert.True(containsText);
159
}
16-
}
10+
}
Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
1-
using Xunit;
21
using NoCommons.Banking;
32

4-
namespace NoCommons.Tests.Banking
3+
namespace NoCommons.Tests.Banking;
4+
5+
public class IbanValidationTests
56
{
6-
public class IbanValidationTests
7+
/// Structure for IBAN in a lot of counties are found here:
8+
/// URL: http://www.ecbs.org/iban.htm
9+
[Theory]
10+
[InlineData("NO9386011117947", "Norway")]
11+
[InlineData("ES9121000418450200051332", "Spain")]
12+
public void TestValidNorwegianIban(string ibanValue, string country)
713
{
8-
/// Structure for IBAN in a lot of counties are found here:
9-
/// URL: http://www.ecbs.org/iban.htm
10-
[Theory]
11-
[InlineData("NO9386011117947", "Norway")]
12-
[InlineData("ES9121000418450200051332", "Spain")]
13-
public void TestValidNorwegianIban(string ibanValue, string country)
14-
{
15-
Assert.True(IbanValidator.IsValid(ibanValue), string.Format("Invalid for {0}", country));
16-
}
17-
18-
[Theory]
19-
[InlineData("NO93 8601 1117 947", "On valid print format, but not valid digital format")]
20-
[InlineData("ES91 2100 0418 4502 0005 1332", "On valid print format, but not valid digital format")]
21-
[InlineData("no9386011117947", "Lower case country code")]
22-
[InlineData("9386011117947", "Missing country code")]
23-
[InlineData("NO938601111794", "Missing end digit")]
24-
[InlineData("", "Empty string")]
25-
[InlineData(null, "null")]
26-
public void InvalidIbansReturnsFalse(string ibanValue, string reason)
27-
{
28-
Assert.False(IbanValidator.IsValid(ibanValue), string.Format("Valid when {0}. ", reason));
29-
}
14+
Assert.True(IbanValidator.IsValid(ibanValue), $"Invalid for {country}");
15+
}
3016

17+
[Theory]
18+
[InlineData("NO93 8601 1117 947", "On valid print format, but not valid digital format")]
19+
[InlineData("ES91 2100 0418 4502 0005 1332", "On valid print format, but not valid digital format")]
20+
[InlineData("no9386011117947", "Lower case country code")]
21+
[InlineData("9386011117947", "Missing country code")]
22+
[InlineData("NO938601111794", "Missing end digit")]
23+
[InlineData("", "Empty string")]
24+
[InlineData(null, "null")]
25+
public void InvalidIbansReturnsFalse(string? ibanValue, string reason)
26+
{
27+
Assert.False(IbanValidator.IsValid(ibanValue!), $"Valid when {reason}. ");
3128
}
32-
}
29+
}

0 commit comments

Comments
 (0)