未验证 提交 3cad3d24 编写于 作者: T Tlakaelel Axayakatl Ceja 提交者: GitHub

Annotate System.Runtime.Serialization for AOT warnings (#74663)

Annotate System.Runtime.Serialization for AOT warnings
Modify current RUC warnings where they use the word `Type` starting with uppercase to just `type` to be consistent with the rest of the framework
上级 f7870ad3
......@@ -492,8 +492,10 @@ public partial class DataRowView : System.ComponentModel.ICustomTypeDescriptor,
public partial class DataSet : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
{
public DataSet() { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Members from serialized types may use dynamic code generation.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Members from serialized types may use dynamic code generation.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected DataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, bool ConstructSchema) { }
public DataSet(string dataSetName) { }
......@@ -548,6 +550,7 @@ public partial class DataSet : System.ComponentModel.MarshalByValueComponent, Sy
public static System.Xml.Schema.XmlSchemaComplexType GetDataSetSchema(System.Xml.Schema.XmlSchemaSet? schemaSet) { throw null; }
public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
protected virtual System.Xml.Schema.XmlSchema? GetSchemaSerializable() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Members from serialized types may use dynamic code generation.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
protected void GetSerializationData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized types may be trimmed if not referenced directly.")]
......
......@@ -33,6 +33,7 @@ namespace System.Data
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.NonPublicConstructors)] // needed by Clone() to preserve derived ctors
public class DataSet : MarshalByValueComponent, IListSource, IXmlSerializable, ISupportInitializeNotification, ISerializable
{
internal const string RequiresDynamicCodeMessage = "Members from serialized types may use dynamic code generation.";
internal const string RequiresUnreferencedCodeMessage = "Members from serialized types may be trimmed if not referenced directly.";
private const string KEY_XMLSCHEMA = "XmlSchema";
private const string KEY_XMLDIFFGRAM = "XmlDiffGram";
......@@ -217,6 +218,7 @@ protected SchemaSerializationMode DetermineSchemaSerializationMode(XmlReader rea
// Deserialize all the tables data of the dataset from binary/xml stream.
// 'instance' method that consumes SerializationInfo
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
protected void GetSerializationData(SerializationInfo info, StreamingContext context)
{
......@@ -238,6 +240,7 @@ protected void GetSerializationData(SerializationInfo info, StreamingContext con
// Deserialize all the tables schema and data of the dataset from binary/xml stream.
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode",
Justification = "CreateInstanceOfThisType's use of GetType uses only the parameterless constructor, but the annotations preserve all non-public constructors causing a warning for the serialization constructors. Those constructors won't be used here.")]
......@@ -245,6 +248,7 @@ protected DataSet(SerializationInfo info, StreamingContext context) : this(info,
{
}
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode",
Justification = "CreateInstanceOfThisType's use of GetType uses only the parameterless constructor, but the annotations preserve all non-public constructors causing a warning for the serialization constructors. Those constructors won't be used here.")]
......@@ -386,6 +390,7 @@ private void SerializeDataSet(SerializationInfo info, StreamingContext context,
}
// Deserialize all the tables - marked internal so that DataTable can call into this
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
internal void DeserializeDataSet(SerializationInfo info, StreamingContext context, SerializationFormat remotingFormat, SchemaSerializationMode schemaSerializationMode)
{
......@@ -396,6 +401,7 @@ internal void DeserializeDataSet(SerializationInfo info, StreamingContext contex
}
// Deserialize schema.
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
private void DeserializeDataSetSchema(SerializationInfo info, StreamingContext context, SerializationFormat remotingFormat, SchemaSerializationMode schemaSerializationMode)
{
......@@ -455,6 +461,7 @@ private void DeserializeDataSetSchema(SerializationInfo info, StreamingContext c
}
// Deserialize all data.
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
private void DeserializeDataSetData(SerializationInfo info, StreamingContext context, SerializationFormat remotingFormat)
{
......
......@@ -16,12 +16,13 @@ public abstract partial class Formatter : System.Runtime.Serialization.IFormatte
public abstract System.Runtime.Serialization.StreamingContext Context { get; set; }
public abstract System.Runtime.Serialization.ISurrogateSelector? SurrogateSelector { get; set; }
[System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the Type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")]
public abstract object Deserialize(System.IO.Stream serializationStream);
protected virtual object? GetNext(out long objID) { throw null; }
protected virtual long Schedule(object? obj) { throw null; }
[System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the Type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")]
public abstract void Serialize(System.IO.Stream serializationStream, object graph);
protected abstract void WriteArray(object obj, string name, System.Type memberType);
protected abstract void WriteBoolean(bool val, string name);
......@@ -91,10 +92,11 @@ public partial interface IFormatter
System.Runtime.Serialization.StreamingContext Context { get; set; }
System.Runtime.Serialization.ISurrogateSelector? SurrogateSelector { get; set; }
[System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the Type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")]
object Deserialize(System.IO.Stream serializationStream);
[System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the Type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")]
void Serialize(System.IO.Stream serializationStream, object graph);
}
public partial interface ISerializationSurrogate
......@@ -117,23 +119,23 @@ public partial class ObjectIDGenerator
public partial class ObjectManager
{
public ObjectManager(System.Runtime.Serialization.ISurrogateSelector? selector, System.Runtime.Serialization.StreamingContext context) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")]
public virtual void DoFixups() { }
public virtual object? GetObject(long objectID) { throw null; }
public virtual void RaiseDeserializationEvent() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")]
public void RaiseOnDeserializingEvent(object obj) { }
public virtual void RecordArrayElementFixup(long arrayToBeFixed, int index, long objectRequired) { }
public virtual void RecordArrayElementFixup(long arrayToBeFixed, int[] indices, long objectRequired) { }
public virtual void RecordDelayedFixup(long objectToBeFixed, string memberName, long objectRequired) { }
public virtual void RecordFixup(long objectToBeFixed, System.Reflection.MemberInfo member, long objectRequired) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")]
public virtual void RegisterObject(object obj, long objectID) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")]
public void RegisterObject(object obj, long objectID, System.Runtime.Serialization.SerializationInfo info) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")]
public void RegisterObject(object obj, long objectID, System.Runtime.Serialization.SerializationInfo? info, long idOfContainingObj, System.Reflection.MemberInfo? member) { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("ObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")]
public void RegisterObject(object obj, long objectID, System.Runtime.Serialization.SerializationInfo? info, long idOfContainingObj, System.Reflection.MemberInfo? member, int[]? arrayIndex) { }
}
public abstract partial class SerializationBinder
......@@ -146,7 +148,7 @@ public sealed partial class SerializationObjectManager
{
public SerializationObjectManager(System.Runtime.Serialization.StreamingContext context) { }
public void RaiseOnSerializedEvent() { }
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("SerializationObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("SerializationObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.")]
public void RegisterObject(object obj) { }
}
public partial class SurrogateSelector : System.Runtime.Serialization.ISurrogateSelector
......@@ -196,10 +198,11 @@ public sealed partial class BinaryFormatter : System.Runtime.Serialization.IForm
public System.Runtime.Serialization.ISurrogateSelector? SurrogateSelector { get { throw null; } set { } }
public System.Runtime.Serialization.Formatters.FormatterTypeStyle TypeFormat { get { throw null; } set { } }
[System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the Type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")]
public object Deserialize(System.IO.Stream serializationStream) { throw null; }
[System.ObsoleteAttribute("BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information.", DiagnosticId = "SYSLIB0011", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the Type of objects being processed cannot be statically discovered.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.")]
public void Serialize(System.IO.Stream serializationStream, object graph) { }
}
}
......@@ -3,6 +3,7 @@
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-Android</TargetFrameworks>
<!-- ILLinker settings -->
<ILLinkDirectory>$(MSBuildThisFileDirectory)ILLink\</ILLinkDirectory>
<EnableAOTAnalyzer>true</EnableAOTAnalyzer>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
......
......@@ -21,6 +21,7 @@ protected Formatter()
}
[Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresDynamicCode(IFormatter.RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)]
public abstract object Deserialize(Stream serializationStream);
......
......@@ -9,6 +9,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
public sealed partial class BinaryFormatter : IFormatter
{
[Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresDynamicCode(IFormatter.RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)]
public object Deserialize(Stream serializationStream)
{
......
......@@ -9,6 +9,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
public sealed partial class BinaryFormatter : IFormatter
{
[Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresDynamicCode(IFormatter.RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(IFormatter.RequiresUnreferencedCodeMessage)]
public object Deserialize(Stream serializationStream)
=> throw new PlatformNotSupportedException(SR.BinaryFormatter_SerializationNotSupportedOnThisPlatform);
......
......@@ -12,6 +12,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
internal sealed class ObjectReader
{
private const string ObjectReaderUnreferencedCodeMessage = "ObjectReader requires unreferenced code";
private const string ObjectReaderDynamicCodeMessage = "ObjectReader requires dynamic code";
// System.Serializer information
internal Stream _stream;
......@@ -74,6 +75,7 @@ internal ObjectReader(Stream stream, ISurrogateSelector? selector, StreamingCont
_formatterEnums = formatterEnums;
}
[RequiresDynamicCode(ObjectReaderUnreferencedCodeMessage)]
[RequiresUnreferencedCode("Types might be removed")]
internal object Deserialize(BinaryParser serParser)
{
......@@ -170,6 +172,7 @@ internal object CrossAppDomainArray(int index)
return ReadObjectInfo.Create(objectType, memberNames, memberTypes, _surrogates, _context, _objectManager, _serObjectInfoInit, _formatterConverter, _isSimpleAssembly);
}
[RequiresDynamicCode(ObjectReaderDynamicCodeMessage)]
[RequiresUnreferencedCode(ObjectReaderUnreferencedCodeMessage)]
internal void Parse(ParseRecord pr)
{
......@@ -217,6 +220,7 @@ private void ParseError(ParseRecord processing, ParseRecord onStack)
private void ParseSerializedStreamHeaderEnd(ParseRecord pr) => _stack!.Pop();
// New object encountered in stream
[RequiresDynamicCode(ObjectReaderDynamicCodeMessage)]
[RequiresUnreferencedCode(ObjectReaderUnreferencedCodeMessage)]
private void ParseObject(ParseRecord pr)
{
......@@ -357,6 +361,7 @@ private void ParseObjectEnd(ParseRecord pr)
}
// Array object encountered in stream
[RequiresDynamicCode(ObjectReaderDynamicCodeMessage)]
[RequiresUnreferencedCode(ObjectReaderUnreferencedCodeMessage)]
private void ParseArray(ParseRecord pr)
{
......@@ -523,6 +528,7 @@ private void NextRectangleMap(ParseRecord pr)
// Array object item encountered in stream
[RequiresDynamicCode(ObjectReaderDynamicCodeMessage)]
[RequiresUnreferencedCode(ObjectReaderUnreferencedCodeMessage)]
private void ParseArrayMember(ParseRecord pr)
{
......@@ -697,6 +703,7 @@ private void ParseArrayMember(ParseRecord pr)
objectPr._memberIndex++;
}
[RequiresDynamicCode(ObjectReaderDynamicCodeMessage)]
[RequiresUnreferencedCode(ObjectReaderUnreferencedCodeMessage)]
private void ParseArrayMemberEnd(ParseRecord pr)
{
......@@ -708,6 +715,7 @@ private void ParseArrayMemberEnd(ParseRecord pr)
}
// Object member encountered in stream
[RequiresDynamicCode(ObjectReaderDynamicCodeMessage)]
[RequiresUnreferencedCode(ObjectReaderUnreferencedCodeMessage)]
private void ParseMember(ParseRecord pr)
{
......@@ -821,6 +829,7 @@ private void ParseMember(ParseRecord pr)
}
// Object member end encountered in stream
[RequiresDynamicCode(ObjectReaderDynamicCodeMessage)]
[RequiresUnreferencedCode(ObjectReaderUnreferencedCodeMessage)]
private void ParseMemberEnd(ParseRecord pr)
{
......
......@@ -13,6 +13,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
internal sealed class BinaryParser
{
private const string BinaryParserUnreferencedCodeMessage = "ObjectReader requires unreferenced code";
private const string BinaryParserDynamicCodeMessage = "ObjectReader requires dynamic code";
private const int ChunkSize = 4096;
private static readonly Encoding s_encoding = new UTF8Encoding(false, true);
......@@ -69,6 +70,7 @@ internal BinaryParser(Stream stream, ObjectReader objectReader)
// Reads each record from the input stream. If the record is a primitive type (A number)
// then it doesn't have a BinaryHeaderEnum byte. For this case the expected type
// has been previously set to Primitive
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
internal void Run()
{
......@@ -307,6 +309,7 @@ internal void ReadAssembly(BinaryHeaderEnum binaryHeaderEnum)
AssemIdToAssemblyTable[record._assemId] = new BinaryAssemblyInfo(record._assemblyString!);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
private void ReadObject()
{
......@@ -375,6 +378,7 @@ private void ReadObject()
_objectReader.Parse(pr);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
internal void ReadCrossAppDomainMap()
{
......@@ -398,6 +402,7 @@ internal void ReadCrossAppDomainMap()
}
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
internal void ReadObjectWithMap(BinaryHeaderEnum binaryHeaderEnum)
{
......@@ -413,6 +418,7 @@ internal void ReadObjectWithMap(BinaryHeaderEnum binaryHeaderEnum)
ReadObjectWithMap(_bowm);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode("Types might be removed")]
private void ReadObjectWithMap(BinaryObjectWithMap record)
{
......@@ -500,6 +506,7 @@ private void ReadObjectWithMap(BinaryObjectWithMap record)
_objectReader.Parse(pr);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode("Types might be removed")]
internal void ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
{
......@@ -515,6 +522,7 @@ internal void ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
ReadObjectWithMapTyped(_bowmt);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode("Types might be removed")]
private void ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
{
......@@ -596,6 +604,7 @@ private void ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
_objectReader.Parse(pr);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
private void ReadObjectString(BinaryHeaderEnum binaryHeaderEnum)
{
......@@ -667,6 +676,7 @@ private void ReadObjectString(BinaryHeaderEnum binaryHeaderEnum)
_objectReader.Parse(PRs);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
private void ReadMemberPrimitiveTyped()
{
......@@ -712,6 +722,7 @@ private void ReadMemberPrimitiveTyped()
_objectReader.Parse(PRs);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
private void ReadArray(BinaryHeaderEnum binaryHeaderEnum)
{
......@@ -895,6 +906,7 @@ private void ReadArrayAsBytes(ParseRecord pr)
}
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
private void ReadMemberPrimitiveUnTyped()
{
......@@ -925,6 +937,7 @@ private void ReadMemberPrimitiveUnTyped()
_objectReader.Parse(PRs);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
private void ReadMemberReference()
{
......@@ -953,6 +966,7 @@ private void ReadMemberReference()
_objectReader.Parse(PRs);
}
[RequiresDynamicCode(BinaryParserDynamicCodeMessage)]
[RequiresUnreferencedCode(BinaryParserUnreferencedCodeMessage)]
private void ReadObjectNull(BinaryHeaderEnum binaryHeaderEnum)
{
......
......@@ -8,9 +8,11 @@ namespace System.Runtime.Serialization
{
public interface IFormatter
{
internal const string RequiresUnreferencedCodeMessage = "BinaryFormatter serialization is not trim compatible because the Type of objects being processed cannot be statically discovered.";
internal const string RequiresDynamicCodeMessage = "BinaryFormatter serialization uses dynamic code generation, the type of objects being processed cannot be statically discovered.";
internal const string RequiresUnreferencedCodeMessage = "BinaryFormatter serialization is not trim compatible because the type of objects being processed cannot be statically discovered.";
[Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
object Deserialize(Stream serializationStream);
[Obsolete(Obsoletions.BinaryFormatterMessage, DiagnosticId = Obsoletions.BinaryFormatterDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
......
......@@ -14,7 +14,7 @@ public class ObjectManager
private const int ArrayMask = MaxArraySize - 1;
private const int MaxReferenceDepth = 100;
private const string ObjectManagerUnreferencedCodeMessage = "ObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.";
private const string ObjectManagerUnreferencedCodeMessage = "ObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.";
private static readonly FieldInfo s_nullableValueField = typeof(Nullable<>).GetField("value", BindingFlags.NonPublic | BindingFlags.Instance)!;
......
......@@ -8,7 +8,7 @@ namespace System.Runtime.Serialization
{
public sealed class SerializationObjectManager
{
private const string SerializationObjectManagerUnreferencedCodeMessage = "SerializationObjectManager is not trim compatible because the Type of objects being managed cannot be statically discovered.";
private const string SerializationObjectManagerUnreferencedCodeMessage = "SerializationObjectManager is not trim compatible because the type of objects being managed cannot be statically discovered.";
private readonly Dictionary<object, object> _objectSeenTable; // Table to keep track of objects [OnSerializing] has been called on
private readonly StreamingContext _context;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册