Skip to content

Commit 1442bfe

Browse files
committed
.
1 parent e9b663d commit 1442bfe

31 files changed

+413
-38
lines changed

src/ApiBuilderTests/Splitter.cs

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,12 @@
1-
using System.Text.RegularExpressions;
2-
using System.Runtime.CompilerServices;
3-
41
/// <summary>
52
/// Splits Polyfill source files by target framework, evaluating conditional compilations.
63
/// Unknown symbols (like Feature*) are preserved in the output.
74
/// </summary>
85
public class Splitter
96
{
10-
static readonly string SolutionDir = FindSolutionDirectory();
11-
static readonly string PolyfillDir = Path.Combine(SolutionDir, "Polyfill");
12-
13-
/// <summary>
14-
/// The directory where split files are written.
15-
/// </summary>
16-
public static readonly string SplitOutputDir = Path.Combine(SolutionDir, "Split");
7+
static readonly string PolyfillDir = Path.Combine(ProjectFiles.SolutionDirectory, "Polyfill");
178

18-
/// <summary>
19-
/// Finds the solution directory by navigating up from the source file location.
20-
/// Falls back to ProjectFiles.SolutionDirectory if the source file approach fails.
21-
/// </summary>
22-
static string FindSolutionDirectory([CallerFilePath] string sourceFilePath = "")
23-
{
24-
// Try to find the solution directory from the source file path
25-
// The source file is at: src/ApiBuilderTests/Splitter.cs
26-
// The solution directory is: src/
27-
if (!string.IsNullOrEmpty(sourceFilePath))
28-
{
29-
var dir = Path.GetDirectoryName(sourceFilePath);
30-
if (dir != null)
31-
{
32-
var parentDir = Path.GetDirectoryName(dir);
33-
if (parentDir != null && Directory.Exists(Path.Combine(parentDir, "Polyfill")))
34-
{
35-
return parentDir;
36-
}
37-
}
38-
}
39-
40-
// Fall back to ProjectFiles.SolutionDirectory
41-
return ProjectFiles.SolutionDirectory;
42-
}
9+
public static readonly string SplitOutputDir = Path.Combine(ProjectFiles.SolutionDirectory, "Split");
4310

4411
/// <summary>
4512
/// All target frameworks to generate splits for.
@@ -620,9 +587,9 @@ string SimplifyUnary()
620587
return "true";
621588
}
622589
// Check if inner starts with ! and simplify double negation
623-
if (inner.StartsWith("!"))
590+
if (inner.StartsWith('!'))
624591
{
625-
return inner.Substring(1);
592+
return inner[1..];
626593
}
627594
return $"!{inner}";
628595
}
@@ -644,7 +611,7 @@ string SimplifyPrimary()
644611
_pos++;
645612
}
646613
// Only keep parens if needed (contains || and was inside an && context)
647-
if (result.Contains("||") && !result.StartsWith("("))
614+
if (result.Contains("||") && !result.StartsWith('('))
648615
{
649616
return $"({result})";
650617
}

