You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -820,7 +820,7 @@ namespace System.Runtime.Serialization
|
||||
|
||||
if (BaseContract != null)
|
||||
{
|
||||
if (hasDataContractAttribute && dataContractAttribute.IsReferenceSetExplicit)
|
||||
if (hasDataContractAttribute && dataContractAttribute.IsReferenceSetExplicitly)
|
||||
{
|
||||
bool baseIsReference = this.BaseContract.IsReference;
|
||||
if ((baseIsReference && !dataContractAttribute.IsReference) ||
|
||||
@@ -920,7 +920,7 @@ namespace System.Runtime.Serialization
|
||||
ThrowInvalidDataContractException(SR.GetString(SR.InvalidMember, DataContract.GetClrTypeFullName(type), member.Name));
|
||||
|
||||
DataMemberAttribute memberAttribute = (DataMemberAttribute)memberAttributes[0];
|
||||
if (memberAttribute.IsNameSetExplicit)
|
||||
if (memberAttribute.IsNameSetExplicitly)
|
||||
{
|
||||
if (memberAttribute.Name == null || memberAttribute.Name.Length == 0)
|
||||
ThrowInvalidDataContractException(SR.GetString(SR.InvalidDataMemberName, member.Name, DataContract.GetClrTypeFullName(type)));
|
||||
|
@@ -539,14 +539,14 @@ namespace System.Runtime.Serialization
|
||||
string itemName = null, keyName = null, valueName = null;
|
||||
if (collectionContractAttribute != null)
|
||||
{
|
||||
if (collectionContractAttribute.IsItemNameSetExplicit)
|
||||
if (collectionContractAttribute.IsItemNameSetExplicitly)
|
||||
{
|
||||
if (collectionContractAttribute.ItemName == null || collectionContractAttribute.ItemName.Length == 0)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.GetString(SR.InvalidCollectionContractItemName, DataContract.GetClrTypeFullName(UnderlyingType))));
|
||||
itemName = DataContract.EncodeLocalName(collectionContractAttribute.ItemName);
|
||||
itemNameSetExplicit = true;
|
||||
}
|
||||
if (collectionContractAttribute.IsKeyNameSetExplicit)
|
||||
if (collectionContractAttribute.IsKeyNameSetExplicitly)
|
||||
{
|
||||
if (collectionContractAttribute.KeyName == null || collectionContractAttribute.KeyName.Length == 0)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.GetString(SR.InvalidCollectionContractKeyName, DataContract.GetClrTypeFullName(UnderlyingType))));
|
||||
@@ -554,7 +554,7 @@ namespace System.Runtime.Serialization
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.GetString(SR.InvalidCollectionContractKeyNoDictionary, DataContract.GetClrTypeFullName(UnderlyingType), collectionContractAttribute.KeyName)));
|
||||
keyName = DataContract.EncodeLocalName(collectionContractAttribute.KeyName);
|
||||
}
|
||||
if (collectionContractAttribute.IsValueNameSetExplicit)
|
||||
if (collectionContractAttribute.IsValueNameSetExplicitly)
|
||||
{
|
||||
if (collectionContractAttribute.ValueName == null || collectionContractAttribute.ValueName.Length == 0)
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.GetString(SR.InvalidCollectionContractValueName, DataContract.GetClrTypeFullName(UnderlyingType))));
|
||||
|
@@ -13,12 +13,12 @@ namespace System.Runtime.Serialization
|
||||
string keyName;
|
||||
string valueName;
|
||||
bool isReference;
|
||||
bool isNameSetExplicit;
|
||||
bool isNamespaceSetExplicit;
|
||||
bool isReferenceSetExplicit;
|
||||
bool isItemNameSetExplicit;
|
||||
bool isKeyNameSetExplicit;
|
||||
bool isValueNameSetExplicit;
|
||||
bool isNameSetExplicitly;
|
||||
bool isNamespaceSetExplicitly;
|
||||
bool isReferenceSetExplicitly;
|
||||
bool isItemNameSetExplicitly;
|
||||
bool isKeyNameSetExplicitly;
|
||||
bool isValueNameSetExplicitly;
|
||||
|
||||
public CollectionDataContractAttribute()
|
||||
{
|
||||
@@ -30,13 +30,13 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
ns = value;
|
||||
isNamespaceSetExplicit = true;
|
||||
isNamespaceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNamespaceSetExplicit
|
||||
public bool IsNamespaceSetExplicitly
|
||||
{
|
||||
get { return isNamespaceSetExplicit; }
|
||||
get { return isNamespaceSetExplicitly; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
@@ -45,13 +45,13 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
isNameSetExplicit = true;
|
||||
isNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNameSetExplicit
|
||||
public bool IsNameSetExplicitly
|
||||
{
|
||||
get { return isNameSetExplicit; }
|
||||
get { return isNameSetExplicitly; }
|
||||
}
|
||||
|
||||
public string ItemName
|
||||
@@ -60,13 +60,13 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
itemName = value;
|
||||
isItemNameSetExplicit = true;
|
||||
isItemNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsItemNameSetExplicit
|
||||
public bool IsItemNameSetExplicitly
|
||||
{
|
||||
get { return isItemNameSetExplicit; }
|
||||
get { return isItemNameSetExplicitly; }
|
||||
}
|
||||
|
||||
public string KeyName
|
||||
@@ -75,7 +75,7 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
keyName = value;
|
||||
isKeyNameSetExplicit = true;
|
||||
isKeyNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,18 +85,18 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
isReference = value;
|
||||
isReferenceSetExplicit = true;
|
||||
isReferenceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsReferenceSetExplicit
|
||||
public bool IsReferenceSetExplicitly
|
||||
{
|
||||
get { return isReferenceSetExplicit; }
|
||||
get { return isReferenceSetExplicitly; }
|
||||
}
|
||||
|
||||
internal bool IsKeyNameSetExplicit
|
||||
public bool IsKeyNameSetExplicitly
|
||||
{
|
||||
get { return isKeyNameSetExplicit; }
|
||||
get { return isKeyNameSetExplicitly; }
|
||||
}
|
||||
|
||||
public string ValueName
|
||||
@@ -105,13 +105,13 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
valueName = value;
|
||||
isValueNameSetExplicit = true;
|
||||
isValueNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsValueNameSetExplicit
|
||||
public bool IsValueNameSetExplicitly
|
||||
{
|
||||
get { return isValueNameSetExplicit; }
|
||||
get { return isValueNameSetExplicitly; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
68d510c66635a8bc1d30f6dcb6c0c9ab53137deb
|
||||
c63c76f91537ad23db1f24fb585d429c313200cd
|
@@ -9,10 +9,10 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
string name;
|
||||
string ns;
|
||||
bool isNameSetExplicit;
|
||||
bool isNamespaceSetExplicit;
|
||||
bool isNameSetExplicitly;
|
||||
bool isNamespaceSetExplicitly;
|
||||
bool isReference;
|
||||
bool isReferenceSetExplicit;
|
||||
bool isReferenceSetExplicitly;
|
||||
|
||||
public DataContractAttribute()
|
||||
{
|
||||
@@ -24,13 +24,13 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
isReference = value;
|
||||
isReferenceSetExplicit = true;
|
||||
isReferenceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsReferenceSetExplicit
|
||||
public bool IsReferenceSetExplicitly
|
||||
{
|
||||
get { return isReferenceSetExplicit; }
|
||||
get { return isReferenceSetExplicitly; }
|
||||
}
|
||||
|
||||
public string Namespace
|
||||
@@ -39,13 +39,13 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
ns = value;
|
||||
isNamespaceSetExplicit = true;
|
||||
isNamespaceSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNamespaceSetExplicit
|
||||
public bool IsNamespaceSetExplicitly
|
||||
{
|
||||
get { return isNamespaceSetExplicit; }
|
||||
get { return isNamespaceSetExplicitly; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
@@ -54,13 +54,13 @@ namespace System.Runtime.Serialization
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
isNameSetExplicit = true;
|
||||
isNameSetExplicitly = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsNameSetExplicit
|
||||
public bool IsNameSetExplicitly
|
||||
{
|
||||
get { return isNameSetExplicit; }
|
||||
get { return isNameSetExplicitly; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ namespace System.Runtime.Serialization
|
||||
|
||||
internal class DataContractSet
|
||||
{
|
||||
// Same string used in MessageContractImporter of System.ServiceModel.dll
|
||||
const String FailedReferenceTypeExceptionKey = "System.Runtime.Serialization.FailedReferenceType";
|
||||
Dictionary<XmlQualifiedName, DataContract> contracts;
|
||||
Dictionary<DataContract, object> processedContracts;
|
||||
IDataContractSurrogate dataContractSurrogate;
|
||||
@@ -368,20 +366,7 @@ namespace System.Runtime.Serialization
|
||||
if (type == null)
|
||||
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ReferencedTypesCannotContainNull)));
|
||||
|
||||
try
|
||||
{
|
||||
AddReferencedType(referencedTypesDictionary, type);
|
||||
}
|
||||
catch (InvalidDataContractException ex)
|
||||
{
|
||||
ex.Data.Add(FailedReferenceTypeExceptionKey, type);
|
||||
throw;
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
ex.Data.Add(FailedReferenceTypeExceptionKey, type);
|
||||
throw;
|
||||
}
|
||||
AddReferencedType(referencedTypesDictionary, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,7 +398,22 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
if (IsTypeReferenceable(type))
|
||||
{
|
||||
XmlQualifiedName stableName = this.GetStableName(type);
|
||||
XmlQualifiedName stableName;
|
||||
try
|
||||
{
|
||||
stableName = this.GetStableName(type);
|
||||
}
|
||||
catch (InvalidDataContractException)
|
||||
{
|
||||
// Type not referenceable if we can't get a stable name.
|
||||
return;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// Type not referenceable if we can't get a stable name.
|
||||
return;
|
||||
}
|
||||
|
||||
object value;
|
||||
if (referencedTypes.TryGetValue(stableName, out value))
|
||||
{
|
||||
@@ -500,11 +500,28 @@ namespace System.Runtime.Serialization
|
||||
static bool IsTypeReferenceable(Type type)
|
||||
{
|
||||
Type itemType;
|
||||
return (type.IsSerializable ||
|
||||
type.IsDefined(Globals.TypeOfDataContractAttribute, false) ||
|
||||
(Globals.TypeOfIXmlSerializable.IsAssignableFrom(type) && !type.IsGenericTypeDefinition) ||
|
||||
CollectionDataContract.IsCollection(type, out itemType) ||
|
||||
ClassDataContract.IsNonAttributedTypeValidForSerialization(type));
|
||||
|
||||
try
|
||||
{
|
||||
return (type.IsSerializable ||
|
||||
type.IsDefined(Globals.TypeOfDataContractAttribute, false) ||
|
||||
(Globals.TypeOfIXmlSerializable.IsAssignableFrom(type) && !type.IsGenericTypeDefinition) ||
|
||||
CollectionDataContract.IsCollection(type, out itemType) ||
|
||||
ClassDataContract.IsNonAttributedTypeValidForSerialization(type));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// An exception can be thrown in the designer when a project has a runtime binding redirection for a referenced assembly or a reference dependent assembly.
|
||||
// Type.IsDefined is known to throw System.IO.FileLoadException.
|
||||
// ClassDataContract.IsNonAttributedTypeValidForSerialization is known to throw System.IO.FileNotFoundException.
|
||||
// We guard against all non-critical exceptions.
|
||||
if (Fx.IsFatal(ex))
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace System.Runtime.Serialization
|
||||
public sealed class DataMemberAttribute : Attribute
|
||||
{
|
||||
string name;
|
||||
bool isNameSetExplicit;
|
||||
bool isNameSetExplicitly;
|
||||
int order = -1;
|
||||
bool isRequired;
|
||||
bool emitDefaultValue = Globals.DefaultEmitDefaultValue;
|
||||
@@ -20,12 +20,12 @@ namespace System.Runtime.Serialization
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; isNameSetExplicit = true; }
|
||||
set { name = value; isNameSetExplicitly = true; }
|
||||
}
|
||||
|
||||
internal bool IsNameSetExplicit
|
||||
public bool IsNameSetExplicitly
|
||||
{
|
||||
get { return isNameSetExplicit; }
|
||||
get { return isNameSetExplicitly; }
|
||||
}
|
||||
|
||||
public int Order
|
||||
|
@@ -290,7 +290,7 @@ namespace System.Runtime.Serialization
|
||||
EnumMemberAttribute memberAttribute = (EnumMemberAttribute)memberAttributes[0];
|
||||
|
||||
DataMember memberContract = new DataMember(field);
|
||||
if (memberAttribute.IsValueSetExplicit)
|
||||
if (memberAttribute.IsValueSetExplicitly)
|
||||
{
|
||||
if (memberAttribute.Value == null || memberAttribute.Value.Length == 0)
|
||||
ThrowInvalidDataContractException(SR.GetString(SR.InvalidEnumMemberValue, field.Name, DataContract.GetClrTypeFullName(type)));
|
||||
|
@@ -8,7 +8,7 @@ namespace System.Runtime.Serialization
|
||||
public sealed class EnumMemberAttribute : Attribute
|
||||
{
|
||||
string value;
|
||||
bool isValueSetExplicit;
|
||||
bool isValueSetExplicitly;
|
||||
|
||||
public EnumMemberAttribute()
|
||||
{
|
||||
@@ -17,12 +17,12 @@ namespace System.Runtime.Serialization
|
||||
public string Value
|
||||
{
|
||||
get { return this.value; }
|
||||
set { this.value = value; this.isValueSetExplicit = true; }
|
||||
set { this.value = value; this.isValueSetExplicitly = true; }
|
||||
}
|
||||
|
||||
internal bool IsValueSetExplicit
|
||||
public bool IsValueSetExplicitly
|
||||
{
|
||||
get { return this.isValueSetExplicit; }
|
||||
get { return this.isValueSetExplicitly; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1092,23 +1092,6 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
static Type typeOfSafeSerializationManager;
|
||||
static bool typeOfSafeSerializationManagerSet;
|
||||
internal static Type TypeOfSafeSerializationManager
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
if (!typeOfSafeSerializationManagerSet)
|
||||
{
|
||||
typeOfSafeSerializationManager = TypeOfInt.Assembly.GetType("System.Runtime.Serialization.SafeSerializationManager");
|
||||
typeOfSafeSerializationManagerSet = true;
|
||||
}
|
||||
return typeOfSafeSerializationManager;
|
||||
}
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
static Uri dataContractXsdBaseNamespaceUri;
|
||||
internal static Uri DataContractXsdBaseNamespaceUri
|
||||
@@ -1122,6 +1105,7 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
#if !DISABLE_CAS_USE
|
||||
[Fx.Tag.SecurityNote(Critical = "Holds instance of SecurityPermission that we will Demand for SerializationFormatter."
|
||||
+ " Should not be modified to something else.")]
|
||||
[SecurityCritical]
|
||||
@@ -1153,7 +1137,7 @@ namespace System.Runtime.Serialization
|
||||
return memberAccessPermission;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public const bool DefaultIsRequired = false;
|
||||
public const bool DefaultEmitDefaultValue = true;
|
||||
@@ -1164,8 +1148,6 @@ namespace System.Runtime.Serialization
|
||||
public readonly static string NewObjectId = string.Empty;
|
||||
public const string SimpleSRSInternalsVisiblePattern = @"^[\s]*System\.Runtime\.Serialization[\s]*$";
|
||||
public const string FullSRSInternalsVisiblePattern = @"^[\s]*System\.Runtime\.Serialization[\s]*,[\s]*PublicKey[\s]*=[\s]*(?i:00000000000000000400000000000000)[\s]*$";
|
||||
public const string SafeSerializationManagerName = "SafeSerializationManager";
|
||||
public const string SafeSerializationManagerNamespace = "http://schemas.datacontract.org/2004/07/System.Runtime.Serialization";
|
||||
public const string NullObjectId = null;
|
||||
public const string Space = " ";
|
||||
public const string OpenBracket = "[";
|
||||
|
@@ -14,4 +14,4 @@ namespace System.Runtime.Serialization.Json
|
||||
StandaloneText,
|
||||
Collection
|
||||
}
|
||||
}
|
||||
}
|
@@ -89,11 +89,13 @@ namespace System.Runtime.Serialization
|
||||
[SecuritySafeCritical]
|
||||
public void DemandSerializationFormatterPermission()
|
||||
{
|
||||
#if !DISABLE_CAS_USE
|
||||
if (!demandedSerializationFormatterPermission)
|
||||
{
|
||||
Globals.SerializationFormatterPermission.Demand();
|
||||
demandedSerializationFormatterPermission = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fx.Tag.SecurityNote(Critical = "Demands MemberAccess permission. demanding the right permission is critical.",
|
||||
@@ -101,11 +103,13 @@ namespace System.Runtime.Serialization
|
||||
[SecuritySafeCritical]
|
||||
public void DemandMemberAccessPermission()
|
||||
{
|
||||
#if !DISABLE_CAS_USE
|
||||
if (!demandedMemberAccessPermission)
|
||||
{
|
||||
Globals.MemberAccessPermission.Demand();
|
||||
demandedMemberAccessPermission = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public StreamingContext GetStreamingContext()
|
||||
@@ -278,10 +282,6 @@ namespace System.Runtime.Serialization
|
||||
DataContract dataContract = PrimitiveDataContract.GetPrimitiveDataContract(typeName.Name, typeName.Namespace);
|
||||
if (dataContract == null)
|
||||
{
|
||||
if (typeName.Name == Globals.SafeSerializationManagerName && typeName.Namespace == Globals.SafeSerializationManagerNamespace && Globals.TypeOfSafeSerializationManager != null)
|
||||
{
|
||||
return GetDataContract(Globals.TypeOfSafeSerializationManager);
|
||||
}
|
||||
dataContract = scopedKnownTypes.GetDataContract(typeName);
|
||||
if (dataContract == null)
|
||||
{
|
||||
|
@@ -193,7 +193,7 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
if (TD.DCDeserializeWithSurrogateStartIsEnabled())
|
||||
{
|
||||
TD.DCDeserializeWithSurrogateStart(surrogateDataContract.UnderlyingType.FullName);
|
||||
TD.DCDeserializeWithSurrogateStart(declaredType.FullName);
|
||||
}
|
||||
|
||||
DataContract dataContract = surrogateDataContract ??
|
||||
|
@@ -494,8 +494,10 @@ namespace System.Runtime.Serialization
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
internal void GetObjectData(ISerializable obj, SerializationInfo serInfo, StreamingContext context)
|
||||
{
|
||||
#if !DISABLE_CAS_USE
|
||||
// Demand the serialization formatter permission every time
|
||||
Globals.SerializationFormatterPermission.Demand();
|
||||
#endif
|
||||
obj.GetObjectData(serInfo, context);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user