Skip to content

Commit e12a48c

Browse files
hf-kkleinKonstantin
and
Konstantin
authored
fmt: apply dotnet csharpier . to entire code base (switch from dotnet-format to csharpier) (#109)
--------- Co-authored-by: Konstantin <[email protected]>
1 parent 75980c1 commit e12a48c

19 files changed

+918
-405
lines changed

.github/workflows/formatter.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: dotnet-format
1+
name: csharpier
22

33
on: [push, pull_request]
44

@@ -7,13 +7,13 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
10-
- name: Setup .NET 3.1
10+
- name: Setup .NET 9
1111
uses: actions/setup-dotnet@v4
1212
with:
13-
dotnet-version: 8.0.100
14-
- name: Install dotnet-format
15-
run: |
16-
dotnet tool install -g dotnet-format
17-
- name: Run dotnet-format
13+
dotnet-version: 9
14+
- name: Restore .NET tools
1815
working-directory: ./ChronoJsonDiffPatch
19-
run: dotnet-format ChronoJsonDiffPatch.sln --check
16+
run: dotnet tool restore
17+
- name: Run CSharpier
18+
working-directory: ./ChronoJsonDiffPatch
19+
run: dotnet csharpier . --check

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ ChronoJsonDiffPatch/ChronoJsonDiffPatch/bin/Debug/net7.0/
1010
ChronoJsonDiffPatch/ChronoJsonDiffPatch.sln.DotSettings.user
1111

1212
ChronoJsonDiffPatch/ChronoJsonDiffPatch/bin/Debug/ChronoJsonDiffPatch.xml
13+
14+
*.dll
15+
16+
*.pdb
17+
18+
*.exe
19+
20+
*.xml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"csharpier": {
6+
"version": "0.30.6",
7+
"commands": [
8+
"dotnet-csharpier"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

ChronoJsonDiffPatch/ChronoJsonDiffPatch/FuturePatchBehaviour.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ public enum FuturePatchBehaviour
2020
/// The future (&gt;= dtB) shall have state B: the second patchA only lasts in the interval between [A,B)
2121
/// </summary>
2222
KeepTheFuture,
23-
}
23+
}

ChronoJsonDiffPatch/ChronoJsonDiffPatch/GenericTimeRangePatchChainProduct.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ namespace ChronoJsonDiffPatch;
1212
/// </remarks>
1313
/// <typeparam name="TProductEntity">type that holds the state of n different types at a given point in time</typeparam>
1414
/// <typeparam name="TChainsAndEntities">the initial state and respective chains of a the different types</typeparam>
15-
public abstract class GenericTimeRangePatchChainProduct<TChainsAndEntities, TProductEntity> where TChainsAndEntities : IChainsAndEntities<TProductEntity>
15+
public abstract class GenericTimeRangePatchChainProduct<TChainsAndEntities, TProductEntity>
16+
where TChainsAndEntities : IChainsAndEntities<TProductEntity>
1617
{
1718
/// <summary>
1819
/// the relevant initial states and chains
1920
/// </summary>
2021
private readonly TChainsAndEntities _chainsAndEntities;
22+
2123
/// <summary>
2224
/// instantiate the generic chain product by providing an instance of a type that holds all chains and respective initial entities.
2325
/// </summary>
@@ -26,14 +28,16 @@ public GenericTimeRangePatchChainProduct(TChainsAndEntities chainsAndEntities)
2628
{
2729
_chainsAndEntities = chainsAndEntities;
2830
}
31+
2932
/// <summary>
3033
/// returns the joint history of all chains involved in <typeparamref name="TChainsAndEntities"/>
3134
/// </summary>
3235
/// <returns>an enumerable that contains entries for every relevant date which there is in either or both of the chains</returns>
3336
[Pure]
3437
public IEnumerable<TProductEntity> GetAll()
3538
{
36-
var result = _chainsAndEntities.GetPatchingDates()
39+
var result = _chainsAndEntities
40+
.GetPatchingDates()
3741
.Where(dt => dt != DateTime.MinValue)
3842
.Where(dt => dt != DateTime.MaxValue)
3943
.Distinct()

ChronoJsonDiffPatch/ChronoJsonDiffPatch/PatchingDirection.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public enum PatchingDirection
2121
/// </summary>
2222
/// <remarks>
2323
/// Although this doesn't feel as natural as <see cref="ParallelWithTime"/>, it might useful if you store changes to an entity in a database and you always want to have the most recent/youngest state as "full" entity and persist the past as patches.
24-
/// Then you always start with the youngest entity and patch "backwards" until you reach the point in time/in the past in which you're interested.
24+
/// Then you always start with the youngest entity and patch "backwards" until you reach the point in time/in the past in which you're interested.
2525
/// </remarks>
2626
AntiParallelWithTime,
27-
}
27+
}

ChronoJsonDiffPatch/ChronoJsonDiffPatch/ProductEntity.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace ChronoJsonDiffPatch;
22

33
/// <summary>
4-
/// A ProductEntity is a composite of both an <typeparamref name="TEntityA"/> and a <typeparamref name="TEntityB"/>.
4+
/// A ProductEntity is a composite of both an <typeparamref name="TEntityA"/> and a <typeparamref name="TEntityB"/>.
55
/// </summary>
66
/// <remarks>This is a shortcut for a <see cref="Tuple{TEntityA, TEntityB, DateTimeOffset}"/></remarks>
77
/// <typeparam name="TEntityA"></typeparam>
@@ -12,10 +12,12 @@ public class ProductEntity<TEntityA, TEntityB>
1212
/// describes the date at which <typeparamref name="TEntityA"/> has state <see cref="EntityA"/> and <typeparamref name="TEntityB"/> has state <see cref="EntityB"/>
1313
/// </summary>
1414
public DateTimeOffset KeyDate { get; }
15+
1516
/// <summary>
1617
/// an instance of <typeparamref name="TEntityA"/> @ <see cref="KeyDate"/>
1718
/// </summary>
1819
public TEntityA EntityA { get; }
20+
1921
/// <summary>
2022
/// an instance of <typeparamref name="TEntityB"/> @ <see cref="KeyDate"/>
2123
/// </summary>
@@ -33,4 +35,4 @@ public ProductEntity(TEntityA entityA, TEntityB entityB, DateTimeOffset keyDate)
3335
EntityB = entityB;
3436
KeyDate = keyDate;
3537
}
36-
}
38+
}

