121 [
UnconditionalSuppressMessage(
"SingleFile",
"IL3000: Avoid accessing Assembly file path when publishing as a single file", Justification =
"Annotating this as dangerous will make the core of the serializer to be marked as not safe, instead this pattern is only dangerous if using sgen only. See https://github.com/dotnet/runtime/issues/50820")]
200 [
UnconditionalSuppressMessage(
"SingleFile",
"IL3000: Avoid accessing Assembly file path when publishing as a single file", Justification =
"Annotating this as dangerous will make the core of the serializer to be marked as not safe, instead this pattern is only dangerous if using sgen only. See https://github.com/dotnet/runtime/issues/50820")]
207 if (!
string.IsNullOrEmpty(
type.Assembly.Location))
219 if (!
string.IsNullOrEmpty(
text))
236 if (serializer ==
null)
257 for (
int i = 0; i <
modules.Length; i++)
283 hashtable.Keys.CopyTo(
array, 0);
300 for (
int k = 0;
k <
types.Length;
k++)
307 indentedWriter.WriteLine(
"[assembly:System.Security.AllowPartiallyTrustedCallers()]");
308 indentedWriter.WriteLine(
"[assembly:System.Security.SecurityTransparent()]");
309 indentedWriter.WriteLine(
"[assembly:System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]");
312 for (
int l = 0;
l <
types.Length;
l++)
327 if (defaultNamespace !=
null)
335 codeIdentifiers.AddUnique(
"XmlSerializationWriter",
"XmlSerializationWriter");
336 codeIdentifiers.AddUnique(
"XmlSerializationReader",
"XmlSerializationReader");
346 indentedWriter.WriteLine(
"namespace Microsoft.Xml.Serialization.GeneratedAssembly {");
349 string text2 =
"XmlSerializationWriter" +
text;
360 string text3 =
"XmlSerializationReader" +
text;
404 string name =
"Microsoft.GeneratedCode";
409 string text =
types[0].Assembly.GetName().Version.ToString();
413 codeIdentifiers.AddUnique(
"XmlSerializationWriter",
"XmlSerializationWriter");
414 codeIdentifiers.AddUnique(
"XmlSerializationReader",
"XmlSerializationReader");
425 string text3 =
"XmlSerializationWriter" +
text2;
436 string text4 =
"XmlSerializationReader" +
text2;
458 return type.Assembly;
475 typeName =
"Microsoft.Xml.Serialization.GeneratedAssembly." + typeName;
507 if (
encodingStyle !=
"http://schemas.xmlsoap.org/soap/encoding/" &&
encodingStyle !=
"http://www.w3.org/2003/05/soap-encoding")
512 else if (
_methods[methodKey].isSoap)
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
static string BaseDirectory
bool ContainsKey(TKey key)
void Add(TKey key, TValue value)
static CultureInfo InvariantCulture
static bool Exists([NotNullWhen(true)] string? path)
static string Combine(string path1, string path2)
static ? string GetDirectoryName(string? path)
static Assembly Load(string assemblyString)
static ? Assembly GetEntryAssembly()
static Assembly LoadFile(string path)
virtual object[] GetCustomAttributes(bool inherit)
static Assembly LoadFrom(string assemblyFile)
static string FailLoadAssemblyUnderPregenMode
static string XmlPregenTypeDynamic
static string Format(string resourceFormat, object p1)
static string XmlInvalidEncoding3
static string XmlNotSerializable
static string XmlNoPartialTrust
static string CompilingScriptsNotSupported
static string XmlPregenInvalidXmlSerializerAssemblyAttribute
static string XmlMissingType
static string XmlInvalidEncodingNotEncoded1
static ModuleBuilder CreateModuleBuilder(AssemblyBuilder assemblyBuilder, string name)
static AssemblyBuilder CreateAssemblyBuilder(string name)
static string MakeValid(string identifier)
static string GetTempAssemblyName(AssemblyName parent, string ns)
static bool IsTypeDynamic(Type type)
static void WriteQuotedCSharpString(IndentedWriter writer, string value)
void InvokeWriter(XmlMapping mapping, XmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces, string encodingStyle, string id)
TempMethodDictionary _methods
TempAssembly(XmlMapping[] xmlMappings, Assembly assembly, XmlSerializerImplementation contract)
IDictionary _writerMethods
static Assembly LoadGeneratedAssembly(Type type, string defaultNamespace, out XmlSerializerImplementation contract)
IDictionary _readerMethods
XmlSerializerImplementation _contract
static bool IsSerializerVersionMatch(Assembly serializer, Type type, string defaultNamespace)
static Type GetTypeFromAssembly(Assembly assembly, string typeName)
static MethodInfo GetMethodFromType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type, string methodName)
bool CanRead(XmlMapping mapping, XmlReader xmlReader)
readonly Assembly _assembly
object InvokeReader(XmlMapping mapping, XmlReader xmlReader, XmlDeserializationEvents events, string encodingStyle)
TempAssembly(XmlMapping[] xmlMappings, Type[] types, string defaultNamespace, string location)
static string GenerateAssemblyId(Type type)
string ValidateEncodingStyle(string encodingStyle, string methodKey)
static Assembly LoadAssemblyByPath(Type type, string assemblyName)
void InitAssemblyMethods(XmlMapping[] xmlMappings)
static Assembly GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[] types, string defaultNamespace)
XmlSerializerImplementation Contract
static bool UseLegacySerializerGeneration
static bool GenerateSerializerToStream(XmlMapping[] xmlMappings, Type[] types, string defaultNamespace, Assembly assembly, Hashtable assemblies, Stream stream)
static XmlSerializationEventSource Log
virtual XmlSerializationWriter Writer
virtual XmlSerializationReader Reader
virtual Hashtable WriteMethods
virtual Hashtable ReadMethods
static SerializationMode Mode
DynamicallyAccessedMemberTypes