Skip to content

Commit

Permalink
Adjust .editorconfig, use .NET 8 recommended styles
Browse files Browse the repository at this point in the history
  • Loading branch information
zsrdjan committed Jul 19, 2024
1 parent 236d475 commit 132a598
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 76 deletions.
63 changes: 3 additions & 60 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ root = true

; For more visit http://editorconfig.org.

; Choose between lf or rf on "end_of_line" property
[*.proto]
indent_style = tab
indent_size = tab
tab_width = 4

[*.{asax,ascx,aspx,cs,cshtml,css,htm,html,js,jsx,master,razor,skin,ts,tsx,vb,xaml,xamlx,xoml}]
indent_style = space
indent_size = 4
Expand All @@ -20,57 +14,6 @@ indent_style = space
indent_size = 2
tab_width = 2

[*]

# Standard properties
end_of_line = native
insert_final_newline = false

# Microsoft .NET properties
csharp_indent_braces = false
csharp_indent_switch_labels = true
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
csharp_prefer_braces = true
csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
csharp_preserve_single_line_blocks = true
csharp_space_after_cast = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_var_elsewhere = true:hint
csharp_style_var_for_built_in_types = true:hint
csharp_style_var_when_type_is_apparent = true:hint
csharp_using_directive_placement = outside_namespace:silent
dotnet_style_predefined_type_for_locals_parameters_members = true:hint
dotnet_style_predefined_type_for_member_access = true:hint
dotnet_style_qualification_for_event = false:hint
dotnet_style_qualification_for_field = false:hint
dotnet_style_qualification_for_method = false:hint
dotnet_style_qualification_for_property = false:hint
dotnet_style_require_accessibility_modifiers = for_non_interface_members:hint
[*.cs]
dotnet_diagnostic.CA1715.severity = none # Identifiers should have correct prefix
dotnet_diagnostic.CA1707.severity = none # Identifiers should not contain underscores
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Features>strict</Features>
<AnalysisLevel>latest</AnalysisLevel>
<WarningLevel>9999</WarningLevel>
<AnalysisLevel>8.0</AnalysisLevel>
<AnalysisMode>Recommended</AnalysisMode>

