Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion

dotnet_style_namespace_match_folder = false

[*.cs]
csharp_style_var_for_built_in_types = true:warning
csharp_style_var_when_type_is_apparent = true:warning
Expand All @@ -49,6 +51,7 @@ csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = false:none
csharp_style_conditional_delegate_call = true:suggestion
csharp_style_prefer_primary_constructors = false

# http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis.CSharp.Workspaces/Formatting/CSharpFormattingOptions.cs

Expand Down Expand Up @@ -101,6 +104,12 @@ dotnet_diagnostic.SX1309.severity = warning
dotnet_diagnostic.SA1400.severity = none
dotnet_diagnostic.SA1516.severity = none

# ArgumentException factory methods don't exist in all supported frameworks.
dotnet_diagnostic.CA1510.severity = none

# IDE0079 is broken and produces a lot of false-positives.
dotnet_diagnostic.IDE0079.severity = none

[*.json]
indent_style = space
indent_size = 2
8 changes: 2 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Setup .NET Core 3.1
- name: Setup .NET Core 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.1.402
- name: Setup .NET Core 6.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.202
dotnet-version: 9.0.100
- name: Build TypeNameInterpretation
run: dotnet build src --configuration ${{ matrix.configuration }}
- name: Run Tests
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CS1591 - Missing XML comment.
-->
<WarningsNotAsErrors>618,1030,1701,1702</WarningsNotAsErrors>
<NoWarn>1591</NoWarn>
<LangVersion>9.0</LangVersion>
<LangVersion>13.0</LangVersion>
<Nullable>enable</Nullable>

<Version>0.1.0</Version>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.4",
"version": "9.0.100",
"rollForward": "latestMinor"
}
}
2 changes: 1 addition & 1 deletion src/TextTools.Test/Format/FormatStringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void AppendFormatted_Formattable_EmptyFormat()
new StringBuilder("#"),
mockProvider.Object,
mockItem.Object,
ReadOnlySpan<char>.Empty)
[])
.ToString();

Assert.That(result, Is.EqualTo("#FormattedToString"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Brian Reichle. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information.
#if NET6_0_OR_GREATER
#if NET
using System;
using System.Text;
using Moq;
Expand All @@ -21,7 +21,7 @@ public void AppendFormatted_SpanFormattable()
new StringBuilder("#"),
mockProvider.Object,
item,
ReadOnlySpan<char>.Empty)
[])
.ToString();

Assert.That(result, Is.EqualTo("#" + new string('x', 15)));
Expand Down Expand Up @@ -53,7 +53,7 @@ public void AppendFormatted_SpanFormattable_Grow()
new StringBuilder("#"),
mockProvider.Object,
item,
ReadOnlySpan<char>.Empty)
[])
.ToString();

Assert.That(result, Is.EqualTo("#" + new string('z', 40)));
Expand Down
2 changes: 1 addition & 1 deletion src/TextTools.Test/StringPool/StringPoolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class StringPoolTest
public void GetString_EmptySpan()
{
var pool = new StringPool();
Assert.That(pool.GetString(ReadOnlySpan<char>.Empty), Is.SameAs(string.Empty));
Assert.That(pool.GetString([]), Is.SameAs(string.Empty));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/TextTools.Test/TestUtils/DummySpanFormattable.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Brian Reichle. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information.
#if NET6_0_OR_GREATER
#if NET
using System;

namespace TextTools.Test.TestUtils
Expand Down
16 changes: 8 additions & 8 deletions src/TextTools.Test/TextTools.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net48;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Moq" Version="[4.18.4]" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.507">
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions src/TextTools/Format/FormatString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static StringBuilder AppendValue(this StringBuilder builder, IFormatProvider? fo
return item switch
{
null => builder,
#if NET6_0_OR_GREATER
#if NET
ISpanFormattable spanFormattable => builder.AppendSpanFormattableValue(formatProvider, spanFormattable, format),
#endif
IFormattable formattable => builder.AppendFormattableValue(formatProvider, formattable, format),
Expand All @@ -194,7 +194,7 @@ static StringBuilder AppendValue(this StringBuilder builder, IFormatProvider? fo
static StringBuilder AppendFormattableValue(this StringBuilder builder, IFormatProvider? formatProvider, IFormattable item, ReadOnlySpan<char> format)
=> builder.Append(item.ToString(format.Length == 0 ? null : format.ToString(), formatProvider));

#if NET6_0_OR_GREATER
#if NET
static StringBuilder AppendSpanFormattableValue(this StringBuilder builder, IFormatProvider? formatProvider, ISpanFormattable item, ReadOnlySpan<char> format)
{
var size = 16;
Expand All @@ -217,7 +217,7 @@ static StringBuilder AppendSpanFormattableValue(this StringBuilder builder, IFor

static bool TryParseInt(ReadOnlySpan<char> text, out int value)
{
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
#if NET || NETSTANDARD2_1_OR_GREATER
return int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out value);
#else
return int.TryParse(text.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out value);
Expand Down
4 changes: 2 additions & 2 deletions src/TextTools/StringBuilderSpanExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace TextTools
{
public static class StringBuilderSpanExtensions
{
#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
#if NET || NETSTANDARD2_1_OR_GREATER
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
#endif
public static StringBuilder Append(this StringBuilder builder, ReadOnlySpan<char> span)
Expand All @@ -16,7 +16,7 @@ public static StringBuilder Append(this StringBuilder builder, ReadOnlySpan<char
throw new ArgumentNullException(nameof(builder));
}

#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
#if NET || NETSTANDARD2_1_OR_GREATER
return builder.Append(span);
#else
unsafe
Expand Down
2 changes: 1 addition & 1 deletion src/TextTools/StringPool/StringPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public string GetString(ReadOnlySpan<char> text)

static void ResetIndexes(int[] indexes)
{
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP
#if NET || NETSTANDARD2_1_OR_GREATER
Array.Fill(indexes, -1);
#else
for (var i = 0; i < indexes.Length; i++)
Expand Down
12 changes: 5 additions & 7 deletions src/TextTools/TextTools.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net46;netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
Expand All @@ -10,11 +10,11 @@
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.507">
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down Expand Up @@ -46,9 +46,7 @@
<Choose>
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
</When>
<When Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
</When>
<When Condition="'$(TargetFramework)' == 'net6.0'">
<When Condition="'$(TargetFramework)' == 'net8.0'">
</When>
<Otherwise>
<PropertyGroup>
Expand All @@ -59,7 +57,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Memory" Version="4.6.3" />
</ItemGroup>
</Otherwise>
</Choose>
Expand Down