* Split Random compat implementation to address most regressions
When we introduced the new Random algorithm, we did so by factoring the old algorithm out into an implementation strategy class that is instantiated for all use other than `new Random()`. This ends up penalizing other uses (providing a seed and/or deriving from Random) by adding more virtual dispatch than is strictly necessary, in particular for `new Random(seed)`. This PR negates most of that (expected) regression by splitting the compat implementation in two, one class for `new Random(seed)` and one for `new DerivedRandom()`/`new DerivedRandom(seed)`; the former no longer needs to make virtual calls back out to the parent type. The former is also one that a consumer can't really do anything to improve, whereas in the derived case, the derivation may override to provide a more optimal implementation.
* Change NextUInt64 implementation to reduce number of calls
We haven't shipped this yet, so we can change its implementation to make 3 calls instead of 8 and to delegate to a different overload of Next.
* Consolidate NextBytes to use span
* [libraries] Update AppDomainTests for iOS,MacCatalyst,tvOS
* Update skip reasons
* Add MacCatalyst to Case Insensitive and remove ActiveIssues
* Replace ActiveIssue with ConditionalTheory based on RemoteExecutor
* Fix test for iOS/tvOS/Catalyst
* Skip UserName test on iOS tvOS
Co-authored-by: Mitchell Hwang <[email protected]>
Co-authored-by: Alexander Köplinger <[email protected]>
1. AppDomain TestingCreateInstanceFromObjectHandle and TestingCreateInstanceFromObjectHandleFullSignature were failing because the assembly file to load has to be case sensitive and wasn't.
2. AppDomain TargetFrameworkTest was permanently skipped
3. StringComparerTests CreateFromCultureAndOptions, CreateFromCultureAndOptionsStringSort, and CreateWithCulturesTest skips testing the turkish culture as it's problematic on Android
4. Environment.Exit ExitCode_VoidMainAppReturnsSetValue was permanently skipped
Fixes https://github.com/dotnet/runtime/issues/49868
It's to clean up the respective CI staging lanes.
The related issues:
[iOS/tvOS/MacCatalyst] Test failures in System.Diagnostics.Tracing.Tests #56073
[libraries][iOSSimulator] ImageTests.FromFile_NullFileName_ThrowsArgumentNullException fails #56048
JitInfoIsPopulated failed with after is not greater than before #55712
[MacCatalyst] Test failures in System.Tests.OperatingSystemTests #56084
[MacCatalyst] App crash in System.Text.Json.SourceGeneration.Tests #56085
```
[22:22:31] fail: [FAIL] System.Tests.EnvironmentStackTrace.StackTraceDoesNotStartWithInternalFrame
[22:22:31] info: System.NullReferenceException : Object reference not set to an instance of an object.
[22:22:31] info: at System.Reflection.RuntimeMethodInfo.Invoke(Object , BindingFlags , Binder , Object[] , CultureInfo )
```
Issue: https://github.com/dotnet/runtime/issues/51676
* 32bit
* 64bit
* Expose in public api
* Unit test
* Add more tests
* Use in test
* Apply suggestions from code review
Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
* Add unsigned variants for BitConverter bit APIs
Adds DoubleToUInt64Bits, UInt64BitsToDouble, SingleToUInt32Bits,
UInt32BitsToSingle, HalfToUInt16Bits and UInt16BitsToHalf.
Implementations were based on existing signed integer variants.
Convert usages of existing APIs to unsigned variants when appropriate.
Fix#36469
* Revert comment change
Reverted a comment change made in the existing code by mistake.
* Use existing code for implementations
Use the existing signed methods with a cast, less code with the same codegen.
* Cast correction
Corrected the type used in a cast.
In effort to assess the state of the iOS library tests, a number of tests will be skipped
Test suites that crash, hang, or have a significant number of failures (mostly 20+ failing unique test methods) are skipped on at the `tests.proj` level. Otherwise, `[ActiveIssue]` attributes have been attached to either the individual test methods that fail or the entire class if the whole test class fails. Any pre-existing `ActiveIssue` attribute associated with iOS had been reassessed to either remain or be closed.
A few test suites have been skipped because they fail with some form of `PlatformNotSupportedException`. `[SkipOnPlatform]` attributes are attached to the failing test methods.
All of the Issues can be tracked at https://github.com/dotnet/runtime/projects/48#column-9236436
The ActiveIssues and `tests.proj` exclusions have been tested on https://github.com/dotnet/runtime/pull/49917 as well.
-----------
This PR makes the following changes in the following files:
`src/libraries/System.IO.Ports/tests/System.IO.Ports.Tests.csproj` - Removed `$(NetCoreAppCurrent)-iOS` from target frameworks as it is stated to currently only supported on Windows.
`src/libraries/tests.proj` - Update the test suites that need to be skipped at the project level, reducing the number and categorizing as a skip due to PNSE, a skip due to numerous failures, and a skip due to the suite crashing.
The remaining files changed are either:
`[ActiveIssue("<issue-url>", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]`
`[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS or tvOS.")]`
Co-authored-by: Mitchell Hwang <[email protected]>
Co-authored-by: Tammy Qiu <[email protected]>
* replacing GetLastWin32Error with GetLastPInvokeError in remaining assemblies
* replace GetLastWin32Error with GetLastPInvokeError in assemblies outside system.private.corelib
* Apply suggestions from code review
Co-authored-by: Jan Kotas <[email protected]>
- Both EAT, and AOT builds are completely green now.
- Number of tests for EAT goes from 147 -> 185
- Number of tests for AOT goes from 147 -> 174 (the difference is because of aot only failures)
- Test run on a regular wasm build runs 206 libraries
* Fix Random.Next(int, int) on 64-bit when max-min overflow int
The fix is a missing cast. Everything else is asserts and test changes.
* Update Random.cs
We have a bunch of test assemblies that don't make sense on some platforms, e.g. Browser.
Right now we're skipping them via `[SkipOnMono("reason", TestPlatforms.Browser)]` but there's nothing that inherently ties this to Mono other than the current implementation.
The more generic `SkipOnPlatform` attribute can be used instead.
We can also use it in places where we do `[PlatformSpecific(~TestPlatforms....)]` to avoid the double inversion.
* Disable failing Apple Silicon Libraries tests
- Use tests.proj to disable catastrophically failing libraries tests
- Add ActiveIssues where XUnit didn't crash
* Enable CoreCLR lib tests for Apple Silicon in Runtime-Staging
* Use IntegralValue() instead of IconValue() in constant folding for PopCount so that CNS_LNGs work on 32 bit targets
* Move the PopCount(Constant) test to the runtime tests directory
Initial support for Mac Catalyst for mono subset. This enables building runtime packs and working jobs, but right now the `tests` subset needs some work to allow library test runs in CI
* Added C# implementation of System.Math.ScaleB and System.MathF.ScaleB, removed old bindings, added test cases.
* Moved tests into System.Runtime.Extensions tests.
* Removed unmanaged scalbn and scalbnf from pal and mono
* Update src/libraries/System.Private.CoreLib/src/System/Math.cs
Co-authored-by: Adeel Mujahid <[email protected]>
* Styling changes.
* Conditionally include ScaleB for Mono.
* Update src/mono/mono/metadata/sysmath.c
Tabs, not spaces.
Co-authored-by: Adeel Mujahid <[email protected]>
* Removing more scalb from PAL
* Completely removed ScaleB from Mono
* Cleaning up more scalbn
* Added comments for ScaleB, updated licenses for musl and Sun
* Fixed whitespace.
* Removing old references, fixing double ScaleB definition that merge didn't resolve
Co-authored-by: Adeel Mujahid <[email protected]>
* Delete custom FastRandom from ThreadPool
- Consolidates 128/256-bit variants of Xoshiro** into the same class name
- Uses that from ThreadPool instead of its custom xorshift-based algorithm
Throughput stays the same (~2.5ns per next random value) and incurs just one additional object allocation per thread pool thread.
* Consolidate TARGET_64/32BIT DefineConstants
* Improve Random (performance, APIs, ...)
- Changes the algorithm used by `new Random()` to be one that's smaller and faster and produces better results
- Refactors the implementation to make it internally pluggable
- Moves the existing implementation to be used when it's necessary for back compat
- Adds NextInt64 and NextSingle methods
* Adding support for ReciprocalEstimate and ReciprocalSqrtEstimate
* Adding basic documentation comments to the new Math.ReciprocalEstimate functions
* Increasing the epsilon for estimated functions to account for ARM64 only doing a single Newton-Raphson iteration
* Adding support for Math/MathF.SinCos
* Fix the handling of sincos on __APPLE__
* Adjusting the SinCos internal call to work on all platforms
* Mark the public SinCos as intrinsic and ensure it is handled in gentree
* Dropping the NI_System_Math_SinCos intrinsic as it requires more extensive changes
* Removing unnecessary casts from the COMSingle and COMDouble SinCos calls
* Adding System.Math overloads for nint/nuint
* Adding a missing cast
* Fixing the Clamp_NInt and Clamp_NUInt tests to work with the provided MemberData