Skip to content

Commit 4031356

Browse files
committed
Merge branch 'main' into more-APIs
2 parents ad75634 + 0e25c27 commit 4031356

File tree

113 files changed

+3298
-2877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3298
-2877
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ obj/
99
nugets/
1010
src/msbuild.binlog
1111
.claude/settings.local.json
12+
src/.claude/settings.local.json

assemblySize.include.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
### Assembly Sizes
2+
3+
| | Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability |
4+
|----------------|----------------|---------------|-----------|-----------|--------------------|---------------------|-------------|
5+
| netstandard2.0 | 8.0 KB | 185.0 KB | +177.0 KB | +8.5 KB | +5.0 KB | +9.0 KB | +13.5 KB |
6+
| netstandard2.1 | 8.5 KB | 150.0 KB | +141.5 KB | +8.5 KB | +5.0 KB | +9.0 KB | +14.0 KB |
7+
| net461 | 5.5 KB | 189.5 KB | +184.0 KB | +8.5 KB | +5.5 KB | +9.0 KB | +14.0 KB |
8+
| net462 | 5.5 KB | 189.5 KB | +184.0 KB | +8.5 KB | +5.5 KB | +9.5 KB | +14.0 KB |
9+
| net47 | 5.5 KB | 189.5 KB | +184.0 KB | +8.5 KB | +5.5 KB | +9.0 KB | +14.0 KB |
10+
| net471 | 5.5 KB | 189.5 KB | +184.0 KB | +8.5 KB | +5.5 KB | +9.0 KB | +14.0 KB |
11+
| net472 | 5.5 KB | 188.5 KB | +183.0 KB | +8.5 KB | +5.5 KB | +9.0 KB | +14.0 KB |
12+
| net48 | 5.5 KB | 188.5 KB | +183.0 KB | +8.5 KB | +5.5 KB | +9.0 KB | +13.5 KB |
13+
| net481 | 5.5 KB | 188.5 KB | +183.0 KB | +8.5 KB | +5.5 KB | +9.0 KB | +14.0 KB |
14+
| netcoreapp2.0 | 9.0 KB | 166.5 KB | +157.5 KB | +8.0 KB | +5.0 KB | +8.5 KB | +13.5 KB |
15+
| netcoreapp2.1 | 9.0 KB | 160.0 KB | +151.0 KB | +8.5 KB | +5.0 KB | +9.0 KB | +14.0 KB |
16+
| netcoreapp2.2 | 9.0 KB | 160.0 KB | +151.0 KB | +8.5 KB | +5.0 KB | +9.0 KB | +14.0 KB |
17+
| netcoreapp3.0 | 9.5 KB | 154.0 KB | +144.5 KB | +8.5 KB | +5.0 KB | +9.0 KB | +13.5 KB |
18+
| netcoreapp3.1 | 9.5 KB | 152.0 KB | +142.5 KB | +8.5 KB | +5.5 KB | +9.0 KB | +14.0 KB |
19+
| net5.0 | 9.5 KB | 131.0 KB | +121.5 KB | +8.0 KB | +5.0 KB | +9.0 KB | +13.5 KB |
20+
| net6.0 | 10.0 KB | 100.0 KB | +90.0 KB | +9.0 KB | +5.5 KB | +1.0 KB | +3.5 KB |
21+
| net7.0 | 10.0 KB | 77.5 KB | +67.5 KB | +9.0 KB | +5.0 KB | +1.0 KB | +3.5 KB |
22+
| net8.0 | 9.5 KB | 62.0 KB | +52.5 KB | +8.5 KB | +1.0 KB | +512 bytes | +3.5 KB |
23+
| net9.0 | 10.0 KB | 36.5 KB | +26.5 KB | +9.0 KB | +1.0 KB | +1.0 KB | +4.0 KB |
24+
| net10.0 | 10.0 KB | 27.5 KB | +17.5 KB | +9.0 KB | +1.5 KB | +1.0 KB | +4.0 KB |
25+
26+
27+
### Assembly Sizes with EmbedUntrackedSources
28+
29+
| | Empty Assembly | With Polyfill | Diff | Ensure | ArgumentExceptions | StringInterpolation | Nullability |
30+
|----------------|----------------|---------------|-----------|-----------|--------------------|---------------------|-------------|
31+
| netstandard2.0 | 8.0 KB | 323.6 KB | +315.6 KB | +16.8 KB | +7.0 KB | +15.3 KB | +19.6 KB |
32+
| netstandard2.1 | 8.5 KB | 288.6 KB | +280.1 KB | +16.8 KB | +7.0 KB | +15.3 KB | +20.1 KB |
33+
| net461 | 5.5 KB | 328.1 KB | +322.6 KB | +16.8 KB | +7.5 KB | +15.3 KB | +20.1 KB |
34+
| net462 | 5.5 KB | 328.1 KB | +322.6 KB | +16.8 KB | +7.5 KB | +15.8 KB | +20.1 KB |
35+
| net47 | 5.5 KB | 328.1 KB | +322.6 KB | +16.8 KB | +7.5 KB | +15.3 KB | +20.1 KB |
36+
| net471 | 5.5 KB | 328.1 KB | +322.6 KB | +16.8 KB | +7.5 KB | +15.3 KB | +20.1 KB |
37+
| net472 | 5.5 KB | 327.1 KB | +321.6 KB | +16.8 KB | +7.5 KB | +15.3 KB | +20.1 KB |
38+
| net48 | 5.5 KB | 327.1 KB | +321.6 KB | +16.8 KB | +7.5 KB | +15.3 KB | +19.6 KB |
39+
| net481 | 5.5 KB | 327.1 KB | +321.6 KB | +16.8 KB | +7.5 KB | +15.3 KB | +20.1 KB |
40+
| netcoreapp2.0 | 9.0 KB | 305.1 KB | +296.1 KB | +16.3 KB | +7.0 KB | +14.8 KB | +19.6 KB |
41+
| netcoreapp2.1 | 9.0 KB | 298.6 KB | +289.6 KB | +16.8 KB | +7.0 KB | +15.3 KB | +20.1 KB |
42+
| netcoreapp2.2 | 9.0 KB | 298.6 KB | +289.6 KB | +16.8 KB | +7.0 KB | +15.3 KB | +20.1 KB |
43+
| netcoreapp3.0 | 9.5 KB | 292.6 KB | +283.1 KB | +16.8 KB | +7.0 KB | +15.3 KB | +19.6 KB |
44+
| netcoreapp3.1 | 9.5 KB | 290.6 KB | +281.1 KB | +16.8 KB | +7.5 KB | +15.3 KB | +20.1 KB |
45+
| net5.0 | 9.5 KB | 269.6 KB | +260.1 KB | +16.3 KB | +7.0 KB | +15.3 KB | +19.6 KB |
46+
| net6.0 | 10.0 KB | 238.6 KB | +228.6 KB | +17.3 KB | +7.5 KB | +7.3 KB | +9.6 KB |
47+
| net7.0 | 10.0 KB | 216.1 KB | +206.1 KB | +17.3 KB | +7.0 KB | +7.3 KB | +9.6 KB |
48+
| net8.0 | 9.5 KB | 200.6 KB | +191.1 KB | +16.8 KB | +3.0 KB | +6.8 KB | +9.6 KB |
49+
| net9.0 | 10.0 KB | 175.1 KB | +165.1 KB | +17.3 KB | +3.0 KB | +7.3 KB | +10.1 KB |
50+
| net10.0 | 10.0 KB | 166.1 KB | +156.1 KB | +17.3 KB | +3.5 KB | +7.3 KB | +10.1 KB |