ChronoJsonDiffPatch/ChronoJsonDiffPatch/SkipCondition.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ public interface ISkipCondition<in TEntity>
2121
/// <param name="errorWhilePatching">any error that occurred</param>
2222
/// <param name="failedPatch">the patch that lead to the exception <paramref name="errorWhilePatching"/></param>
2323
/// <returns>true if the patch should be skipped</returns>
24-
public bool ShouldSkipPatch(TEntity initialEntity, TimeRangePatch failedPatch, Exception errorWhilePatching);
24+
public bool ShouldSkipPatch(
25+
TEntity initialEntity,
26+
TimeRangePatch failedPatch,
27+
Exception errorWhilePatching
28+
);
2529
}

ChronoJsonDiffPatch/ChronoJsonDiffPatch/SkipPatchesWithUnmatchedListItems.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public SkipPatchesWithUnmatchedListItems(Func<TEntity, List<TListItem>?> listAcc
2121
/// <summary>
2222
/// <inheritdoc cref="ISkipCondition{TEntity}"/>
2323
/// </summary>
24-
public virtual bool ShouldSkipPatch(TEntity initialEntity, TimeRangePatch failedPatch, Exception errorWhilePatching)
24+
public virtual bool ShouldSkipPatch(
25+
TEntity initialEntity,
26+
TimeRangePatch failedPatch,
27+
Exception errorWhilePatching
28+
)
2529
{
2630
if (errorWhilePatching is not ArgumentOutOfRangeException)
2731
{

ChronoJsonDiffPatch/ChronoJsonDiffPatch/TimeRangePatch.cs

+17-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ public class TimeRangePatch : TimeRange
3131
public DateTimeOffset From
3232
{
3333
get => Start == DateTime.MinValue ? DateTimeOffset.MinValue : new DateTimeOffset(Start);
34-
set => Start = value == DateTimeOffset.MinValue ? DateTimeOffset.MinValue.UtcDateTime : value.UtcDateTime;
34+
set =>
35+
Start =
36+
value == DateTimeOffset.MinValue
37+
? DateTimeOffset.MinValue.UtcDateTime
38+
: value.UtcDateTime;
3539
}
3640

3741
/// <summary>
@@ -50,7 +54,9 @@ public DateTimeOffset? To
5054
{
5155
if (value.Value < From)
5256
{
53-
throw new ArgumentException($"{nameof(value)} ({value.Value:o}) must not be lower than {nameof(From)} ({From:o})");
57+
throw new ArgumentException(
58+
$"{nameof(value)} ({value.Value:o}) must not be lower than {nameof(From)} ({From:o})"
59+
);
5460
}
5561

5662
End = value.Value.UtcDateTime;
@@ -73,6 +79,7 @@ public DateTimeOffset? To
7379
public DateTime? Timestamp { get; set; }
7480

7581
private readonly PatchingDirection _patchingDirection;
82+
7683
/// <summary>
7784
/// Describes of this patch shall be applied "left to right" or "right to left".
7885
/// For details see <see cref="PatchingDirection"/>
@@ -91,14 +98,18 @@ public TimeRangePatch()
9198
/// by default: assume the From-date is now
9299
/// </summary>
93100
/// <param name="patch"></param>
94-
public TimeRangePatch(JsonDocument? patch) : this(DateTimeOffset.UtcNow, patch)
95-
{
96-
}
101+
public TimeRangePatch(JsonDocument? patch)
102+
: this(DateTimeOffset.UtcNow, patch) { }
97103

98104
/// <summary>
99105
/// instantiate with given "from" date and open end
100106
/// </summary>
101-
public TimeRangePatch(DateTimeOffset from, JsonDocument? patch, DateTimeOffset? to = null, PatchingDirection patchingDirection = PatchingDirection.ParallelWithTime)
107+
public TimeRangePatch(
108+
DateTimeOffset from,
109+
JsonDocument? patch,
110+
DateTimeOffset? to = null,
111+
PatchingDirection patchingDirection = PatchingDirection.ParallelWithTime
112+
)
102113
{
103114
To = to;
104115
From = from;

0 commit comments

Comments
 (0)