Skip to content

Commit

Permalink
Resolve ILLink warnings on System.Private.DataContractSerialization P…
Browse files Browse the repository at this point in the history
…art 1; Json) (#50619)

* Resolve ILLink warnings on System.Private.DataContractSerialization (Part 1; Json)

* Marking other two constructors as Unsafe

* Refactor GetInvokeMethod into a single suppressed call
  • Loading branch information
joperezr authored Apr 8, 2021
1 parent ae820d0 commit f22214b
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,87 +21,81 @@
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<argument>IL2046</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.ClassDataContract.ClassDataContractCriticalHelper.SetKeyValuePairAdapterFlags(System.Type)</property>
<property name="Target">M:System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.InternalReadObject(System.Runtime.Serialization.XmlReaderDelegator,System.Boolean)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<argument>IL2046</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.CollectionDataContract.CollectionDataContractCriticalHelper.GetCollectionElementType</property>
<property name="Target">M:System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.InternalWriteObject(System.Runtime.Serialization.XmlWriterDelegator,System.Object)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<argument>IL2046</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.CollectionDataContract.CollectionDataContractCriticalHelper.IncrementCollectionCount(System.Runtime.Serialization.XmlWriterDelegator,System.Object,System.Runtime.Serialization.XmlObjectSerializerWriteContext)</property>
<property name="Target">M:System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.InternalWriteObjectContent(System.Runtime.Serialization.XmlWriterDelegator,System.Object)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<argument>IL2046</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.CollectionDataContract.IsCollectionOrTryCreate(System.Type,System.Boolean,System.Runtime.Serialization.DataContract@,System.Type@,System.Boolean)</property>
<property name="Target">M:System.Runtime.Serialization.Json.ReflectionJsonReader.ReflectionReadDictionaryItem(System.Runtime.Serialization.XmlReaderDelegator,System.Runtime.Serialization.XmlObjectSerializerReadContext,System.Runtime.Serialization.CollectionDataContract)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<argument>IL2046</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractAdapterType(System.Type)</property>
<property name="Target">M:System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(System.Runtime.Serialization.DataContract,System.Runtime.Serialization.XmlReaderDelegator)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<argument>IL2046</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes(System.Type,System.Collections.Generic.Dictionary{System.Type,System.Type},System.Collections.Generic.Dictionary{System.Xml.XmlQualifiedName,System.Runtime.Serialization.DataContract}@)</property>
<property name="Target">M:System.Runtime.Serialization.Json.XmlObjectSerializerWriteContextComplexJson.WriteDataContractValue(System.Runtime.Serialization.DataContract,System.Runtime.Serialization.XmlWriterDelegator,System.Object,System.RuntimeTypeHandle)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Globals.get_TypeOfHashtable</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.AddCollectionItemTypeToKnownTypes(System.Type)</property>
<property name="Target">M:System.Runtime.Serialization.ClassDataContract.ClassDataContractCriticalHelper.SetKeyValuePairAdapterFlags(System.Type)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonDataContract.JsonDataContractCriticalHelper.AddCollectionItemContractsToKnownDataContracts</property>
<property name="Target">M:System.Runtime.Serialization.CollectionDataContract.CollectionDataContractCriticalHelper.GetCollectionElementType</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.GenerateClassReader(System.Runtime.Serialization.ClassDataContract)</property>
<property name="Target">M:System.Runtime.Serialization.CollectionDataContract.CollectionDataContractCriticalHelper.IncrementCollectionCount(System.Runtime.Serialization.XmlWriterDelegator,System.Object,System.Runtime.Serialization.XmlObjectSerializerWriteContext)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.ReadCollection(System.Runtime.Serialization.CollectionDataContract)</property>
<property name="Target">M:System.Runtime.Serialization.CollectionDataContract.IsCollectionOrTryCreate(System.Type,System.Boolean,System.Runtime.Serialization.DataContract@,System.Type@,System.Boolean)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.WrapNullableObject(System.Reflection.Emit.LocalBuilder,System.Reflection.Emit.LocalBuilder,System.Int32)</property>
<property name="Target">M:System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractAdapterType(System.Type)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatWriterGenerator.CriticalHelper.InitArgs(System.Type)</property>
<property name="Target">M:System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes(System.Type,System.Collections.Generic.Dictionary{System.Type,System.Type},System.Collections.Generic.Dictionary{System.Xml.XmlQualifiedName,System.Runtime.Serialization.DataContract}@)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2055</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatWriterGenerator.CriticalHelper.WriteCollection(System.Runtime.Serialization.CollectionDataContract)</property>
<property name="Target">M:System.Runtime.Serialization.Globals.get_TypeOfHashtable</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
Expand Down Expand Up @@ -169,18 +163,6 @@
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.FastInvokerBuilder.GetMakeNewInstanceFunc(System.Type)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2060</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.ReadCollection(System.Runtime.Serialization.CollectionDataContract)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2060</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatWriterGenerator.CriticalHelper.WriteCollection(System.Runtime.Serialization.CollectionDataContract)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2060</argument>
Expand Down Expand Up @@ -229,12 +211,6 @@
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.XmlFormatReaderGenerator.UnsafeGetUninitializedObject(System.Type)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2067</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.SurrogateDataContract.GetUninitializedObject(System.Type)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2070</argument>
Expand Down Expand Up @@ -271,18 +247,6 @@
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes(System.Type,System.Collections.Generic.Dictionary{System.Type,System.Type},System.Collections.Generic.Dictionary{System.Xml.XmlQualifiedName,System.Runtime.Serialization.DataContract}@)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2070</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.BeginMethod(System.Runtime.Serialization.CodeGenerator,System.String,System.Type,System.Boolean)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2070</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatWriterGenerator.CriticalHelper.BeginMethod(System.Runtime.Serialization.CodeGenerator,System.String,System.Type,System.Boolean)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2070</argument>
Expand Down Expand Up @@ -361,36 +325,6 @@
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.EnumDataContract.EnumDataContractCriticalHelper.ImportDataMembers</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.CreateObject(System.Runtime.Serialization.ClassDataContract)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.ReadCollection(System.Runtime.Serialization.CollectionDataContract)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.ReadISerializable(System.Runtime.Serialization.ClassDataContract)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatReaderGenerator.CriticalHelper.WrapNullableObject(System.Reflection.Emit.LocalBuilder,System.Reflection.Emit.LocalBuilder,System.Int32)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
<property name="Scope">member</property>
<property name="Target">M:System.Runtime.Serialization.Json.JsonFormatWriterGenerator.CriticalHelper.WriteCollection(System.Runtime.Serialization.CollectionDataContract)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Security;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization.Json;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -131,7 +132,7 @@ internal void BeginMethod(DynamicMethod dynamicMethod, Type delegateType, string

internal void BeginMethod(string methodName, Type delegateType, bool allowPrivateMemberAccess)
{
MethodInfo signature = delegateType.GetMethod("Invoke")!;
MethodInfo signature = JsonFormatWriterGenerator.GetInvokeMethod(delegateType);
ParameterInfo[] parameters = signature.GetParameters();
Type[] paramTypes = new Type[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
Expand Down
Loading

0 comments on commit f22214b

Please sign in to comment.