contributing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ partial class PolyfillTests
386386
var memory = new Memory<char>(result);
387387
using var reader = new StreamReader(stream);
388388
var read = await reader.ReadAsync(memory);
389-
Assert.AreEqual(5, read);
390-
Assert.IsTrue("value".SequenceEqual(result));
389+
await Assert.That(read).IsEqualTo(5);
390+
await Assert.That("value".SequenceEqual(result)).IsTrue();
391391
}
392392

393393
[Test]
@@ -396,7 +396,7 @@ partial class PolyfillTests
396396
using var stream = new MemoryStream("value"u8.ToArray());
397397
using var reader = new StreamReader(stream);
398398
var read = await reader.ReadToEndAsync(Cancel.None);
399-
Assert.AreEqual("value", read);
399+
await Assert.That(read).IsEqualTo("value");
400400
}
401401

402402
[Test]
@@ -405,7 +405,7 @@ partial class PolyfillTests
405405
using var stream = new MemoryStream("line1\nline2"u8.ToArray());
406406
using var reader = new StreamReader(stream);
407407
var read = await reader.ReadLineAsync(Cancel.None);
408-
Assert.AreEqual("line1", read);
408+
await Assert.That(read).IsEqualTo("line1");
409409
}
410410
}
411411
```

readme.md

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The package targets `netstandard2.0` and is designed to support the following ru
1313
* `uap10`
1414

1515

16-
**API count: 657**<!-- singleLineInclude: apiCount. path: /apiCount.include.md -->
16+
**API count: 646**<!-- singleLineInclude: apiCount. path: /apiCount.include.md -->
1717

1818

1919
**See [Milestones](../../milestones?state=closed) for release notes.**
@@ -96,14 +96,14 @@ Reference: [Module Initializers](https://learn.microsoft.com/en-us/dotnet/csharp
9696
static bool InitCalled;
9797

9898
[Test]
99-
public void ModuleInitTest() =>
100-
Assert.True(InitCalled);
99+
public async Task ModuleInitTest() =>
100+
await Assert.That(InitCalled).IsTrue();
101101

102102
[ModuleInitializer]
103103
public static void ModuleInit() =>
104104
InitCalled = true;
105105
```
106-
<sup><a href='/src/Tests/ModuleInitSample.cs#L4-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-ModuleInitializerAttribute' title='Start of snippet'>anchor</a></sup>
106+
<sup><a href='/src/Tests/ModuleInitSample.cs#L3-L15' title='Snippet source file'>snippet source</a> | <a href='#snippet-ModuleInitializerAttribute' title='Start of snippet'>anchor</a></sup>
107107
<!-- endSnippet -->
108108

