Skip to content

Commit 532f2bc

Browse files
committed
use aspnetcore inspired .editorconfig file
1 parent f75ed97 commit 532f2bc

File tree

10 files changed

+485
-146
lines changed

10 files changed

+485
-146
lines changed

.editorconfig

Lines changed: 421 additions & 137 deletions
Large diffs are not rendered by default.

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"EditorConfig.EditorConfig",
4+
"GitHub.vscode-github-actions"
5+
]
6+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 sotsera
3+
Copyright (c) 2024 Alessandro Ghidini
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Sotsera.Sources.Common.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{F2
1313
icon.svg = icon.svg
1414
LICENSE = LICENSE
1515
README.md = README.md
16+
Sotsera.Sources.Common.sln.DotSettings = Sotsera.Sources.Common.sln.DotSettings
1617
EndProjectSection
1718
EndProject
1819
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B3030FA3-01FF-42F6-A449-1D8D960AE6D1}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ghidini/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Sotsera/@EntryIndexedValue">True</s:Boolean>
4+
</wpf:ResourceDictionary>

src/Sotsera.Sources.Common/Extensions/ObjectExtensions.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
// Copyright (c) Alessandro Ghidini. All rights reserved.
2+
// SPDX-License-Identifier: MIT.
3+
4+
using System.Diagnostics.CodeAnalysis;
25
using System.Runtime.CompilerServices;
36

47
namespace Sotsera.Sources.Common.Extensions;
58

69
internal static class ObjectExtensions
710
{
11+
/// <summary>
12+
/// Throws an <see cref="ArgumentNullException"/> if the specified argument is null.
13+
/// </summary>
14+
/// <typeparam name="T">The type of the argument.</typeparam>
15+
/// <param name="argument">The argument to check for null.</param>
16+
/// <param name="paramName">The name of the parameter that caused the exception. This is optional and will be automatically set to the name of the argument if not provided.</param>
17+
/// <returns>The original argument if it is not null.</returns>
18+
/// <exception cref="ArgumentNullException">Thrown if the argument is null.</exception>
819
public static T ThrowIfNull<T>([NotNull] this T? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
920
{
1021
ArgumentNullException.ThrowIfNull(argument, paramName);

src/Sotsera.Sources.Common/Extensions/StringExtensions.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,48 @@
1-
using System.Collections;
1+
// Copyright (c) Alessandro Ghidini. All rights reserved.
2+
// SPDX-License-Identifier: MIT.
3+
4+
using System.Collections;
25
using System.Diagnostics.CodeAnalysis;
36
using System.Runtime.CompilerServices;
47

58
namespace Sotsera.Sources.Common.Extensions;
69

710
internal static class StringExtensions
811
{
12+
/// <summary>
13+
/// Throws an <see cref="ArgumentException"/> if the provided string is null or consists only of white-space characters.
14+
/// </summary>
15+
/// <param name="argument">The string to check.</param>
16+
/// <param name="paramName">The name of the parameter being checked. This is automatically provided by the compiler.</param>
17+
/// <returns>The original string if it is not null or white-space.</returns>
18+
/// <exception cref="ArgumentException">Thrown if the string is null or white-space.</exception>
919
public static string ThrowIfEmpty([NotNull] this string? argument, [CallerArgumentExpression(nameof(argument))] string? paramName = null)
1020
{
1121
ArgumentException.ThrowIfNullOrWhiteSpace(argument, paramName);
1222
return argument;
1323
}
1424

25+
/// <summary>
26+
/// Determines whether the specified string is null or consists only of white-space characters.
27+
/// </summary>
28+
/// <param name="value">The string to check.</param>
29+
/// <returns><c>true</c> if the string is null or white-space; otherwise, <c>false</c>.</returns>
1530
public static bool IsEmpty([NotNullWhen(false)] this string? value) => string.IsNullOrWhiteSpace(value);
1631

32+
/// <summary>
33+
/// Determines whether the specified string is not null and contains non-white-space characters.
34+
/// </summary>
35+
/// <param name="value">The string to check.</param>
36+
/// <returns><c>true</c> if the string is not null and contains non-white-space characters; otherwise, <c>false</c>.</returns>
1737
public static bool IsNonEmpty([NotNullWhen(true)] this string? value) => !string.IsNullOrWhiteSpace(value);
1838

39+
/// <summary>
40+
/// Joins an enumeration of strings into a single string, with an optional separator and the option to include or exclude empty values.
41+
/// </summary>
42+
/// <param name="values">The enumeration of strings to join.</param>
43+
/// <param name="separator">The string to use as a separator between each joined string.</param>
44+
/// <param name="includeEmptyValues">If <c>true</c>, empty strings are included in the result; otherwise, they are excluded.</param>
45+
/// <returns>A single string that consists of the joined strings from the enumeration, separated by the specified separator.</returns>
1946
public static string JoinStrings(this IEnumerable<string?>? values, string? separator, bool includeEmptyValues = false)
2047
{
2148
return values is null or IList { Count: 0 }

src/Sotsera.Sources.Common/Sotsera.Sources.Common.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
4+
</PropertyGroup>
25
<ItemGroup>
36
<PackageReference Include="MinVer">
47
<PrivateAssets>all</PrivateAssets>

test/Sotsera.Sources.Common.Tests.Unit/Extensions/ObjectExtensionsTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using Sotsera.Sources.Common.Extensions;
1+
// Copyright (c) Alessandro Ghidini. All rights reserved.
2+
// SPDX-License-Identifier: MIT.
3+
4+
using Sotsera.Sources.Common.Extensions;
25

36
namespace Sotsera.Sources.Common.Tests.Unit.Extensions;
47

@@ -14,7 +17,6 @@ public void ThrowIfNull_ShouldThrowArgumentNullException_WhenValueIsNull()
1417
act.Should().Throw<ArgumentNullException>().WithParameterName(nameof(value));
1518
}
1619

17-
1820
[Theory]
1921
[InlineData("ciao")]
2022
[InlineData(true)]

test/Sotsera.Sources.Common.Tests.Unit/Extensions/StringExtensionsTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
// Copyright (c) Alessandro Ghidini. All rights reserved.
2+
// SPDX-License-Identifier: MIT.
3+
4+
using System.Diagnostics.CodeAnalysis;
25
using Sotsera.Sources.Common.Extensions;
36
using Xunit.Abstractions;
47

@@ -58,7 +61,6 @@ public void JoinStrings_ShouldReturnTheExpectedValue(EnumerableStringList list,
5861
list.Values.JoinStrings("; ", includeEmptyValues).Should().Be(expected);
5962
}
6063

61-
6264
private class NullOrWhiteSpaceValueGenerator : TheoryData<string?>
6365
{
6466
public NullOrWhiteSpaceValueGenerator()
@@ -96,7 +98,6 @@ public StringEnumerableToBeJoinedValueGenerator()
9698
Add(new EnumerableStringList(["a", "b"]), false, "a; b");
9799
Add(new EnumerableStringList(["a", null, "b"]), false, "a; b");
98100

99-
100101
Add(new EnumerableStringList(null), true, "");
101102
Add(new EnumerableStringList(Enumerable.Empty<string>()), true, "");
102103
Add(new EnumerableStringList(Array.Empty<string>()), true, "");

0 commit comments

Comments
 (0)