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
API cleanup.
  • Loading branch information
StephenMolloy committed Jul 14, 2022
commit 446c99369d0f14f36f2df1cde45749c762ce2b19
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,9 @@
<data name="DupTypeContractInDataContractSet" xml:space="preserve">
<value>DataContract for type '{0}' cannot be added to DataContractSet since type '{1}' with the same data contract name '{2}' in namespace '{3}' is already present and the contracts are not equivalent.</value>
</data>
<data name="GenericTypeNameMismatch" xml:space="preserve">
<value>DataContract name '{0}' from namespace '{1}' does not match the generic name '{2}' from namespace '{3}'.</value>
</data>
<data name="GenericTypeNotExportable" xml:space="preserve">
<value>Type '{0}' cannot be exported as a schema type because it is an open generic type. You can only export a generic type if all its generic parameter types are actual types.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using System.Threading;
using System.Xml;

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

namespace System.Runtime.Serialization
{
Expand All @@ -20,11 +20,11 @@ internal sealed class ClassDataContract : DataContract
internal const string ContractTypeString = nameof(ClassDataContract);
public override string? ContractType => ContractTypeString;

public XmlDictionaryString[]? ContractNamespaces;
internal XmlDictionaryString[]? ContractNamespaces;

public XmlDictionaryString[]? MemberNames;
internal XmlDictionaryString[]? MemberNames;

public XmlDictionaryString[]? MemberNamespaces;
internal XmlDictionaryString[]? MemberNamespaces;

private XmlDictionaryString?[]? _childElementNamespaces;

Expand Down Expand Up @@ -63,13 +63,13 @@ internal ClassDataContract? BaseClassContract
set => _helper.BaseClassContract = value;
}

public override IList<DataMember>? Members
public override List<DataMember>? Members
{
get => _helper.Members;
internal set => _helper.Members = value;
}

public XmlDictionaryString?[]? ChildElementNamespaces
internal XmlDictionaryString?[]? ChildElementNamespaces
{
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
get
Expand Down Expand Up @@ -578,7 +578,7 @@ private sealed class ClassDataContractCriticalHelper : DataContract.DataContract
private static Type[]? s_serInfoCtorArgs;

private ClassDataContract? _baseContract;
private IList<DataMember>? _members;
private List<DataMember>? _members;
private MethodInfo? _onSerializing, _onSerialized;
private MethodInfo? _onDeserializing, _onDeserialized;
private MethodInfo? _extensionDataSetMethod;
Expand All @@ -599,9 +599,9 @@ private sealed class ClassDataContractCriticalHelper : DataContract.DataContract
private bool _hasDataContract;
private bool _hasExtensionData;

public XmlDictionaryString[]? ContractNamespaces;
public XmlDictionaryString[]? MemberNames;
public XmlDictionaryString[]? MemberNamespaces;
internal XmlDictionaryString[]? ContractNamespaces;
internal XmlDictionaryString[]? MemberNames;
internal XmlDictionaryString[]? MemberNamespaces;

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal ClassDataContractCriticalHelper([DynamicallyAccessedMembers(DataContractPreserveMemberTypes)]
Expand Down Expand Up @@ -1132,7 +1132,7 @@ internal ClassDataContract? BaseClassContract
}
}

