Skip to content

Commit

Permalink
ci/fmt: switch from dotnet-format to csharpier (#520)
Browse files Browse the repository at this point in the history
* dotnet new tool-manifest

* dotnet tool install csharpier

* dotnet csharpier .

* ci: switch from dotnet-format to csharpier

* fmt: prettier dotnet-tools.json

---------

Co-authored-by: Konstantin <[email protected]>
  • Loading branch information
hf-kklein and Konstantin authored Sep 5, 2024
1 parent c26169a commit e26b623
Show file tree
Hide file tree
Showing 306 changed files with 4,682 additions and 2,732 deletions.
11 changes: 11 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.29.1",
"commands": ["dotnet-csharpier"],
"rollForward": false
}
}
}
13 changes: 6 additions & 7 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: dotnet-format
name: csharpier

on: [push, pull_request]

Expand All @@ -7,12 +7,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 6
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.100
- name: Install dotnet-format
run: |
dotnet tool install -g dotnet-format
- name: Run dotnet-format
run: dotnet-format BO4E-dotnet.sln --check
- name: Restore .NET tools
run: dotnet tool restore
- name: Run CSharpier
run: dotnet csharpier BO4E-dotnet.sln --check
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public static class BenachrichtigungExtension
/// <returns></returns>
public static bool Has(this BO.Benachrichtigung b, string key, string value)
{
return Has(b, new GenericStringStringInfo
{
KeyColumn = key,
Value = value
});
return Has(b, new GenericStringStringInfo { KeyColumn = key, Value = value });
}

/// <summary>
Expand Down Expand Up @@ -73,8 +69,14 @@ public static bool Has(this BO.Benachrichtigung b, string key)
/// true if there's an info object with given key <paramref name="keyName" /> of type <typeparamref name="T" />
/// fulfilling <paramref name="predicate" /> or there's no such property but <paramref name="passByDefault" /> is true
/// </returns>
public static bool Has<T>(this BO.Benachrichtigung b, string keyName, Predicate<T> predicate,
bool passByDefault = true, TypeConverter typeConverter = null) where T : IComparable
public static bool Has<T>(
this BO.Benachrichtigung b,
string keyName,
Predicate<T> predicate,
bool passByDefault = true,
TypeConverter typeConverter = null
)
where T : IComparable
{
if (!b.Has(keyName))
{
Expand All @@ -94,9 +96,7 @@ public static bool Has<T>(this BO.Benachrichtigung b, string keyName, Predicate<
return predicate(value);
}
}
catch (NotSupportedException)
{
}
catch (NotSupportedException) { }

return false;
}
Expand All @@ -108,7 +108,10 @@ public static bool Has<T>(this BO.Benachrichtigung b, string keyName, Predicate<
/// <param name="b">Benachrichtigung</param>
/// <param name="overwriteExistingKeys">set true to overwrite userProperties with same key</param>
// ToDo: make method generic MoveInfosTouserProperties<boT>(...)
public static void MoveInfosToUserProperties(this BO.Benachrichtigung b, bool overwriteExistingKeys = false)
public static void MoveInfosToUserProperties(
this BO.Benachrichtigung b,
bool overwriteExistingKeys = false
)
{
if (b.Infos != null && b.Infos.Count > 0)
{
Expand All @@ -124,11 +127,10 @@ public static void MoveInfosToUserProperties(this BO.Benachrichtigung b, bool ov
b.UserProperties.Remove(info.KeyColumn);
}

b.UserProperties.Add(info.KeyColumn,
info.Value); // might throw exception if key exists and !overwriteExistingKeys. That's ok.
b.UserProperties.Add(info.KeyColumn, info.Value); // might throw exception if key exists and !overwriteExistingKeys. That's ok.
}

b.Infos = null; // set to null after all elements have been moved
}
}
}
}
5 changes: 3 additions & 2 deletions BO4E.Extensions/BusinessObjects/BusinessObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ public static class BusinessObjectExtensions
/// <typeparam name="T">Type of the BusinessObject</typeparam>
/// <param name="source">the BO that is copied</param>
/// <returns>the deep copy</returns>
public static T DeepClone<T>(this T source) where T : BusinessObject
public static T DeepClone<T>(this T source)
where T : BusinessObject
{
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(source));
}
}
}
Loading

0 comments on commit e26b623

Please sign in to comment.