-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
1388 xml serializer assembly load context awareness #58932
Changes from 9 commits
4647d16
55eb88b
d9e96dc
b6f110a
8616e29
88778c4
15b7517
2c82165
da3c8c1
0d37491
6ab0bcd
f160c1b
454a9fe
d361830
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ namespace System.Xml.Serialization | |
using System.Xml.Serialization; | ||
using System.Xml; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Runtime.CompilerServices; | ||
|
||
///<internalonly/> | ||
public abstract class XmlSerializationWriter : XmlSerializationGeneratedCode | ||
|
@@ -1465,13 +1466,13 @@ internal static class DynamicAssemblies | |
{ | ||
private static readonly Hashtable s_nameToAssemblyMap = new Hashtable(); | ||
private static readonly Hashtable s_assemblyToNameMap = new Hashtable(); | ||
private static readonly Hashtable s_tableIsTypeDynamic = Hashtable.Synchronized(new Hashtable()); | ||
private static readonly ConditionalWeakTable<Type, object> s_tableIsTypeDynamic = new ConditionalWeakTable<Type, object>(); | ||
|
||
StephenMolloy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// SxS: This method does not take any resource name and does not expose any resources to the caller. | ||
// It's OK to suppress the SxS warning. | ||
internal static bool IsTypeDynamic(Type type) | ||
{ | ||
object? oIsTypeDynamic = s_tableIsTypeDynamic[type]; | ||
s_tableIsTypeDynamic.TryGetValue(type, out object? oIsTypeDynamic); | ||
if (oIsTypeDynamic == null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confident this isn't on a hot code path for RefEmit serializer, but what about the reflection based serializer? Does this get called for every object that's being serialized or is it an initialization only usage? If the former, then this needs to do the dual table route. |
||
{ | ||
Assembly assembly = type.Assembly; | ||
|
@@ -1500,7 +1501,7 @@ internal static bool IsTypeDynamic(Type type) | |
} | ||
} | ||
} | ||
s_tableIsTypeDynamic[type] = oIsTypeDynamic = isTypeDynamic; | ||
s_tableIsTypeDynamic.AddOrUpdate(type, oIsTypeDynamic = isTypeDynamic); | ||
} | ||
return (bool)oIsTypeDynamic; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are still using a ConditionalWeakTable for lookups even when using the default ALC. This will regress a lot as every single property set will hit this method and based on looking at the code for CWT, it's going to be expensive. This is used on a hot code path. You need to do the double table approach for this too.