Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1322449
Fix Private.Xml solution broken by https://github.com/dotnet/runtime/…
StephenMolloy Jun 28, 2022
fe3c017
Align DCS with 4.8 implementation - minus schema import/export.
StephenMolloy Jun 29, 2022
335adfe
External DCS Schema support groundwork. Before DC-tree work and other…
StephenMolloy Jul 3, 2022
6dfd3c4
Added public APIs, but not the DataContract tree yet.
StephenMolloy Jul 6, 2022
71d4ab4
All APIs in.
StephenMolloy Jul 7, 2022
4eb08fb
Cleanup.
StephenMolloy Jul 7, 2022
ec2518d
Addressed some nits and PR feedback on API.
StephenMolloy Jul 8, 2022
ec64156
Merge branch 'main' into dcs-alignment-with-schema-support
StephenMolloy Jul 8, 2022
1183287
API nit, more PR feedback.
StephenMolloy Jul 10, 2022
92b1d63
Fix HasRoot hiding issue.
StephenMolloy Jul 11, 2022
79da1a7
Add basic schema tests. Fix DataMember bug.
StephenMolloy Jul 12, 2022
9a13158
Add /// comments for new schema project.
StephenMolloy Jul 12, 2022
3b376ab
Fixing bad format in xml comment.
StephenMolloy Jul 12, 2022
2127ba8
Skip import test on Wasm.
StephenMolloy Jul 12, 2022
4c3417c
Obsolete old half-coded schema exporter.
StephenMolloy Jul 12, 2022
54b6b39
Add obsolete attribute in ref project as well.
StephenMolloy Jul 12, 2022
7308470
Removing obsolete for now, since it appears Syndication depends on ol…
StephenMolloy Jul 13, 2022
6be7bbc
Fix the DCJS ref project.
StephenMolloy Jul 13, 2022
446c993
API cleanup.
StephenMolloy Jul 14, 2022
8157957
Project file cleanup
StephenMolloy Jul 14, 2022
0956064
Merge branch 'main' into dcs-alignment-with-schema-support
ViktorHofer Jul 14, 2022
f1414b8
Fix mono issue with reflection access to non-public private fields.
StephenMolloy Jul 15, 2022
36267a6
Merge branch 'dcs-alignment-with-schema-support' of https://github.co…
StephenMolloy Jul 15, 2022
bf6d5dd
Addressing feedback from API review.
StephenMolloy Jul 29, 2022
df5f444
Merge branch 'main' into dcs-alignment-with-schema-support
StephenMolloy Jul 29, 2022
e868642
Port NetFx Export/Import test suites to Serializer test projects.
StephenMolloy Aug 2, 2022
24ca75c
Fix bugs found by newly ported tests.
StephenMolloy Aug 2, 2022
6b65e43
Merge branch 'dcs-alignment-with-schema-support' of https://github.co…
StephenMolloy Aug 2, 2022
ded55f6
Account for different newline sizes on different platforms.
StephenMolloy Aug 3, 2022
7462bea
Skip flaky test on wasm for now.
StephenMolloy Aug 3, 2022
7bbdbee
Non-draft PR feedback.
StephenMolloy Aug 11, 2022
be324a7
Gentle nudge for Azure pipeline, which seems to have gotten stuck.
StephenMolloy Aug 11, 2022
08d419c
Change DC.Members API. Drop KVP shennanigans.
StephenMolloy Aug 12, 2022
4f555bc
More PR feedback.
StephenMolloy Aug 12, 2022
80fd11b
Nudge Azure pipelines again. :(
StephenMolloy Aug 12, 2022
f8ebd1a
nudge
StephenMolloy Aug 12, 2022
01517c7
nudge again.
StephenMolloy Aug 13, 2022
b7100af
One more nudge.
StephenMolloy Aug 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressed some nits and PR feedback on API.
  • Loading branch information
StephenMolloy committed Jul 8, 2022
commit ec2518dc1552ac653092f7acac220ac89b13bada
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
using System.Threading;
using System.Xml;

using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
internal sealed class ClassDataContract : DataContract
{
internal const string ContractTypeString = "ClassDataContract";
internal const string ContractTypeString = nameof(ClassDataContract);
public override string? ContractType => ContractTypeString;

public XmlDictionaryString[]? ContractNamespaces;
Expand Down Expand Up @@ -121,7 +121,7 @@ public override bool IsISerializable

internal bool HasExtensionData => _helper.HasExtensionData;

internal string? SerialiazationExceptionMessage => _helper.SerializationExceptionMessage;
internal string? SerializationExceptionMessage => _helper.SerializationExceptionMessage;
internal string? DeserializationExceptionMessage => _helper.DeserializationExceptionMessage;

internal bool IsReadOnlyContract => DeserializationExceptionMessage != null;
Expand Down Expand Up @@ -599,10 +599,6 @@ private sealed class ClassDataContractCriticalHelper : DataContract.DataContract
private bool _hasDataContract;
private bool _hasExtensionData;

private XmlDictionaryString?[]? _childElementNamespaces;
private XmlFormatClassReaderDelegate? _xmlFormatReaderDelegate;
private XmlFormatClassWriterDelegate? _xmlFormatWriterDelegate;

public XmlDictionaryString[]? ContractNamespaces;
public XmlDictionaryString[]? MemberNames;
public XmlDictionaryString[]? MemberNamespaces;
Expand Down Expand Up @@ -688,7 +684,7 @@ internal ClassDataContractCriticalHelper([DynamicallyAccessedMembers(DataContrac
{
if (BaseClassContract.IsReadOnlyContract)
{
_serializationExceptionMessage = BaseClassContract.SerialiazationExceptionMessage;
_serializationExceptionMessage = BaseClassContract.SerializationExceptionMessage;
}
baseMemberCount = BaseClassContract.MemberNames!.Length;
MemberNames = new XmlDictionaryString[Members.Count + baseMemberCount];
Expand Down Expand Up @@ -1193,14 +1189,6 @@ internal override DataContractDictionary? KnownDataContracts
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
get
{
// NOTE TODO smolloy - Oddly, this shortcut was not here in NetFx. I'm not sure this was added strictly as a perf-optimization though.
// See https://github.com/dotnet/runtime/commit/5d2dba7ffcc4ad6a11a570f5bd8d1964000099ea
// This shouldn't change between invocations though, right? So seems like a good thing to leave in.
if (_knownDataContracts != null)
{
return _knownDataContracts;
}

if (!_isKnownTypeAttributeChecked && UnderlyingType != null)
{
lock (this)
Expand Down Expand Up @@ -1264,23 +1252,11 @@ internal override bool IsISerializable
return ctor;
}

internal XmlFormatClassWriterDelegate? XmlFormatWriterDelegate
{
get => _xmlFormatWriterDelegate;
set => _xmlFormatWriterDelegate = value;
}
internal XmlFormatClassWriterDelegate? XmlFormatWriterDelegate { get; set; }

internal XmlFormatClassReaderDelegate? XmlFormatReaderDelegate
{
get => _xmlFormatReaderDelegate;
set => _xmlFormatReaderDelegate = value;
}
internal XmlFormatClassReaderDelegate? XmlFormatReaderDelegate { get; set; }

public XmlDictionaryString?[]? ChildElementNamespaces
{
get => _childElementNamespaces;
set => _childElementNamespaces = value;
}
public XmlDictionaryString?[]? ChildElementNamespaces { get; set; }

private static Type[] SerInfoCtorArgs => s_serInfoCtorArgs ??= new Type[] { typeof(SerializationInfo), typeof(StreamingContext) };

Expand Down Expand Up @@ -1317,7 +1293,7 @@ public int Compare(Member x, Member y)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
public override DataContract BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract> boundContracts)
public override DataContract BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
{
Type type = UnderlyingType;
if (!type.IsGenericType || !type.ContainsGenericParameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using System.Threading;
using System.Xml;

using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -77,7 +77,7 @@ internal enum CollectionKind : byte

internal sealed class CollectionDataContract : DataContract
{
internal const string ContractTypeString = "CollectionDataContract";
internal const string ContractTypeString = nameof(CollectionDataContract);
public override string? ContractType => ContractTypeString;

private XmlDictionaryString _collectionItemName;
Expand Down Expand Up @@ -1339,7 +1339,7 @@ private static bool IsKnownInterface(Type type)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
public override DataContract BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract> boundContracts)
public override DataContract BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
{
DataContract boundContract;
if (boundContracts.TryGetValue(this, out boundContract!))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using System.Text;
using System.Xml;

using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -274,7 +274,7 @@ internal virtual void WriteRootElement(XmlWriterDelegator writer, XmlDictionaryS
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
public virtual DataContract BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract> boundContracts)
public virtual DataContract BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
{
return this;
}
Expand Down Expand Up @@ -2026,7 +2026,7 @@ private static void ImportKnownTypeAttributes(Type? type, Dictionary<Type, Type>
collectionDataContract.ItemType.GetGenericTypeDefinition() == Globals.TypeOfKeyValue)
{
DataContract itemDataContract = DataContract.GetDataContract(Globals.TypeOfKeyValuePair.MakeGenericType(collectionDataContract.ItemType.GetGenericArguments()));
knownDataContracts ??= new DataContractDictionary();
knownDataContracts ??= new Dictionary<XmlQualifiedName, DataContract>();

knownDataContracts.TryAdd(itemDataContract.StableName, itemDataContract);
}
Expand All @@ -2050,7 +2050,7 @@ internal static void CheckAndAdd(Type type, Dictionary<Type, Type> typesChecked,
DataContract dataContract = DataContract.GetDataContract(type);
if (nameToDataContractTable == null)
{
nameToDataContractTable = new DataContractDictionary();
nameToDataContractTable = new Dictionary<XmlQualifiedName, DataContract>();
}
else if (nameToDataContractTable.TryGetValue(dataContract.StableName, out DataContract? alreadyExistingContract))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Runtime.CompilerServices;
using System.Xml;

using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Text;
using System.Xml.Schema;

using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -54,10 +54,10 @@ public DataContractSet(DataContractSet dataContractSet)
}
}

internal DataContractDictionary Contracts =>
_contracts ??= new DataContractDictionary();
public DataContractDictionary Contracts =>
_contracts ??= new Dictionary<XmlQualifiedName, DataContract>();

public Dictionary<DataContract, object> ProcessedContracts =>
public IDictionary<DataContract, object> ProcessedContracts =>
_processedContracts ??= new Dictionary<DataContract, object>();

private Hashtable SurrogateDataTable => _surrogateDataTable ??= new Hashtable();
Expand Down Expand Up @@ -515,7 +515,7 @@ internal void SetContractProcessed(DataContract dataContract)
ProcessedContracts.Add(dataContract, dataContract);
}

public IEnumerator<KeyValuePair<XmlQualifiedName, DataContract>> GetEnumerator()
internal IEnumerator<KeyValuePair<XmlQualifiedName, DataContract>> GetEnumerator()
{
return Contracts.GetEnumerator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ internal bool RequiresMemberAccessForSet()
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal DataMember BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract> boundContracts)
internal DataMember BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
{
DataContract memberTypeContract = MemberTypeContract.BindGenericParameters(paramContracts, boundContracts);
DataMember boundDataMember = new DataMember(memberTypeContract,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace System.Runtime.Serialization
{
internal sealed class EnumDataContract : DataContract
{
internal const string ContractTypeString = "EnumDataContract";
internal const string ContractTypeString = nameof(EnumDataContract);
public override string? ContractType => ContractTypeString;

private readonly EnumDataContractCriticalHelper _helper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal GenericParameterDataContractCriticalHelper(
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
public override DataContract BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract> boundContracts)
public override DataContract BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
{
return paramContracts[ParameterPosition];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
using System.Security;
using System.Text;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization.Json
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Text;
using System.Xml;

using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization.Json
{
internal sealed class JsonXmlDataContract : JsonDataContract
Expand Down Expand Up @@ -62,12 +64,12 @@ private static List<Type> GetKnownTypesFromContext(XmlObjectSerializerContext? c
if (context != null)
{
List<XmlQualifiedName> stableNames = new List<XmlQualifiedName>();
Dictionary<XmlQualifiedName, DataContract>[] entries = context.scopedKnownTypes.dataContractDictionaries;
DataContractDictionary[] entries = context.scopedKnownTypes.dataContractDictionaries;
if (entries != null)
{
for (int i = 0; i < entries.Length; i++)
{
Dictionary<XmlQualifiedName, DataContract> entry = entries[i];
DataContractDictionary entry = entries[i];
if (entry != null)
{
foreach (KeyValuePair<XmlQualifiedName, DataContract> pair in entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace System.Runtime.Serialization
{
internal abstract class PrimitiveDataContract : DataContract
{
internal const string ContractTypeString = "PrimitiveDataContract";
internal const string ContractTypeString = nameof(PrimitiveDataContract);
public override string? ContractType => ContractTypeString;

internal static readonly PrimitiveDataContract NullContract = new NullPrimitiveDataContract();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Collections;
using System.Collections.Generic;

using SchemaObjectDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.SchemaObjectInfo>;
using SchemaObjectDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.SchemaObjectInfo>;

namespace System.Runtime.Serialization
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
using System.Xml;
using System.Xml.Schema;

using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using SchemaObjectDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.SchemaObjectInfo>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using SchemaObjectDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.SchemaObjectInfo>;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -236,7 +236,7 @@ private void ImportKnownTypesForObject()

internal SchemaObjectDictionary CreateSchemaObjects()
{
SchemaObjectDictionary schemaObjects = new SchemaObjectDictionary();
SchemaObjectDictionary schemaObjects = new Dictionary<XmlQualifiedName, SchemaObjectInfo>();
ICollection schemaList = _schemaSet.Schemas();
List<XmlSchemaType> knownTypesForObject = new List<XmlSchemaType>();
schemaObjects.Add(SchemaExporter.AnytypeQualifiedName, new SchemaObjectInfo(null, null, null, knownTypesForObject));
Expand Down Expand Up @@ -907,7 +907,7 @@ private void ImportBaseContract(XmlQualifiedName baseTypeName, ClassDataContract
DataContractDictionary? knownDataContracts = ancestorDataContract.KnownDataContracts;
if (knownDataContracts == null)
{
knownDataContracts = new DataContractDictionary();
knownDataContracts = new Dictionary<XmlQualifiedName, DataContract>();
ancestorDataContract.KnownDataContracts = knownDataContracts;
}
knownDataContracts.Add(dataContract.StableName, dataContract);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
internal delegate IXmlSerializable CreateXmlSerializableDelegate();
public sealed class XmlDataContract : DataContract
{
internal const string ContractTypeString = "XmlDataContract";
internal const string ContractTypeString = nameof(XmlDataContract);
public override string? ContractType => ContractTypeString;

private readonly XmlDataContractCriticalHelper _helper;
Expand Down Expand Up @@ -48,7 +48,11 @@ public bool IsAnonymous
get => _helper.IsAnonymous;
}

public void SetIsValueType(bool isValueType) => IsValueType = isValueType;
public new bool IsValueType
{
get => _helper.IsValueType;
set => _helper.IsValueType = value;
}

public override bool HasRoot
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Security;
using System.Text;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Reflection;
using System.Security;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -177,7 +177,7 @@ internal virtual DataContractDictionary? SerializerKnownDataContracts
internal static DataContractDictionary? GetDataContractsForKnownTypes(IList<Type> knownTypeList)
{
if (knownTypeList == null) return null;
DataContractDictionary dataContracts = new DataContractDictionary();
DataContractDictionary dataContracts = new Dictionary<XmlQualifiedName, DataContract>();
Dictionary<Type, Type> typesChecked = new Dictionary<Type, Type>();
for (int i = 0; i < knownTypeList.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down
Loading