internal IList<DataMember>? Members
internal List<DataMember>? Members
{
get => _members;
set => _members = value;
Expand Down Expand Up @@ -1255,7 +1255,7 @@ internal override bool IsISerializable

internal XmlFormatClassReaderDelegate? XmlFormatReaderDelegate { get; set; }

public XmlDictionaryString?[]? ChildElementNamespaces { get; set; }
internal XmlDictionaryString?[]? ChildElementNamespaces { get; set; }

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

Expand Down Expand Up @@ -1292,15 +1292,15 @@ public int Compare(Member x, Member y)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
public override DataContract BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
internal override DataContract BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract>? boundContracts = null)
{
Type type = UnderlyingType;
if (!type.IsGenericType || !type.ContainsGenericParameters)
return this;

lock (this)
{
if (boundContracts.TryGetValue(this, out DataContract? boundContract))
if (boundContracts != null && boundContracts.TryGetValue(this, out DataContract? boundContract))
return boundContract;

XmlQualifiedName stableName;
Expand Down Expand Up @@ -1341,6 +1341,7 @@ public override DataContract BindGenericParameters(DataContract[] paramContracts
boundType = type.MakeGenericType(paramTypes);
}
ClassDataContract boundClassContract = new ClassDataContract(boundType);
boundContracts ??= new Dictionary<DataContract, DataContract>();
boundContracts.Add(this, boundClassContract);
boundClassContract.StableName = CreateQualifiedName(DataContract.ExpandGenericParameters(XmlConvert.DecodeName(stableName.Name), new GenericNameProvider(DataContract.GetClrTypeFullName(UnderlyingType), genericParams)), stableName.Namespace);
if (BaseClassContract != null)
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.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -153,7 +153,7 @@ private void InitCollectionDataContract(DataContract? sharedTypeContract)

internal Type ItemType => _helper.ItemType;

public DataContract ItemContract
internal DataContract ItemContract
{
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
get => _itemContract ?? _helper.ItemContract;
Expand All @@ -173,7 +173,7 @@ internal string ItemName
set => _helper.ItemName = value;
}

public XmlDictionaryString CollectionItemName => _collectionItemName;
internal XmlDictionaryString CollectionItemName => _collectionItemName;

internal string? KeyName
{
Expand Down Expand Up @@ -203,7 +203,7 @@ public override DataContract BaseContract

internal bool IsDictionary => KeyName != null;

public XmlDictionaryString? ChildElementNamespace
internal XmlDictionaryString? ChildElementNamespace
{
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
get
Expand Down Expand Up @@ -629,7 +629,7 @@ internal bool IsConstructorCheckRequired
set => _isConstructorCheckRequired = value;
}

public XmlDictionaryString CollectionItemName => _collectionItemName;
internal XmlDictionaryString CollectionItemName => _collectionItemName;

internal string? KeyName
{
Expand All @@ -645,11 +645,11 @@ internal string? ValueName

internal bool IsDictionary => KeyName != null;

public string? SerializationExceptionMessage => _serializationExceptionMessage;
internal string? SerializationExceptionMessage => _serializationExceptionMessage;

public string? DeserializationExceptionMessage => _deserializationExceptionMessage;
internal string? DeserializationExceptionMessage => _deserializationExceptionMessage;

public XmlDictionaryString? ChildElementNamespace
internal XmlDictionaryString? ChildElementNamespace
{
get => _childElementNamespace;
set => _childElementNamespace = value;
Expand Down Expand Up @@ -1330,10 +1330,10 @@ private static bool IsKnownInterface(Type type)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
public override DataContract BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
internal override DataContract BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract>? boundContracts = null)
{
DataContract boundContract;
if (boundContracts.TryGetValue(this, out boundContract!))
if (boundContracts != null && boundContracts.TryGetValue(this, out boundContract!))
return boundContract;

// NOTE TODO smolloy - this type-binding ('boundType') stuff is new. We did not do this in NetFx. We used to use default constructors and let the
Expand All @@ -1349,6 +1349,7 @@ public override DataContract BindGenericParameters(DataContract[] paramContracts
Type boundType = type.MakeGenericType(paramTypes);

CollectionDataContract boundCollectionContract = new CollectionDataContract(boundType);
boundContracts ??= new Dictionary<DataContract, DataContract>();
boundContracts.Add(this, boundCollectionContract);
boundCollectionContract.ItemContract = ItemContract.BindGenericParameters(paramContracts, boundContracts);
boundCollectionContract.IsItemTypeNullable = !boundCollectionContract.ItemContract.IsValueType;
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.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down Expand Up @@ -207,11 +207,11 @@ public virtual DataContract? BaseContract
get => null;
}

public virtual GenericInfo? GenericInfo
internal GenericInfo? GenericInfo
{
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
get => _helper.GenericInfo;
internal set => _helper.GenericInfo = value;
set => _helper.GenericInfo = value;
}

public virtual DataContractDictionary? KnownDataContracts
Expand Down Expand Up @@ -259,7 +259,7 @@ public virtual bool IsKeyValue(out string? keyName, out string? valueName, out s
return false;
}

public virtual IList<DataMember>? Members
public virtual List<DataMember>? Members
{
get => null;
internal set { }
Expand All @@ -274,7 +274,7 @@ internal virtual void WriteRootElement(XmlWriterDelegator writer, XmlDictionaryS
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
public virtual DataContract BindGenericParameters(DataContract[] paramContracts, IDictionary<DataContract, DataContract> boundContracts)
internal virtual DataContract BindGenericParameters(DataContract[] paramContracts, Dictionary<DataContract, DataContract>? boundContracts = null)
{
return this;
}
Expand Down Expand Up @@ -2016,7 +2016,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 Dictionary<XmlQualifiedName, DataContract>();
knownDataContracts ??= new DataContractDictionary();

knownDataContracts.TryAdd(itemDataContract.StableName, itemDataContract);
}
Expand All @@ -2040,7 +2040,7 @@ internal static void CheckAndAdd(Type type, Dictionary<Type, Type> typesChecked,
DataContract dataContract = DataContract.GetDataContract(type);
if (nameToDataContractTable == null)
{
nameToDataContractTable = new Dictionary<XmlQualifiedName, DataContract>();
nameToDataContractTable = new DataContractDictionary();
}
else if (nameToDataContractTable.TryGetValue(dataContract.StableName, out DataContract? alreadyExistingContract))
{
Expand Down Expand Up @@ -2338,7 +2338,7 @@ private XmlQualifiedName GetStableName(int i)
}
}

public sealed class GenericInfo : IGenericNameProvider
internal sealed class GenericInfo : IGenericNameProvider
{
private string? _genericTypeName;
private XmlQualifiedName _stableName;
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.IDictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
Expand Down
Loading