Skip to content

Commit 1af3382

Browse files
committed
Smaller improvements and added analyzer
1 parent 372eb36 commit 1af3382

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
99
### Addeed
1010

1111
- Added overload which allows an initial string for the ValueStringBuilder
12+
- Meziantou.Analyzer as developer dependency to spot issues early on
13+
14+
### Changed
15+
- Added `StructLayout(LayoutKind.Auto)`, which makes the ValueStringBuilder not usable for unmanaged code
1216

1317
## [1.5.1] - 2022-11-05
1418

src/LinkDotNet.StringBuilder/LinkDotNet.StringBuilder.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<PrivateAssets>all</PrivateAssets>
3737
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3838
</PackageReference>
39+
<PackageReference Include="Meziantou.Analyzer" Version="1.0.746">
40+
<PrivateAssets>all</PrivateAssets>
41+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
42+
</PackageReference>
3943
</ItemGroup>
4044

4145
</Project>

src/LinkDotNet.StringBuilder/TypedSpanList.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System.Runtime.CompilerServices;
2+
using System.Runtime.InteropServices;
23

34
namespace LinkDotNet.StringBuilder;
45

56
/// <summary>
67
/// Represents a List based on the <see cref="Span{T}"/> type.
78
/// </summary>
89
/// <typeparam name="T">Any struct.</typeparam>
10+
[StructLayout(LayoutKind.Auto)]
911
internal ref struct TypedSpanList<T>
1012
where T : struct
1113
{

src/LinkDotNet.StringBuilder/ValueStringBuilder.Replace.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char
114114
var length = startIndex + count;
115115
var slice = buffer[startIndex..length];
116116

117-
if (oldValue == newValue)
117+
if (oldValue.SequenceEqual(newValue))
118118
{
119119
return;
120120
}

tests/LinkDotNet.StringBuilder.UnitTests/LinkDotNet.StringBuilder.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="FluentAssertions" Version="6.8.0" />
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
1313
<PackageReference Include="xunit" Version="2.4.2" />
1414
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)