You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.69
Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
parent
d8f8abd549
commit
e2950ec768
@@ -1 +1 @@
|
||||
e7ec34477d033511dee8f3189b17d4727d180f0e
|
||||
5124846c60d750bcb536bb4802a339dee73b9d28
|
||||
@@ -14,6 +14,9 @@ using System.Xml;
|
||||
namespace System.Configuration
|
||||
{
|
||||
[Serializable]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
#endif
|
||||
public class ConfigurationErrorsException : ConfigurationException
|
||||
{
|
||||
// Constants
|
||||
@@ -104,7 +107,34 @@ namespace System.Configuration
|
||||
protected ConfigurationErrorsException(SerializationInfo info, StreamingContext context) :
|
||||
base(info, context)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
int firstLine;
|
||||
int count;
|
||||
|
||||
// Retrieve out members
|
||||
string firstFilename = info.GetString(SerializationParamFilename);
|
||||
firstLine = info.GetInt32(SerializationParamLine);
|
||||
|
||||
Init(firstFilename, firstLine);
|
||||
|
||||
// Retrieve errors for _errors object
|
||||
count = info.GetInt32(SerializationParamErrorCount);
|
||||
|
||||
if (count == 0) return;
|
||||
_errors = new ConfigurationException[count];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
string numPrefix = i.ToString(CultureInfo.InvariantCulture);
|
||||
string currentType = info.GetString(numPrefix + SerializationParamErrorType);
|
||||
Type currentExceptionType = Type.GetType(currentType, true);
|
||||
|
||||
// Only allow our exception types
|
||||
if ((currentExceptionType != typeof(ConfigurationException)) &&
|
||||
(currentExceptionType != typeof(ConfigurationErrorsException)))
|
||||
throw ExceptionUtil.UnexpectedError("ConfigurationErrorsException");
|
||||
|
||||
_errors[i] = (ConfigurationException)info.GetValue(numPrefix + SerializationParamErrorData, currentExceptionType);
|
||||
}
|
||||
}
|
||||
|
||||
// The message includes the file/line number information.
|
||||
@@ -168,6 +198,28 @@ namespace System.Configuration
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData(info, context);
|
||||
|
||||
// Serialize our members
|
||||
info.AddValue(SerializationParamFilename, Filename);
|
||||
info.AddValue(SerializationParamLine, Line);
|
||||
|
||||
// Serialize rest of errors, along with count
|
||||
// (since first error duplicates this error, only worry if
|
||||
// there is more than one)
|
||||
int subErrors = 0;
|
||||
if ((_errors != null) && (_errors.Length > 1))
|
||||
{
|
||||
subErrors = _errors.Length;
|
||||
|
||||
for (int i = 0; i < _errors.Length; i++)
|
||||
{
|
||||
string numPrefix = i.ToString(CultureInfo.InvariantCulture);
|
||||
info.AddValue(numPrefix + SerializationParamErrorData, _errors[i]);
|
||||
info.AddValue(numPrefix + SerializationParamErrorType, _errors[i].GetType());
|
||||
}
|
||||
}
|
||||
|
||||
info.AddValue(SerializationParamErrorCount, subErrors);
|
||||
}
|
||||
|
||||
// Get file and linenumber from an XML Node in a DOM
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace System.Configuration
|
||||
/// number information where possible.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#endif
|
||||
public class ConfigurationException : SystemException
|
||||
{
|
||||
private string _filename;
|
||||
@@ -26,7 +29,7 @@ namespace System.Configuration
|
||||
protected ConfigurationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
Init(info.GetString("filename"), info.GetInt32("line"));
|
||||
}
|
||||
|
||||
[Obsolete("This class is obsolete, to create a new exception create a System.Configuration!System.Configuration.ConfigurationErrorsException")]
|
||||
@@ -93,6 +96,8 @@ namespace System.Configuration
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("filename", _filename);
|
||||
info.AddValue("line", _line);
|
||||
}
|
||||
|
||||
[Obsolete("This class is obsolete, use System.Configuration!System.Configuration.ConfigurationErrorsException.GetFilename instead")]
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace System.Configuration
|
||||
|
||||
public GenericEnumConverter(Type typeEnum)
|
||||
{
|
||||
if (typeEnum == null) throw new ArgumentNullException(nameof(typeEnum));
|
||||
if (typeEnum == null)
|
||||
throw new ArgumentNullException(nameof(typeEnum));
|
||||
|
||||
_enumType = typeEnum;
|
||||
}
|
||||
@@ -26,41 +27,39 @@ namespace System.Configuration
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data)
|
||||
{
|
||||
object result;
|
||||
|
||||
// For any error, throw the ArgumentException with SR.Invalid_enum_value
|
||||
try
|
||||
if ((data is string value) && (value.Length > 0))
|
||||
{
|
||||
string value = (string)data;
|
||||
if (string.IsNullOrEmpty(value)) throw new Exception();
|
||||
|
||||
// Disallow numeric values for enums.
|
||||
if (!string.IsNullOrEmpty(value) &&
|
||||
(char.IsDigit(value[0]) ||
|
||||
(value[0] == '-') ||
|
||||
(value[0] == '+')))
|
||||
throw new Exception();
|
||||
|
||||
if (value != value.Trim())
|
||||
// Disallow numeric values and whitespace at start and end.
|
||||
if ((!char.IsDigit(value[0])) && (value[0] != '-') && (value[0] != '+') &&
|
||||
(!char.IsWhiteSpace(value[0])) && (!char.IsWhiteSpace(value[value.Length - 1])))
|
||||
{
|
||||
// throw if the value has whitespace
|
||||
throw new Exception();
|
||||
try
|
||||
{
|
||||
return Enum.Parse(_enumType, value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Exception from parse. Will throw more appropriate exception below.
|
||||
}
|
||||
}
|
||||
|
||||
result = Enum.Parse(_enumType, value);
|
||||
}
|
||||
catch
|
||||
throw CreateExceptionForInvalidValue();
|
||||
}
|
||||
|
||||
private ArgumentException CreateExceptionForInvalidValue()
|
||||
{
|
||||
StringBuilder names = new StringBuilder();
|
||||
|
||||
foreach (string name in Enum.GetNames(_enumType))
|
||||
{
|
||||
StringBuilder names = new StringBuilder();
|
||||
|
||||
foreach (string name in Enum.GetNames(_enumType))
|
||||
if (names.Length != 0)
|
||||
{
|
||||
if (names.Length != 0) names.Append(", ");
|
||||
names.Append(name);
|
||||
names.Append(", ");
|
||||
}
|
||||
throw new ArgumentException(string.Format(SR.Invalid_enum_value, names.ToString()));
|
||||
names.Append(name);
|
||||
}
|
||||
return result;
|
||||
return new ArgumentException(string.Format(SR.Invalid_enum_value, names.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Runtime.InteropServices;
|
||||
namespace System.Configuration
|
||||
{
|
||||
// obsolete
|
||||
[ComVisible(false)]
|
||||
public interface IConfigurationSystem
|
||||
{
|
||||
// Returns the config object for the specified key.
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.Configuration.Internal
|
||||
{
|
||||
[ComVisible(false)]
|
||||
public interface IInternalConfigHostPaths
|
||||
{
|
||||
void RefreshConfigPaths();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace System.Configuration
|
||||
s_properties = new ConfigurationPropertyCollection { s_propProviders, s_propDefaultProvider };
|
||||
}
|
||||
|
||||
public ProtectedConfigurationSection(){}
|
||||
public ProtectedConfigurationSection(){}
|
||||
|
||||
protected internal override ConfigurationPropertyCollection Properties => s_properties;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace System.Configuration
|
||||
ProviderSettings ps = Providers[providerName];
|
||||
|
||||
if (ps == null)
|
||||
throw new Exception(string.Format(SR.ProtectedConfigurationProvider_not_found, providerName));
|
||||
throw new ArgumentException(string.Format(SR.ProtectedConfigurationProvider_not_found, providerName), nameof(providerName));
|
||||
|
||||
return InstantiateProvider(ps);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace System.Configuration
|
||||
{
|
||||
Type t = TypeUtil.GetType(pn.Type, true);
|
||||
if (!typeof(ProtectedConfigurationProvider).IsAssignableFrom(t))
|
||||
throw new Exception(SR.WrongType_of_Protected_provider);
|
||||
throw new ArgumentException(SR.WrongType_of_Protected_provider, nameof(pn));
|
||||
|
||||
return CreateAndInitializeProviderWithAssert(t, pn);
|
||||
}
|
||||
@@ -116,4 +116,4 @@ namespace System.Configuration
|
||||
return encNode.OuterXml;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ using System.Runtime.Serialization;
|
||||
namespace System.Configuration.Provider
|
||||
{
|
||||
[Serializable]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
#endif
|
||||
public class ProviderException : Exception
|
||||
{
|
||||
public ProviderException() { }
|
||||
@@ -22,7 +25,6 @@ namespace System.Configuration.Provider
|
||||
protected ProviderException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ using System.Runtime.Serialization;
|
||||
namespace System.Configuration
|
||||
{
|
||||
[Serializable]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#endif
|
||||
public class SettingsPropertyIsReadOnlyException : Exception
|
||||
{
|
||||
public SettingsPropertyIsReadOnlyException(String message)
|
||||
@@ -22,10 +25,10 @@ namespace System.Configuration
|
||||
protected SettingsPropertyIsReadOnlyException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public SettingsPropertyIsReadOnlyException()
|
||||
{ }
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ using System.Runtime.Serialization;
|
||||
namespace System.Configuration
|
||||
{
|
||||
[Serializable]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#endif
|
||||
public class SettingsPropertyNotFoundException : Exception
|
||||
{
|
||||
public SettingsPropertyNotFoundException(String message)
|
||||
@@ -22,11 +25,11 @@ namespace System.Configuration
|
||||
protected SettingsPropertyNotFoundException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public SettingsPropertyNotFoundException()
|
||||
{ }
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ using System.Runtime.Serialization;
|
||||
namespace System.Configuration
|
||||
{
|
||||
[Serializable]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#endif
|
||||
public class SettingsPropertyWrongTypeException : Exception
|
||||
{
|
||||
public SettingsPropertyWrongTypeException(String message)
|
||||
@@ -22,10 +25,10 @@ namespace System.Configuration
|
||||
protected SettingsPropertyWrongTypeException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public SettingsPropertyWrongTypeException()
|
||||
{ }
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace System.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
@@ -101,6 +101,56 @@ namespace MonoTests.System.Configuration
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertFrom_InvalidString_WhiteSpaceAtTheBeginning()
|
||||
{
|
||||
GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));
|
||||
object o = null;
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => o = cv.ConvertFrom(null, null, " Foo"));
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertFrom_InvalidString_WhiteSpaceAtTheEnd()
|
||||
{
|
||||
GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));
|
||||
object o = null;
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => o = cv.ConvertFrom(null, null, "Foo "));
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertFrom_InvalidString_DigitAtTheBeginning()
|
||||
{
|
||||
GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));
|
||||
object o = null;
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => o = cv.ConvertFrom(null, null, "1Foo"));
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertFrom_InvalidString_PlusSignAtTheBeginning()
|
||||
{
|
||||
GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));
|
||||
object o = null;
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => o = cv.ConvertFrom(null, null, "+Foo"));
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertFrom_InvalidString_MinusSignAtTheBeginning()
|
||||
{
|
||||
GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));
|
||||
object o = null;
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => o = cv.ConvertFrom(null, null, "-Foo"));
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertFrom_Null()
|
||||
{
|
||||
@@ -111,6 +161,16 @@ namespace MonoTests.System.Configuration
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertFrom_EmptyString()
|
||||
{
|
||||
GenericEnumConverter cv = new GenericEnumConverter(typeof(FooEnum));
|
||||
object o = null;
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => o = cv.ConvertFrom(null, null, string.Empty));
|
||||
Assert.Null(o);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertTo()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user