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
1 change: 1 addition & 0 deletions api_list.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
#### Environment

* `ProcessId` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.environment.processid?view=net-11.0#system-environment-processid)
* `ProcessPath` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.environment.processpath?view=net-11.0#system-environment-processpath)


#### EventInfo
Expand Down
5 changes: 5 additions & 0 deletions src/Consume/Consume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,11 @@ void Enum_Methods()
values = Enum.GetValuesAsUnderlyingType<DayOfWeek>();
}

void Environment_Methods()
{
var processPath = Environment.ProcessPath;
}

void EnumerationOptions_Methods()
{
var options = new EnumerationOptions
Expand Down
30 changes: 27 additions & 3 deletions src/Polyfill/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#if !NET5_0_OR_GREATER

namespace Polyfills;

using System;
using System.Diagnostics;

static partial class Polyfill
{
#if !NET5_0_OR_GREATER
static int processId;

extension(Environment)
Expand All @@ -29,5 +28,30 @@ public static int ProcessId
}
}
}
}
#endif

#if !NET6_0_OR_GREATER
static string? processPath;

extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.environment.processpath?view=net-11.0#system-environment-processpath
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}

return processPath;
}
}
}
#endif
}
19 changes: 19 additions & 0 deletions src/Split/net461/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/net462/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/net47/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/net471/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/net472/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/net48/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/net481/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
27 changes: 27 additions & 0 deletions src/Split/net5.0/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <auto-generated />
#pragma warning disable
namespace Polyfills;
using System;
using System.Diagnostics;
static partial class Polyfill
{
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/netcoreapp2.0/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/netcoreapp2.1/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/netcoreapp2.2/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/netcoreapp3.0/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
19 changes: 19 additions & 0 deletions src/Split/netcoreapp3.1/EnvironmentPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,23 @@ public static int ProcessId
}
}
}
static string? processPath;
extension(Environment)
{
/// <summary>
/// Gets the path of the executable that started the currently executing process.
/// </summary>
public static string? ProcessPath
{
get
{
if (processPath is null)
{
using var process = Process.GetCurrentProcess();
processPath = process.MainModule?.FileName;
}
return processPath;
}
}
}
}
Loading