<PackageTags>domain-modeling;event-sourcing;eventsourcing;cqrs</PackageTags>
<PackageIcon>gradient_128x128.png</PackageIcon>
Expand Down
2 changes: 1 addition & 1 deletion src/Fraktalio.FModel/InternalDecider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// <typeparam name="So">Output State type</typeparam>
/// <typeparam name="Ei">Input Event type</typeparam>
/// <typeparam name="Eo">Output Event type</typeparam>
internal class InternalDecider<C, Si, So, Ei, Eo>
internal sealed class InternalDecider<C, Si, So, Ei, Eo>
{
/// <summary>
/// [InternalDecider] is a datatype that represents the main decision-making algorithm.
Expand Down
2 changes: 1 addition & 1 deletion src/Fraktalio.FModel/InternalView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Fraktalio.FModel;
/// <typeparam name="Si">Input State type</typeparam>
/// <typeparam name="So">Output State type</typeparam>
/// <typeparam name="E">Event type</typeparam>
internal class InternalView<Si, So, E>(Func<Si, E, So> evolve, So initialState)
internal sealed class InternalView<Si, So, E>(Func<Si, E, So> evolve, So initialState)
{
internal Func<Si, E, So> Evolve { get; } = evolve;
internal So InitialState { get; } = initialState;
Expand Down
4 changes: 2 additions & 2 deletions src/Fraktalio.FModel/ViewBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Fraktalio.FModel;

internal class ViewBuilder<S, E>
internal sealed class ViewBuilder<S, E>
{
private Func<S, E, S> Evolve { get; set; } = (s, _) => s;
private Func<S> InitialState { get; set; } = () => throw new Exception("Initial State is not initialized");
private Func<S> InitialState { get; set; } = () => throw new InvalidOperationException("Initial State is not initialized");

public void SetEvolve(Func<S, E, S> value) => Evolve = value;

Expand Down
13 changes: 7 additions & 6 deletions test/Fraktalio.FModel.Tests/EventSourcedDeciderTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fraktalio.FModel.Tests.Examples.Numbers;
using System.Globalization;
using Fraktalio.FModel.Tests.Examples.Numbers;
using Fraktalio.FModel.Tests.Examples.Numbers.Even;
using Fraktalio.FModel.Tests.Examples.Numbers.Odd;
using Fraktalio.FModel.Tests.Extensions;
Expand Down Expand Up @@ -51,15 +52,15 @@ public void GivenEvents_SubtractOddNumber() =>
[Test]
public void GivenEvents_LeftMapOverCommand_AddEvenNumber() =>
_evenDecider.MapLeftOnCommand<int>(cn =>
new EvenNumberCommand.AddEvenNumber(Description.Create(cn.ToString()), Number.Create(cn)))
new EvenNumberCommand.AddEvenNumber(Description.Create(cn.ToString(CultureInfo.InvariantCulture)), Number.Create(cn)))
.GivenEvents([],
() => 2)
.ThenEvents([new EvenNumberAdded(Description.Create("2"), Number.Create(2))]);

[Test]
public void GivenState_LeftMapOverCommand_AddEvenNumber() =>
_evenDecider.MapLeftOnCommand<int>(cn =>
new EvenNumberCommand.AddEvenNumber(Description.Create(cn.ToString()), Number.Create(cn)))
new EvenNumberCommand.AddEvenNumber(Description.Create(cn.ToString(CultureInfo.InvariantCulture)), Number.Create(cn)))
.GivenState(null,
() => 2)
.ThenState(new EvenNumberState(Description.Create("Initial state + 2"), Number.Create(2)));
Expand All @@ -70,7 +71,7 @@ public void GivenEmptyEvents_DimapOverEventParameter_AddEvenNumber() =>
_evenDecider.DimapOnEvent<EvenNumberEvent?>(
fl => fl != null ? fl with { Value = fl.Value} : null,
fr => fr != null
? new EvenNumberAdded(Description.Create(fr.Value.Value.ToString()), Number.Create(fr.Value))
? new EvenNumberAdded(Description.Create(fr.Value.Value.ToString(CultureInfo.InvariantCulture)), Number.Create(fr.Value))
: null)
.GivenEvents([], () => new EvenNumberCommand.AddEvenNumber(Description.Create("2"), Number.Create(2)))
.ThenEvents([new EvenNumberAdded(Description.Create("2"), Number.Create(2))]);
Expand All @@ -81,7 +82,7 @@ public void GivenEmptyEvents_DimapOverStateParameter_AddEvenNumber() =>
_evenDecider.DimapOnState<EvenNumberState>(
fl => fl with { Value = fl.Value},
fr =>
new EvenNumberState(Description.Create(fr.Value.Value.ToString()), Number.Create(fr.Value))
new EvenNumberState(Description.Create(fr.Value.Value.ToString(CultureInfo.InvariantCulture)), Number.Create(fr.Value))
)
.GivenEvents([], () => new EvenNumberCommand.AddEvenNumber(Description.Create("2"), Number.Create(2)))
.ThenEvents([new EvenNumberAdded(Description.Create("2"), Number.Create(2))]);
Expand All @@ -92,7 +93,7 @@ public void GivenEmptyState_DimapOverStateParameter_AddEvenNumber() =>
_evenDecider.DimapOnState<EvenNumberState>(
fl => fl with { Value = fl.Value},
fr =>
new EvenNumberState(Description.Create(fr.Value.Value.ToString()), Number.Create(fr.Value))
new EvenNumberState(Description.Create(fr.Value.Value.ToString(CultureInfo.InvariantCulture)), Number.Create(fr.Value))
)
.GivenState(null, () => new EvenNumberCommand.AddEvenNumber(Description.Create("2"), Number.Create(2)))
.ThenState(new EvenNumberState(Description.Create("2"), Number.Create(2)));
Expand Down
5 changes: 3 additions & 2 deletions test/Fraktalio.FModel.Tests/SagaTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fraktalio.FModel.Tests.Examples.Numbers;
using System.Globalization;
using Fraktalio.FModel.Tests.Examples.Numbers;
using Fraktalio.FModel.Tests.Extensions;
using OddNumberCommand = Fraktalio.FModel.Tests.Examples.Numbers.NumberCommand.OddNumberCommand;
using EvenNumberCommand = Fraktalio.FModel.Tests.Examples.Numbers.NumberCommand.EvenNumberCommand;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void Given_OddNumberAdded_CombinedSaga_CreatesAddEvenNumberCommand()
[Test]
public void MapLeftOnActionResult() =>
_evenSaga.MapLeftOnActionResult<int>(arn =>
new EvenNumberAdded(Description.Create(arn.ToString()), Number.Create(arn)))
new EvenNumberAdded(Description.Create(arn.ToString(CultureInfo.InvariantCulture)), Number.Create(arn)))
.WhenActionResult(
2)
.ExpectActions(
Expand Down
5 changes: 3 additions & 2 deletions test/Fraktalio.FModel.Tests/ViewTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using Fraktalio.FModel.Tests.Examples.Numbers;
using Fraktalio.FModel.Tests.Examples.Numbers.Even;
using Fraktalio.FModel.Tests.Examples.Numbers.Odd;
Expand Down Expand Up @@ -30,7 +31,7 @@ public void GivenMultipleEvents_EvenNumberState() =>
public void MapLefOnEvent_EvenNumbersAdded()
{
var mappedEvenView = _evenView.MapLeftOnEvent<int>(number =>
new EvenNumberAdded(Description.Create(number.ToString()), Number.Create(number)));
new EvenNumberAdded(Description.Create(number.ToString(CultureInfo.InvariantCulture)), Number.Create(number)));
mappedEvenView.GivenEvents([
2,
4
Expand All @@ -43,7 +44,7 @@ public void DimapOnState_EvenNumbersAdded()
{
var mappedEvenView =
_evenView.DimapOnState(fl =>
new EvenNumberState(Description.Create(fl.ToString()), Number.Create(fl)),
new EvenNumberState(Description.Create(fl.ToString(CultureInfo.InvariantCulture)), Number.Create(fl)),
fr => fr.Value.Value);

mappedEvenView.GivenEvents([
Expand Down

0 comments on commit 132a598

Please sign in to comment.