src/Split/net10.0/Polyfill_Process.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ namespace Polyfills;
88
using System.Threading.Tasks;
99
static partial class Polyfill
1010
{
11+
#if WINDOWS_UWP
12+
/// <summary>
13+
/// Immediately stops the associated process, and optionally its child/descendent processes.
14+
/// Maps to <see cref="Process.Kill"/>.
15+
/// </summary>
16+
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.kill?view=net-10.0#system-diagnostics-process-kill(system-boolean)
17+
[SupportedOSPlatform("maccatalyst")]
18+
[UnsupportedOSPlatform("ios")]
19+
[UnsupportedOSPlatform("tvos")]
20+
public static void Kill(this Process target, bool entireProcessTree) =>
21+
target.Kill();
22+
#endif
1123
#if !NET
1224
/// <summary>
1325
/// Instructs the Process component to wait for the associated process to exit, or
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
// <auto-generated />
22
#pragma warning disable
33
#if FeatureMemory
4+
#if WINDOWS_UWP
5+
#nullable enable
6+
namespace System.Buffers;
7+
using System.Diagnostics;
8+
using System.Diagnostics.CodeAnalysis;
9+
#if PolyUseEmbeddedAttribute
10+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
11+
#endif
12+
// Encapsulates a method that receives a read-only span of objects of type T and a state object of type TArg.
13+
// https://learn.microsoft.com/en-us/dotnet/api/system.buffers.readonlyspanaction-2?view=net-10.0
14+
#if PolyPublic
15+
public
16+
#endif
17+
delegate void ReadOnlySpanAction<T, in TArg>(ReadOnlySpan<T> span, TArg arg);
18+
#else
419
using System.Buffers;
520
using System.Runtime.CompilerServices;
621
[assembly: TypeForwardedTo(typeof(ReadOnlySpanAction<,>))]
22+
#endif
723
#endif

src/Split/net10.0/SpanAction.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
// <auto-generated />
22
#pragma warning disable
33
#if FeatureMemory
4+
#if WINDOWS_UWP
5+
#nullable enable
6+
namespace System.Buffers;
7+
using System.Diagnostics;
8+
using System.Diagnostics.CodeAnalysis;
9+
#if PolyUseEmbeddedAttribute
10+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
11+
#endif
12+
// Encapsulates a method that receives a span of objects of type T and a state object of type TArg.
13+
// https://learn.microsoft.com/en-us/dotnet/api/system.buffers.spanaction-2?view=net-10.0
14+
#if PolyPublic
15+
public
16+
#endif
17+
delegate void SpanAction<T, in TArg>(Span<T> span, TArg arg);
18+
#else
419
using System.Buffers;
520
using System.Runtime.CompilerServices;
621
[assembly: TypeForwardedTo(typeof(SpanAction<,>))]
22+
#endif
723
#endif

src/Split/net5.0/Polyfill_Process.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ namespace Polyfills;
88
using System.Threading.Tasks;
99
static partial class Polyfill
1010
{
11+
#if WINDOWS_UWP
12+
/// <summary>
13+
/// Immediately stops the associated process, and optionally its child/descendent processes.
14+
/// Maps to <see cref="Process.Kill"/>.
15+
/// </summary>
16+
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.kill?view=net-10.0#system-diagnostics-process-kill(system-boolean)
17+
[SupportedOSPlatform("maccatalyst")]
18+
[UnsupportedOSPlatform("ios")]
19+
[UnsupportedOSPlatform("tvos")]
20+
public static void Kill(this Process target, bool entireProcessTree) =>
21+
target.Kill();
22+
#endif
1123
#if !NET
1224
/// <summary>
1325
/// Instructs the Process component to wait for the associated process to exit, or
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
// <auto-generated />
22
#pragma warning disable
33
#if FeatureMemory
4+
#if WINDOWS_UWP
5+
#nullable enable
6+
namespace System.Buffers;
7+
using System.Diagnostics;
8+
using System.Diagnostics.CodeAnalysis;
9+
#if PolyUseEmbeddedAttribute
10+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
11+
#endif
12+
// Encapsulates a method that receives a read-only span of objects of type T and a state object of type TArg.
13+
// https://learn.microsoft.com/en-us/dotnet/api/system.buffers.readonlyspanaction-2?view=net-10.0
14+
#if PolyPublic
15+
public
16+
#endif
17+
delegate void ReadOnlySpanAction<T, in TArg>(ReadOnlySpan<T> span, TArg arg);
18+
#else
419
using System.Buffers;
520
using System.Runtime.CompilerServices;
621
[assembly: TypeForwardedTo(typeof(ReadOnlySpanAction<,>))]
22+
#endif
723
#endif

src/Split/net5.0/SpanAction.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
// <auto-generated />
22
#pragma warning disable
33
#if FeatureMemory
4+
#if WINDOWS_UWP
5+
#nullable enable
6+
namespace System.Buffers;
7+
using System.Diagnostics;
8+
using System.Diagnostics.CodeAnalysis;
9+
#if PolyUseEmbeddedAttribute
10+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
11+
#endif
12+
// Encapsulates a method that receives a span of objects of type T and a state object of type TArg.
13+
// https://learn.microsoft.com/en-us/dotnet/api/system.buffers.spanaction-2?view=net-10.0
14+
#if PolyPublic
15+
public
16+
#endif
17+
delegate void SpanAction<T, in TArg>(Span<T> span, TArg arg);
18+
#else
419
using System.Buffers;
520
using System.Runtime.CompilerServices;
621
[assembly: TypeForwardedTo(typeof(SpanAction<,>))]
22+
#endif
723
#endif

src/Split/net6.0/Polyfill_Process.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ namespace Polyfills;
88
using System.Threading.Tasks;
99
static partial class Polyfill
1010
{
11+
#if WINDOWS_UWP
12+
/// <summary>
13+
/// Immediately stops the associated process, and optionally its child/descendent processes.
14+
/// Maps to <see cref="Process.Kill"/>.
15+
/// </summary>
16+
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.kill?view=net-10.0#system-diagnostics-process-kill(system-boolean)
17+
[SupportedOSPlatform("maccatalyst")]
18+
[UnsupportedOSPlatform("ios")]
19+
[UnsupportedOSPlatform("tvos")]
20+
public static void Kill(this Process target, bool entireProcessTree) =>
21+
target.Kill();
22+
#endif
1123
#if !NET
1224
/// <summary>
1325
/// Instructs the Process component to wait for the associated process to exit, or
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
// <auto-generated />
22
#pragma warning disable
33
#if FeatureMemory
4+
#if WINDOWS_UWP
5+
#nullable enable
6+
namespace System.Buffers;
7+
using System.Diagnostics;
8+
using System.Diagnostics.CodeAnalysis;
9+
#if PolyUseEmbeddedAttribute
10+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
11+
#endif
12+
// Encapsulates a method that receives a read-only span of objects of type T and a state object of type TArg.
13+
// https://learn.microsoft.com/en-us/dotnet/api/system.buffers.readonlyspanaction-2?view=net-10.0
14+
#if PolyPublic
15+
public
16+
#endif
17+
delegate void ReadOnlySpanAction<T, in TArg>(ReadOnlySpan<T> span, TArg arg);
18+
#else
419
using System.Buffers;
520
using System.Runtime.CompilerServices;
621
[assembly: TypeForwardedTo(typeof(ReadOnlySpanAction<,>))]
22+
#endif
723
#endif

src/Split/net6.0/SpanAction.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
// <auto-generated />
22
#pragma warning disable
33
#if FeatureMemory
4+
#if WINDOWS_UWP
5+
#nullable enable
6+
namespace System.Buffers;
7+
using System.Diagnostics;
8+
using System.Diagnostics.CodeAnalysis;
9+
#if PolyUseEmbeddedAttribute
10+
[global::Microsoft.CodeAnalysis.EmbeddedAttribute]
11+
#endif
12+
// Encapsulates a method that receives a span of objects of type T and a state object of type TArg.
13+
// https://learn.microsoft.com/en-us/dotnet/api/system.buffers.spanaction-2?view=net-10.0
14+
#if PolyPublic
15+
public
16+
#endif
17+
delegate void SpanAction<T, in TArg>(Span<T> span, TArg arg);
18+
#else
419
using System.Buffers;
520
using System.Runtime.CompilerServices;
621
[assembly: TypeForwardedTo(typeof(SpanAction<,>))]
22+
#endif
723
#endif

0 commit comments

Comments
 (0)