Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Move PosixSignalRegistration to corelib
  • Loading branch information
stephentoub committed Jul 11, 2021
commit ccc9d4caf22f44061db44a76b60f2c677a40a24e
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public static partial class PlatformDetection
public static bool IsSolaris => RuntimeInformation.IsOSPlatform(OSPlatform.Create("SOLARIS"));
public static bool IsBrowser => RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"));
public static bool IsNotBrowser => !IsBrowser;
public static bool IsNotMobile => IsNotBrowser && !IsMacCatalyst && !IsiOS && !IstvOS && !IsAndroid;
public static bool IsMobile => IsBrowser || IsMacCatalyst || IsiOS || IstvOS || IsAndroid;
public static bool IsNotMobile => !IsMobile;
public static bool IsNotNetFramework => !IsNetFramework;

public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NFloat.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\OptionalAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\OutAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignalContext.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignalRegistration.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PreserveSigAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\ProgIdAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\SafeArrayRankMismatchException.cs" />
Expand Down Expand Up @@ -1235,6 +1238,7 @@
</ItemGroup>
<ItemGroup Condition="'$(IsMobileLike)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Loader\AssemblyDependencyResolver.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignalRegistration.PlatformNotSupported.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonPath)Interop\Windows\Advapi32\Interop.ActivityControl.cs">
Expand Down Expand Up @@ -1651,6 +1655,9 @@
<Compile Include="$(CommonPath)Interop\Windows\Interop.OBJECT_ATTRIBUTES.cs">
<Link>Common\Interop\Windows\Interop.OBJECT_ATTRIBUTES.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetConsoleCtrlHandler.cs">
<Link>Common\Interop\Windows\Interop.SetConsoleCtrlHandler.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetCurrentDirectory.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.SetCurrentDirectory.cs</Link>
</Compile>
Expand Down Expand Up @@ -1833,6 +1840,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\MemoryFailPoint.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\Marshal.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NativeMemory.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignalRegistration.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\StandardOleMarshalObject.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SecureString.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelMonitor.Windows.cs" />
Expand Down Expand Up @@ -2129,6 +2137,10 @@
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.GetPid.cs">
<Link>Common\Interop\Unix\System.Native\Interop.GetPid.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.InitializeTerminalAndSignalHandling.cs"
Link="Common\Interop\Unix\Interop.InitializeTerminalAndSignalHandling.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.PosixSignal.cs"
Link="Common\Interop\Unix\Interop.PosixSignal.cs" />
<Compile Include="$(CommonPath)Interop\FreeBSD\Interop.Process.GetProcInfo.cs" Condition="'$(TargetsFreeBSD)' == 'true'"
Link="Common\Interop\FreeBSD\Interop.Process.GetProcInfo.cs" />
<Compile Include="$(CommonPath)Interop\BSD\System.Native\Interop.Sysctl.cs" Condition="'$(TargetsFreeBSD)' == 'true'"
Expand All @@ -2151,6 +2163,9 @@
<Compile Include="$(MSBuildThisFileDirectory)System\IO\DriveInfoInternal.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\PersistedFiles.Unix.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(IsMobileLike)' != 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\PosixSignalRegistration.Unix.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\AppContext.Browser.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Environment.Browser.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,4 @@
<data name="ArgumentOutOfRange_FileLengthTooBig" xml:space="preserve">
<value>Specified file length was too large for the file system.</value>
</data>
<data name="IO_AlreadyExists_Name" xml:space="preserve">
<value>Cannot create '{0}' because a file or directory with the same name already exists.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<Nullable>enable</Nullable>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Runtime\CompilerServices\IDispatchConstantAttribute.cs" />
Expand Down Expand Up @@ -33,9 +33,6 @@
<Compile Include="System\Runtime\InteropServices\ImportedFromTypeLibAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\ManagedToNativeComInteropStubAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\PrimaryInteropAssemblyAttribute.cs" />
<Compile Include="System\Runtime\InteropServices\PosixSignal.cs" />
<Compile Include="System\Runtime\InteropServices\PosixSignalContext.cs" />
<Compile Include="System\Runtime\InteropServices\PosixSignalRegistration.cs" />
<Compile Include="System\Runtime\InteropServices\RegistrationClassContext.cs" />
<Compile Include="System\Runtime\InteropServices\RegistrationConnectionType.cs" />
<Compile Include="System\Runtime\InteropServices\RuntimeEnvironment.cs" />
Expand All @@ -51,27 +48,7 @@
<Compile Include="System\Security\SecureStringMarshal.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs" Link="Common\System\Obsoletions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="System\Runtime\InteropServices\PosixSignalRegistration.Unix.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.PosixSignal.cs" Link="Common\Interop\Unix\Interop.PosixSignal.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.InitializeTerminalAndSignalHandling.cs" Link="Common\Interop\Unix\Interop.InitializeTerminalAndSignalHandling.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs" Link="Common\Interop\Unix\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.Errors.cs" Link="Common\CoreLib\Interop\Unix\Interop.Errors.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.IOErrors.cs" Link="Common\Interop\Unix\Interop.IOErrors.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="System\Runtime\InteropServices\PosixSignalRegistration.Windows.cs" />
<Compile Include="$(CommonPath)System\IO\Win32Marshal.cs" Link="Common\System\IO\Win32Marshal.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.BOOL.cs" Link="Common\Interop\Windows\Interop.BOOL.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Errors.cs" Link="Common\Interop\Windows\Interop.Errors.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs" Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.FormatMessage.cs" Link="Common\Interop\Windows\Interop.FormatMessage.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetConsoleCtrlHandler.cs" Link="Common\Interop\Windows\Interop.SetConsoleCtrlHandler.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<Compile Include="System\Runtime\InteropServices\PosixSignalRegistration.Unsupported.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(CoreLibProject)" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix</TargetFrameworks>
<TestRuntime>true</TestRuntime>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
</PropertyGroup>
Expand Down Expand Up @@ -192,7 +192,4 @@
<Compile Include="System\Runtime\InteropServices\PosixSignalRegistrationTests.Unix.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs" Link="Common\Interop\Unix\Interop.Libraries.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<Compile Include="System\Runtime\InteropServices\PosixSignalRegistrationTests.Browser.cs" />
</ItemGroup>
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,37 @@ public partial class PosixSignalRegistrationTests
{
public static IEnumerable<object[]> UninstallableSignals()
{
yield return new object[] { (PosixSignal)9 };
if (PlatformDetection.IsNotMobile)
{
yield return new object[] { (PosixSignal)9 };
}
}

public static IEnumerable<object[]> SupportedSignals()
{
foreach (PosixSignal value in Enum.GetValues(typeof(PosixSignal)))
yield return new object[] { value };
if (PlatformDetection.IsNotMobile)
{
foreach (PosixSignal value in Enum.GetValues(typeof(PosixSignal)))
yield return new object[] { value };
}
}

public static IEnumerable<object[]> UnsupportedSignals()
{
if (PlatformDetection.IsMobile)
{
foreach (PosixSignal value in Enum.GetValues(typeof(PosixSignal)))
yield return new object[] { value };
}

yield return new object[] { 0 };
yield return new object[] { -1000 };
yield return new object[] { 1000 };
}

[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public static bool NotMobileAndRemoteExecutable => PlatformDetection.IsNotMobile && RemoteExecutor.IsSupported;

[ConditionalTheory(nameof(NotMobileAndRemoteExecutable))]
[MemberData(nameof(SupportedSignals))]
public void SignalHandlerCalledForKnownSignals(PosixSignal s)
{
Expand All @@ -55,7 +69,7 @@ public void SignalHandlerCalledForKnownSignals(PosixSignal s)
}, s.ToString()).Dispose();
}