109109

@@ -225,25 +225,24 @@ If consuming in a project that targets net461 or net462, a reference to System.V
225225
<!-- snippet: IndexRange -->
226226
<a id='snippet-IndexRange'></a>
227227
```cs
228-
[TestFixture]
229228
class IndexRangeSample
230229
{
231230
[Test]
232-
public void Range()
231+
public async Task Range()
233232
{
234233
var substring = "value"[2..];
235-
Assert.AreEqual("lue", substring);
234+
await Assert.That(substring).IsEqualTo("lue");
236235
}
237236

238237
[Test]
239-
public void Index()
238+
public async Task Index()
240239
{
241240
var ch = "value"[^2];
242-
Assert.AreEqual('u', ch);
241+
await Assert.That(ch).IsEqualTo('u');
243242
}
244243

245244
[Test]
246-
public void ArrayIndex()
245+
public async Task ArrayIndex()
247246
{
248247
var array = new[]
249248
{
@@ -253,11 +252,11 @@ class IndexRangeSample
253252

254253
var value = array[^2];
255254

256-
Assert.AreEqual("value1", value);
255+
await Assert.That(value).IsEqualTo("value1");
257256
}
258257
}
259258
```
260-
<sup><a href='/src/Tests/IndexRangeSample.cs#L1-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-IndexRange' title='Start of snippet'>anchor</a></sup>
259+
<sup><a href='/src/Tests/IndexRangeSample.cs#L1-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-IndexRange' title='Start of snippet'>anchor</a></sup>
261260
<!-- endSnippet -->
262261

