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
Fix bugs found by newly ported tests.
  • Loading branch information
StephenMolloy committed Aug 2, 2022
commit 24ca75cd9658378b2358a560b059d3e7304d82be
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@
<value>Simple type restriction must specify a base type.</value>
</data>
<data name="SimpleTypeUnionNotSupported" xml:space="preserve">
<value>=Simple types with &lt;union&gt; content are not supported.</value>
<value>Simple types with &lt;union&gt; content are not supported.</value>
</data>
<data name="SpecifiedTypeNotFoundInSchema" xml:space="preserve">
<value>Invalid type specified. Type with name '{0}' not found in schema with namespace '{1}'.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ internal override DataContract BindGenericParameters(DataContract[] paramContrac
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal override bool Equals(object? other, HashSet<DataContractPairKey> checkedContracts)
internal override bool Equals(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (IsEqualOrChecked(other, checkedContracts))
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ internal bool RequiresMemberAccessForWrite(SecurityException? securityException)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal override bool Equals(object? other, HashSet<DataContractPairKey> checkedContracts)
internal override bool Equals(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (IsEqualOrChecked(other, checkedContracts))
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ public sealed override bool Equals(object? obj)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal virtual bool Equals(object? other, HashSet<DataContractPairKey> checkedContracts)
internal virtual bool Equals(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (other is DataContract dataContract)
{
Expand All @@ -2066,18 +2066,21 @@ internal virtual bool Equals(object? other, HashSet<DataContractPairKey> checked
return false;
}

internal bool IsEqualOrChecked(object? other, HashSet<DataContractPairKey> checkedContracts)
internal bool IsEqualOrChecked(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (other == null)
return false;

if ((object)this == other)
return true;

DataContractPairKey contractPairKey = new DataContractPairKey(this, other);
if (checkedContracts.Contains(contractPairKey))
return true;
checkedContracts.Add(contractPairKey);
if (checkedContracts != null)
{
DataContractPairKey contractPairKey = new DataContractPairKey(this, other);
if (checkedContracts.Contains(contractPairKey))
return true;
checkedContracts.Add(contractPairKey);
}

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ internal void Add(XmlQualifiedName name, DataContract dataContract)
{
if (dataContract.IsBuiltInDataContract)
return;
if (dataContract is DataContract dataContractInternal)
InternalAdd(name, dataContractInternal);
InternalAdd(name, dataContract);
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
Expand Down Expand Up @@ -167,16 +166,19 @@ private void AddClassDataContract(ClassDataContract classDataContract)
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
private void AddCollectionDataContract(CollectionDataContract collectionDataContract)
{
if (collectionDataContract.IsDictionary)
if (collectionDataContract.UnderlyingType != Globals.TypeOfSchemaDefinedType)
{
ClassDataContract keyValueContract = (collectionDataContract.ItemContract as ClassDataContract)!;
AddClassDataContract(keyValueContract);
}
else
{
DataContract itemContract = GetItemTypeDataContract(collectionDataContract);
if (itemContract != null)
Add(itemContract.XmlName, itemContract);
if (collectionDataContract.IsDictionary)
{
ClassDataContract keyValueContract = (collectionDataContract.ItemContract as ClassDataContract)!;
AddClassDataContract(keyValueContract);
}
else
{
DataContract itemContract = GetItemTypeDataContract(collectionDataContract);
if (itemContract != null)
Add(itemContract.XmlName, itemContract);
}
}
AddKnownDataContracts(collectionDataContract.KnownDataContracts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ internal DataMember BindGenericParameters(DataContract[] paramContracts, Diction
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal bool Equals(object? other, HashSet<DataContractPairKey> checkedContracts)
internal bool Equals(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (this == other)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,43 @@ internal long GetEnumValueFromString(string value)
}
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal override bool Equals(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (IsEqualOrChecked(other, checkedContracts))
return true;

if (base.Equals(other, null))
{
if (other is EnumDataContract enumContract)
{
if (Members.Count != enumContract.Members.Count || Values?.Count != enumContract.Values?.Count)
return false;
string[] memberNames1 = new string[Members.Count], memberNames2 = new string[Members.Count];
for (int i = 0; i < Members.Count; i++)
{
memberNames1[i] = Members[i].Name;
memberNames2[i] = enumContract.Members[i].Name;
}
Array.Sort(memberNames1);
Array.Sort(memberNames2);
for (int i = 0; i < Members.Count; i++)
{
if (memberNames1[i] != memberNames2[i])
return false;
}

return (IsFlags == enumContract.IsFlags);
}
}
return false;
}

public override int GetHashCode()
{
return base.GetHashCode();
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal override void WriteXmlValue(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext? context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ internal static Type TypeOfHashtable
internal static Type TypeOfSchemaDefinedType =>
s_typeOfSchemaDefinedType ??= typeof(SchemaDefinedType);

[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicFields)]
private static Type? s_typeOfSchemaDefinedEnum;
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicFields)]
internal static Type TypeOfSchemaDefinedEnum =>
s_typeOfSchemaDefinedEnum ??= typeof(SchemaDefinedEnum);

private static MemberInfo? s_schemaMemberInfoPlaceholder;
internal static MemberInfo SchemaMemberInfoPlaceholder =>
s_schemaMemberInfoPlaceholder ??= TypeOfSchemaDefinedType.GetField("_xmlName", BindingFlags.NonPublic | BindingFlags.Instance)!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected static bool TryReadNullAtTopLevel(XmlReaderDelegator reader)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal override bool Equals(object? other, HashSet<DataContractPairKey> checkedContracts)
internal override bool Equals(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (other is PrimitiveDataContract)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public SchemaDefinedType(XmlQualifiedName xmlName)
}
}

internal enum SchemaDefinedEnum { SchemaDefinedEnumValue };

internal static class SchemaHelper
{
internal static bool NamespacesEqual(string? ns1, string? ns2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,15 +935,13 @@ private void ImportClassMember(XmlSchemaElement element, ClassDataContract dataC
{
XmlQualifiedName typeName = dataContract.XmlName;

Debug.Assert(element.Name != null);

if (element.MinOccurs > 1)
ThrowTypeCannotBeImportedException(typeName.Name, typeName.Namespace, SR.Format(SR.ElementMinOccursMustBe, element.Name));
if (element.MaxOccurs != 1)
ThrowTypeCannotBeImportedException(typeName.Name, typeName.Namespace, SR.Format(SR.ElementMaxOccursMustBe, element.Name));

DataContract? memberTypeContract = null;
string memberName = element.Name;
string? memberName = element.Name;
bool memberIsRequired = (element.MinOccurs > 0);
bool memberIsNullable = element.IsNillable;
bool memberEmitDefaultValue;
Expand Down Expand Up @@ -987,6 +985,7 @@ private void ImportClassMember(XmlSchemaElement element, ClassDataContract dataC
memberEmitDefaultValue = emitDefaultValueFromAnnotation != null ? emitDefaultValueFromAnnotation.Value : Globals.DefaultEmitDefaultValue;

Debug.Assert(dataContract.Members != null); // This method is only called from ImportClass() after that method has initialized the Members collection.
Debug.Assert(memberName != null); // At this point, elements without a name should have been handled.

int prevMemberIndex = dataContract.Members.Count - 1;
if (prevMemberIndex >= 0)
Expand Down Expand Up @@ -1179,7 +1178,7 @@ private static bool IsDictionary(XmlQualifiedName typeName, XmlSchemaAnnotation?
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
private EnumDataContract ImportEnum(XmlQualifiedName typeName, XmlSchemaSimpleTypeRestriction restriction, bool isFlags, XmlSchemaAnnotation? annotation)
{
EnumDataContract dataContract = new EnumDataContract(Globals.TypeOfSchemaDefinedType);
EnumDataContract dataContract = new EnumDataContract(Globals.TypeOfSchemaDefinedEnum);
dataContract.XmlName = typeName;
dataContract.BaseContractName = ImportActualType(annotation, SchemaExporter.DefaultEnumBaseTypeName, typeName);
dataContract.IsFlags = isFlags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ internal IXmlSerializable ReflectionCreateXmlSerializable(Type type)
}

[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]
internal override bool Equals(object? other, HashSet<DataContractPairKey> checkedContracts)
internal override bool Equals(object? other, HashSet<DataContractPairKey>? checkedContracts)
{
if (IsEqualOrChecked(other, checkedContracts))
return true;
Expand Down