[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
[ConditionalTheory(nameof(NotMobileAndRemoteExecutable))]
[MemberData(nameof(PosixSignalAsRawValues))]
public void SignalHandlerCalledForRawSignals(PosixSignal s)
{
Expand All @@ -80,7 +94,7 @@ public void SignalHandlerCalledForRawSignals(PosixSignal s)
}, s.ToString()).Dispose();
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile))]
public void SignalHandlerWorksForSecondRegistration()
{
PosixSignal signal = PosixSignal.SIGCONT;
Expand All @@ -104,7 +118,7 @@ public void SignalHandlerWorksForSecondRegistration()
}
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile))]
public void SignalHandlerNotCalledWhenDisposed()
{
PosixSignal signal = PosixSignal.SIGCONT;
Expand All @@ -118,7 +132,7 @@ public void SignalHandlerNotCalledWhenDisposed()
Thread.Sleep(100);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile))]
public void SignalHandlerNotCalledWhenFinalized()
{
PosixSignal signal = PosixSignal.SIGCONT;
Expand All @@ -140,7 +154,7 @@ void CreateDanglingRegistration()
}
}

[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
[ConditionalTheory(nameof(NotMobileAndRemoteExecutable))]
[InlineData(PosixSignal.SIGINT, true, 0)]
[InlineData(PosixSignal.SIGINT, false, 130)]
[InlineData(PosixSignal.SIGTERM, true, 0)]
Expand Down