Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't shim OperatingSystem.IsWindows() #57

Open
kohanyirobert opened this issue Feb 25, 2025 · 0 comments
Open

Couldn't shim OperatingSystem.IsWindows() #57

kohanyirobert opened this issue Feb 25, 2025 · 0 comments

Comments

@kohanyirobert
Copy link

kohanyirobert commented Feb 25, 2025

I'm trying to shim OperatingSystem.IsWindows() but bump into an error. Shimmed call seem to return null.

I created a minimal working example, here: https://github.com/kohanyirobert/pose-os-shim/

This uses .NET 8, same happens in .NET 9 tho'.

Is this even possible? The underlying method uses conditional compilation (using #if WINDOWS or such), not sure if this is an issue or not.

> dotnet test
Restore complete (0,2s)
  pose-os-shim succeeded (0,4s) → bin\Debug\net8.0\pose-os-shim.dll
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.0.2+dd36e86129 (64-bit .NET 8.0.13)
[xUnit.net 00:00:00.21]   Discovering: pose-os-shim
[xUnit.net 00:00:00.35]   Discovered:  pose-os-shim
[xUnit.net 00:00:00.51]   Starting:    pose-os-shim
[xUnit.net 00:00:00.58]     poser_os_shim.UnitTest1.Test1 [FAIL]
[xUnit.net 00:00:00.58]       Assert.False() Failure
[xUnit.net 00:00:00.58]       Expected: False
[xUnit.net 00:00:00.58]       Actual:   null
[xUnit.net 00:00:00.58]       Stack Trace:
[xUnit.net 00:00:00.58]            at impl_Xunit.Assert_False(Nullable`1, String)
[xUnit.net 00:00:00.58]            at impl_poser_os_shim.UnitTest1+<>c_<Test1>b__0_2(<>c)
[xUnit.net 00:00:00.58]            at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
[xUnit.net 00:00:00.58]            at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
[xUnit.net 00:00:00.59]   Finished:    pose-os-shim
  pose-os-shim test failed with 1 error(s) (1,3s)
    C:\Users\rkohanyi\Work\pose-os-shim\bin\Debug\net8.0\pose-os-shim.dll : error TESTERROR:
      poser_os_shim.UnitTest1.Test1 (41ms): Error Message: Assert.False() Failure
      Expected: False
      Actual:   null
      Stack Trace:
         at impl_Xunit.Assert_False(Nullable`1, String)
         at impl_poser_os_shim.UnitTest1+<>c_<Test1>b__0_2(<>c)
         at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
         at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Test summary: total: 1; failed: 1; succeeded: 0; skipped: 0; duration: 1,3s
Build failed with 1 error(s) in 2,4s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant