* Generate dynamic serialization assembly in the appropriate ALC, and don't keep any hard refs to types that could prevent unloading.
* Add small test for ALC unloading.
* PR feedback; Move into TempAssembly; Strong/Weak lookup tables; Test refinement
* Refining TempAssembly cache; Reflection-based fix; Test corrections
* Mono/wasm test fixup
* Ensure that serializers from XmlMappings don't run afoul of collectible ALCs.
* PR feedback
* Unloadable contexts not yet supported in Mono.
* Fix trimming of types for XmlSerializer tests that got moved out of main test assembly.
* Encapsulating the duality of dealing with unloadable ALC instead of rewriting similar code everywhere.
* Missed new file in last commit.
* Compilation bug not seen locally.
* Perf improvement.
* Remove extraneous line. Test feedback.
* Fix unloadability (#58948)
There is a bug in AppDomain::FindAssembly code path that iterates over
the domain assemblies. The iteration loop leaves the refcount of the
LoaderAllocator related to the returned DomainAssembly bumped, but
nothing ever decrements it. So when a code that needs to be unloaded
ends up in that code path, all the managed things like managed
LoaderAllocator, LoaderAllocatorScout are destroyed, but the unloading
doesn't complete due to the refcount.
We have never found it before as this code path is never executed in any
of the coreclr tests even with unloadability testing option.
(cherry picked from commit 8b38c1973e)
Co-authored-by: Steve Molloy <[email protected]>
Co-authored-by: Jan Vorlicek <[email protected]>
* XmlSerializer support for IsDynamicCodeSupported=false
Add more checks to XmlSerializer to check the SerializationMode. Don't try to use Reflection.Emit if the SerializationMode is ReflectionOnly.
These changes were ported from
* https://github.com/dotnet/runtimelab/pull/593
* https://github.com/dotnet/runtimelab/pull/600Fix#59167
* Fix a bug in XmlSerializer.CanDeserialize when in ReflectionOnly mode.
* Port UAP code for CanDeserialize
* PR feedback
* Add a linker test to ensure linker option '--enable-opt sealer' works when IsDynamicCodeSupported==false.
Co-authored-by: Eric Erhardt <[email protected]>
* Use official Type.GetTypeCode() instead of the extension that was added to fill the gap in the earlier days of .Net Core.
* Bring reflection-based serializer in line with RefEmit behavior for 'object' serialization.
* Allow easier creation of correctly sized dictionaries in scenarios with lots of known namespaces.
* Stop passing internal dictionaries around.
* Reduce enumerations, and immutable-ish improvements.
* PR feedback.
* Use ValueCollection directly instead of IEnumerable<> to avoid virtual calls.
* Update XmlSerializerNamespaces.cs
* Remove old fwlink from Obsolete messages and make message improvements
* Thorough review and update of Obsolete messages
* Cleanup
* Make messages about unsupported APIs more consistent
* Update RequiresUnreferencedCodeAttribute messages to be consistent between ref and src
* Cleanup
* Cleanup
* Use 'not supported' instead of 'no longer supported'
* Omit unnecessary error:false from Obsolete attributes. Fix message typo.
* Remove old comment
* PR feedback
Fixes#50576Fixes#50881Fixes#50916Fixes#50917Fixes#50918Fixes#50919Fixes#50927Fixes#50928Fixes#50944Fixes#50945Fixes#50946Fixes#50947Fixes#50948Fixes#50999
When setting up functional tests for mobile, the feature switches being used for the tests were misplaced in a broader project, affecting the library tests and causing failures. After moving the feature switches to the scope of functional tests as done in #53253, these test suites no longer fail and can be re-enabled.
* Replace a few unnecessary uses of Convert.ToString
* Update src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs
Co-authored-by: Christopher Watford <[email protected]>
Co-authored-by: Christopher Watford <[email protected]>
* Bugfix: System.Xml.Serialization: Compiler.GetTempAssemblyName is not persistent under .NET Core
The implementation of String.GetHashCode() was persistent by default in .NET Framework. allowing to predictably name an XmlSerializers.{HashCode}.dll containing the pre-generated serializers.
In .NET Core / .NET 5, String.GetHashCode() is no longer persistent, so the value of ns.GetHashCode() will change during each run, preventing it from picking up the XmlSerializers dll correctly.
* Remove trailing whitespace
* Use truncated SHA512
* Fixed compilation
* Dispose SHA512 instance
* Fixed compilation
* Update src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update Compiler.cs
Co-authored-by: Stephen Toub <[email protected]>
* Use more string interpolation
I previously did a pass looking for opportunities. Finding a few more, as well as fixing some misuse of existing methods.
* Update src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs
Co-authored-by: halgab <[email protected]>
* Apply suggestions from code review
Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: halgab <[email protected]>
Co-authored-by: Jan Kotas <[email protected]>
* Add DateTimeOffset as a primitive for XmlSerializer.
* Fix DefaultValueAttribute handling for DTO.
* Add tests for DateTimeAttribute and XmlSerializer.
* Missed a 'KnownType' spot.
* Update SGen tests to use current dotnet.exe from build.
* Unbreak runtimeconfig creation for testing.
* Debugging failure to resolve CoreCLR path.
* Test fixup.
* More test cleanup.
* Temporarily disable generator tests.
* Use InitObj instead of constructors for DateTimeOffset and TimeSpan.
* Use a different XmlWriter which will check for invalid characters like null.
* Bring our XmlReader use into the 21st century as well.
* Update src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs
Co-authored-by: Stephen Toub <[email protected]>
* Update src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs
Co-authored-by: Stephen Toub <[email protected]>
* Don't need to specify options that are defaults on XmlWriter.
Co-authored-by: Stephen Toub <[email protected]>
* Preserve necessary type and method
* Change the way of getting the type
* Inline the constants
* Enable NonValidated_ValidAndInvalidValues_DictionaryMembersWork
* Enable TransformStrStrResolver3
It can easily use a static singleton, as the instance is immutable and exists purely to provide a "I don't have line info" / (0,0) value if anyone queries for position.
The array is only used for a subset of validators; no point in paying for this array for every ValidationState instance even if it's not going to be used.
* Remove unnecessary cost from XmlNode.SelectSingleNode
It's currently implemented by delegating to SelectSingleNodes and returning the first one. While the list is lazily-populated, this still entails creating an `XPathNodeList`, creating a `List<XmlNode>`, storing the enumerated into the list, and then returning the element from the list, which is then thrown away. With just a few lines, we can cut through all of that.
* Make XPathScanner and XPathParser into structs
No need for these to be allocated classes. They can just live on the stack where they're created.
* Reduce ScanName overhead
This shows up on the hot path of parsing the xpath expression. We can use a span to avoid bounds checking.
* Avoid bounds check in NextChar
NextChar is used by lots of routines to advance to the next character. We can streamline it to avoid the bounds check when indexing into the string.
* Optimize SkipSpace for there not being any
The typical case is there isn't any whitespace, so inline that fast check. This was showing up as a few percentage of a simple scenario.
* 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.
ArrayList.ToArray(Type) has to lookup the array type in the type loader structures. It makes it slow and potentially AOT unfriendly since the code required to support the array type may not exist.
Convert most uses of ArrayList.ToArray in libraries to use List<T> if possible, or ArrayList.CopyTo if the conversion to List<T> was not straightforward.
Simplified a few other places that created arrays while I was on it.
WSL1 isn't a supported build or execution environment for dotnet/runtime.
Because of that removing the checks and platform detection for it as
that code path isn't necessary for WSL2 anymore as it contains a fully
featured kernel which behaves just a like a usual Linux distro.
Fixes https://github.com/dotnet/runtime/issues/18258
Summary:
Enables single file analyzer in the runtime by adding the ILLink.Analyzers package and the property EnableSingleFileAnalyzer equals to true
Deletes entries IL3000 and IL3001 in the CodeAnalysis.ruleset so the analyzer can actually produce these warnings otherwise the analyzer execution would be skipped. *Note*: tests warnings are controlled by CodeAnalysis.test.ruleset (this PR adds IL3002 to the CodeAnalysis.test.ruleset to disable the warning on tests)
Resolve warnings on single file dangerous patterns by:
- Annotating incompatible single file patterns with RequiresAssemblyFiles
- Suppressing the warning (because there is code that handles the incompatible code)
- Fixing the issue on code (remove the incompatible code and replace it with something that won't fail)
- Opening an issue to track fix and either annotate/suppress the current behavior
After the basic annotation of `Type.GetInterface` and `Type.GetInterfaces` this propagates this annotation to all places which require it. It also resolves warnings in all the places where this shows up.
For the most part this is just blindly propagating the annotations.
Most of the suppressions rely on the fact that is `IFoo` is referenced (and thus the `Type` instance of it exists at runtime), trimmer guarantees that it will keep it on all types which implement that interface. And also on additional fact that if `IFoo<>` is preserved, then all instantiations of it are also preserved. This is true for linker, but not necessarily true for AOT - that is we can do better if we don't have to make that assumption. For now I rely on that assumption.
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]>
- 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