You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -117,4 +117,4 @@ using System.Diagnostics.CodeAnalysis;
|
||||
[assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope="member", Target="Microsoft.Win32.SystemEvents.get_UserInteractive():System.Boolean")]
|
||||
|
||||
namespace System.ComponentModel {
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,9 @@ namespace System.ComponentModel {
|
||||
/// <para>Provides data for the <see langword='PropertyChanged'/>
|
||||
/// event.</para>
|
||||
/// </devdoc>
|
||||
#if !SILVERLIGHT
|
||||
[HostProtection(SharedState = true)]
|
||||
#endif
|
||||
public class PropertyChangedEventArgs : EventArgs {
|
||||
private readonly string propertyName;
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace System.ComponentModel {
|
||||
/// <see langword='PropertyChanged'/> event raised when a
|
||||
/// property is changed on a component.</para>
|
||||
/// </devdoc>
|
||||
#if !SILVERLIGHT
|
||||
[HostProtection(SharedState = true)]
|
||||
#endif
|
||||
public delegate void PropertyChangedEventHandler(object sender, PropertyChangedEventArgs e);
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,6 @@ namespace System.ComponentModel {
|
||||
|
||||
object invokee = GetInvocationTarget(componentClass, component);
|
||||
|
||||
Debug.Assert(!IsReadOnly, "SetValue attempted on read-only property [" + Name + "]");
|
||||
if (!IsReadOnly) {
|
||||
|
||||
// Announce that we are about to change this component
|
||||
|
||||
@@ -90,12 +90,11 @@ namespace System.ComponentModel {
|
||||
return nativeErrorCode;
|
||||
}
|
||||
}
|
||||
#if !MONO
|
||||
private static string GetErrorMessage(int error) {
|
||||
//get the system error message...
|
||||
string errorMsg = "";
|
||||
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
#if !MONO
|
||||
private static bool TryGetErrorMessage(int error, StringBuilder sb, out string errorMsg)
|
||||
{
|
||||
errorMsg = "";
|
||||
int result = SafeNativeMethods.FormatMessage(
|
||||
SafeNativeMethods.FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
SafeNativeMethods.FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
@@ -111,11 +110,48 @@ namespace System.ComponentModel {
|
||||
}
|
||||
errorMsg = sb.ToString(0, i);
|
||||
}
|
||||
else if (Marshal.GetLastWin32Error() == SafeNativeMethods.ERROR_INSUFFICIENT_BUFFER) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
errorMsg ="Unknown error (0x" + Convert.ToString(error, 16) + ")";
|
||||
}
|
||||
|
||||
return errorMsg;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Windows API FormatMessage lets you format a message string given an errocode.
|
||||
// Unlike other APIs this API does not support a way to query it for the total message size.
|
||||
//
|
||||
// So the API can only be used in one of these two ways.
|
||||
// a. You pass a buffer of appropriate size and get the resource.
|
||||
// b. Windows creates a buffer and passes the address back and the onus of releasing the bugffer lies on the caller.
|
||||
//
|
||||
// Since the error code is coming from the user, it is not possible to know the size in advance.
|
||||
// Unfortunately we can't use option b. since the buffer can only be freed using LocalFree and it is a private API on onecore.
|
||||
// Also, using option b is ugly for the manged code and could cause memory leak in situations where freeing is unsuccessful.
|
||||
//
|
||||
// As a result we use the following approach.
|
||||
// We initially call the API with a buffer size of 256 and then gradually increase the size in case of failure until we reach the max allowed size of 65K bytes.
|
||||
|
||||
private const int MaxAllowedBufferSize = 65 * 1024;
|
||||
|
||||
private static string GetErrorMessage(int error) {
|
||||
string errorMsg;
|
||||
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
do {
|
||||
if (TryGetErrorMessage(error, sb, out errorMsg))
|
||||
return errorMsg;
|
||||
else {
|
||||
// increase the capacity of the StringBuilder by 4 times.
|
||||
sb.Capacity *= 4;
|
||||
}
|
||||
}
|
||||
while (sb.Capacity < MaxAllowedBufferSize);
|
||||
|
||||
// If you come here then a size as large as 65K is also not sufficient and so we give the generic errorMsg.
|
||||
return "Unknown error (0x" + Convert.ToString(error, 16) + ")";
|
||||
}
|
||||
#endif
|
||||
// Even though all we're exposing is the nativeErrorCode (which is also available via public property)
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace System.ComponentModel.Design {
|
||||
Debug.WriteLineIf(RuntimeLicenseContextSwitch.TraceVerbose,"rawfile: " + rawFile);
|
||||
string codeBase;
|
||||
|
||||
#if !DISABLE_CAS_USE
|
||||
// FileIOPermission is required for ApplicationBase in URL-hosted domains
|
||||
FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
|
||||
perm.Assert();
|
||||
@@ -102,6 +103,9 @@ namespace System.ComponentModel.Design {
|
||||
finally {
|
||||
CodeAccessPermission.RevertAssert();
|
||||
}
|
||||
#else
|
||||
codeBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
|
||||
#endif
|
||||
if (rawFile != null && codeBase != null) {
|
||||
licenseFile = new Uri(new Uri(codeBase), rawFile);
|
||||
}
|
||||
@@ -129,6 +133,7 @@ namespace System.ComponentModel.Design {
|
||||
// file://fullpath/foo.exe
|
||||
//
|
||||
string fileName;
|
||||
#if !DISABLE_CAS_USE
|
||||
FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
|
||||
perm.Assert();
|
||||
try
|
||||
@@ -140,6 +145,10 @@ namespace System.ComponentModel.Design {
|
||||
{
|
||||
CodeAccessPermission.RevertAssert();
|
||||
}
|
||||
#else
|
||||
fileName = GetLocalPath(asm.EscapedCodeBase);
|
||||
fileName = new FileInfo(fileName).Name;
|
||||
#endif
|
||||
|
||||
Stream s = asm.GetManifestResourceStream(fileName + ".licenses");
|
||||
if (s == null) {
|
||||
@@ -245,10 +254,11 @@ namespace System.ComponentModel.Design {
|
||||
|
||||
static Stream OpenRead(Uri resourceUri) {
|
||||
Stream result = null;
|
||||
|
||||
#if !DISABLE_CAS_USE
|
||||
PermissionSet perms = new PermissionSet(PermissionState.Unrestricted);
|
||||
|
||||
perms.Assert();
|
||||
#endif
|
||||
try {
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.Credentials = CredentialCache.DefaultCredentials;
|
||||
@@ -257,10 +267,11 @@ namespace System.ComponentModel.Design {
|
||||
catch (Exception e) {
|
||||
Debug.Fail(e.ToString());
|
||||
}
|
||||
#if !DISABLE_CAS_USE
|
||||
finally {
|
||||
CodeAccessPermission.RevertAssert();
|
||||
}
|
||||
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user