263262

@@ -278,15 +277,15 @@ class IndexRangeSample
278277
<!-- snippet: OverloadResolutionPriority -->
279278
<a id='snippet-OverloadResolutionPriority'></a>
280279
```cs
281-
[TestFixture]
282280
public class OverloadResolutionPriorityAttributeTests
283281
{
284282
[Test]
285-
public void Run()
283+
public Task Run()
286284
{
287285
int[] arr = [1, 2, 3];
288286
//Prints "Span" because resolution priority is higher
289287
Method(arr);
288+
return Task.CompletedTask;
290289
}
291290

292291
[OverloadResolutionPriority(2)]
@@ -1212,12 +1211,6 @@ The class `Polyfill` includes the following extension methods:
12121211
* `void SetCanceled<T>(CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskcompletionsource-1.setcanceled?view=net-10.0#system-threading-tasks-taskcompletionsource-1-setcanceled(system-threading-cancellationtoken))
12131212

12141213

1215-
#### TaskWhenEach
1216-
1217-
* `IAsyncEnumerable<Task> WhenEach(IEnumerable<Task>, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.wheneach?view=net-10.0)
1218-
* `IAsyncEnumerable<Task<TResult>> WhenEach<TResult>(IEnumerable<Task<TResult>>, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.wheneach?view=net-10.0)
1219-
1220-
12211214
#### TextReader
12221215

12231216
* `ValueTask<int> ReadAsync(Memory<char>, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.textreader.readasync?view=net-10.0#system-io-textreader-readasync(system-memory((system-char))-system-threading-cancellationtoken))
@@ -1252,7 +1245,6 @@ The class `Polyfill` includes the following extension methods:
12521245
* `int Nanoseconds()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.timespan.nanoseconds?view=net-10.0)
12531246
* `bool TryFormat(Span<byte>, int, ReadOnlySpan<char>, IFormatProvider?)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.timespan.tryformat?view=net-10.0#system-timespan-tryformat(system-span((system-byte))-system-int32@-system-readonlyspan((system-char))-system-iformatprovider))
12541247
* `bool TryFormat(Span<char>, int, ReadOnlySpan<char>, IFormatProvider?)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.timespan.tryformat?view=net-10.0#system-timespan-tryformat(system-span((system-char))-system-int32@-system-readonlyspan((system-char))-system-iformatprovider))
1255-
* `TimeSpan FromMilliseconds(long)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.timespan.frommilliseconds?view=net-10.0)
12561248

12571249

12581250
#### Type
@@ -1346,17 +1338,6 @@ The class `Polyfill` includes the following extension methods:
13461338
* `ExternalAttributes` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.externalattributes?view=net-10.0)
13471339

13481340

1349-
#### ZipFile
1350-
1351-
* `Task CreateFromDirectoryAsync(string, string, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.createfromdirectoryasync?view=net-10.0)
1352-
* `Task CreateFromDirectoryAsync(string, string, CompressionLevel, bool, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.createfromdirectoryasync?view=net-10.0)
1353-
* `Task CreateFromDirectoryAsync(string, string, CompressionLevel, bool, Encoding, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.createfromdirectoryasync?view=net-10.0)
1354-
* `Task ExtractToDirectoryAsync(string, string, bool, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.extracttodirectoryasync?view=net-10.0)
1355-
* `Task ExtractToDirectoryAsync(string, string, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.extracttodirectoryasync?view=net-10.0)
1356-
* `Task ExtractToDirectoryAsync(string, string, Encoding, bool, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.extracttodirectoryasync?view=net-10.0)
1357-
* `Task ExtractToDirectoryAsync(string, string, Encoding, CancellationToken)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.extracttodirectoryasync?view=net-10.0)
1358-
1359-
13601341
#### Ensure
13611342

13621343
* `void DirectoryExists(string)`
@@ -1505,7 +1486,7 @@ class NullabilityTarget
15051486
<a id='snippet-NullabilityUsage'></a>
15061487
```cs
15071488
[Test]
1508-
public void Test()
1489+
public async Task Test()
15091490
{
15101491
var type = typeof(NullabilityTarget);
15111492
var arrayField = type.GetField("ArrayField")!;
@@ -1515,14 +1496,14 @@ public void Test()
15151496

15161497
var arrayInfo = context.Create(arrayField);
15171498

1518-
Assert.AreEqual(NullabilityState.NotNull, arrayInfo.ReadState);
1519-
Assert.AreEqual(NullabilityState.Nullable, arrayInfo.ElementType!.ReadState);
1499+
await Assert.That(arrayInfo.ReadState).IsEqualTo(NullabilityState.NotNull);
1500+
await Assert.That(arrayInfo.ElementType!.ReadState).IsEqualTo(NullabilityState.Nullable);
15201501

15211502
var genericInfo = context.Create(genericField);
15221503

1523-
Assert.AreEqual(NullabilityState.NotNull, genericInfo.ReadState);
1524-
Assert.AreEqual(NullabilityState.NotNull, genericInfo.GenericTypeArguments[0].ReadState);
1525-
Assert.AreEqual(NullabilityState.Nullable, genericInfo.GenericTypeArguments[1].ReadState);
1504+
await Assert.That(genericInfo.ReadState).IsEqualTo(NullabilityState.NotNull);
1505+
await Assert.That(genericInfo.GenericTypeArguments[0].ReadState).IsEqualTo(NullabilityState.NotNull);
1506+
await Assert.That(genericInfo.GenericTypeArguments[1].ReadState).IsEqualTo(NullabilityState.Nullable);
15261507
}
15271508
```
15281509
<sup><a href='/src/Tests/NullabilitySamples.cs#L6-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-NullabilityUsage' title='Start of snippet'>anchor</a></sup>
@@ -1595,7 +1576,7 @@ void ArgumentExceptionExample(Order order, Customer customer, string customerId,
15951576
this.quantity = quantity;
15961577
}
15971578
```
1598-
<sup><a href='/src/Consume/Consume.cs#L377-L395' title='Snippet source file'>snippet source</a> | <a href='#snippet-ArgumentExceptionUsage' title='Start of snippet'>anchor</a></sup>
1579+
<sup><a href='/src/Consume/Consume.cs#L378-L396' title='Snippet source file'>snippet source</a> | <a href='#snippet-ArgumentExceptionUsage' title='Start of snippet'>anchor</a></sup>
15991580
<!-- endSnippet -->
16001581

16011582

@@ -1614,7 +1595,7 @@ void EnsureExample(Order order, Customer customer, string customerId, string ema
16141595
this.quantity = Ensure.NotNegativeOrZero(quantity);
16151596
}
16161597
```
1617-
<sup><a href='/src/Consume/Consume.cs#L401-L413' title='Snippet source file'>snippet source</a> | <a href='#snippet-EnsureUsage' title='Start of snippet'>anchor</a></sup>
1598+
<sup><a href='/src/Consume/Consume.cs#L402-L414' title='Snippet source file'>snippet source</a> | <a href='#snippet-EnsureUsage' title='Start of snippet'>anchor</a></sup>
16181599
<!-- endSnippet -->
16191600

16201601

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
34
<TargetFramework>net10.0</TargetFramework>
45
</PropertyGroup>
56
<ItemGroup>
67
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
7-
<PackageReference Include="NUnit" />
8-
<PackageReference Include="NUnit3TestAdapter" />
9-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
8+
<PackageReference Include="TUnit" />
109
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
11-
<Compile Include="..\Tests\SolutionDirectoryFinder.cs">
12-
<Link>SolutionDirectoryFinder.cs</Link>
13-
</Compile>
10+
<PackageReference Include="ProjectFiles" />
1411
</ItemGroup>
1512
</Project>

0 commit comments

Comments
 (0)