Compare commits

...
Author SHA1 Message Date
Alexander Köplinger 11a5aa9194 Merge pull request #3065 from rolfbjarne/git-instead-of-ssh-4.5.0
[offsets-tool] Use git protocol instead of ssh to allow anonymous access.
2016-05-27 17:40:55 +02:00
Alexander Köplinger 4c5bc2f25d Merge pull request #3064 from rolfbjarne/fix-rebuild-offsets-tool-4.5.0
[offsets-tool] Only create the .stamp-clone file if the clone succeeds.
2016-05-27 17:02:28 +02:00
Rolf Bjarne Kvinge 9475ea4fb5 [offsets-tool] Use git protocol instead of ssh to allow anonymous access. 2016-05-27 17:01:07 +02:00
Rolf Bjarne Kvinge fd9042c45f [offsets-tool] Only create the .stamp-clone file if the clone succeeds.
This makes rebuilds work if the clone was cancelled.
2016-05-27 16:56:57 +02:00
Alexander Köplinger 07fa020214 [xbuild] Add AssignLinkMetadata to xbuild 14
This is essentially the same as https://github.com/mono/mono/commit/639bf661715fc190b595d05193c335f70b3313eb but for the xbuild 14 profile.

(cherry picked from commit 30dd64033c)
2016-05-23 16:41:06 +02:00
Alexander Köplinger 759c1feba6 [xbuild] Make sure MSBuildFrameworkToolsPath is set for xbuild 14
(cherry picked from commit 4103bd9aae)
2016-05-23 16:41:03 +02:00
Alexander Köplinger fe326b4b03 [xbuild] Fix DependsOnSystemRuntime returning false on xbuild 14
In https://github.com/mono/mono/commit/4164d9fbe19a1e6acb3a5ea122891020ff2868d7 the 14.0 target was updated to include
the DependsOnSystemRuntime property. However, it wasn't actually implemented in the code behind. This resulted in the
property not being set/true even if we depend on assemblies that reference System.Runtime, which in turn leads us to not
adding the Facades in ImplicitlyExpandDesignTimeFacades. This then breaks compilation because the System.Runtime lookup fails.

The fix is to actually implement the property.

(cherry picked from commit d44824b7f8)
2016-05-23 16:41:00 +02:00
Andi McClure 4b2ce1dd9b Add some comments in new/old gc bridges 2016-05-17 13:23:02 -04:00
Andi McClure e15dc436d6 Fix error message in sgen-bridge which does not list all options 2016-05-17 12:47:35 -04:00
Andi McClure 87e1a9dec7 Remove redundant flag set in sgen-tarjan-bridge
bridge_processing_in_progress is set by sgen-tarjan-bridge.c at the
start and end of each bridge, although sgen-bridge sets this flag at
the same time.
2016-05-17 12:47:05 -04:00
Andi McClure 37c4bf2811 More accurate trace reporting duration of android gc bridge
There is some code that reports the length of a gc bridge operation in
sgen-stw. This is dead code dating from a period when gc bridges
occurred synchronously as part of a stop the world operation. The new
code globally tracks the end of the last stw and reports time since
then when the bridge thread completes.
2016-05-17 12:45:49 -04:00
Martin Baulig 9c18adad5b [corlib]: Update X509Helper.Apple.cs. 2016-05-16 14:43:32 -04:00
Rolf Bjarne Kvinge ddf0c921cc Bump nunit-lite to get compiler warning fix.
commit //github.com/mono/NUnitLite@7065bc89e8661cad447140752c0fce118644e06e
Author: Rolf Bjarne Kvinge <[email protected]>
Date:   Thu May 12 12:30:28 2016 +0200

    Fix compiler warning.
2016-05-12 12:39:36 +02:00
Alexander Köplinger c7a9db4601 [corlib] Make CountdownEventTests.Signal_Concurrent more reliable
We were seeing random failures of the test in the iOS simulator and devices.

Looking at the test, it seems to me like the 1000ms timeout is just too short. In a single iteration we're
enqueuing 500 threadpool workitems and effectively give each of them just 2ms to run and signal the CountdownEvent.

Indeed I can easily repro this in the simulator on my box if I lower the timeout to 900ms.
This may be a side effect of the new threadpool which starts threads more conservatively afaik.

Bumping the timeout should fix this.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=39305

(cherry picked from commit 5745b945a2)
2016-05-11 18:36:28 +02:00
Alexander Köplinger 2bb8b89fbb [corlib] Ignore DirectoryNotFoundException in FileStreamTest.OpenCharDeviceRepeatedly test
It seems that older iOS6 devices don't allow access to /dev, as a DirectoryNotFoundException is
thrown when accessing /dev/zero in the FileStreamTest.OpenCharDeviceRepeatedly test there.

Ignore this exception and the test in those cases.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=40462

(cherry picked from commit 8fd52718cf)
2016-05-11 18:36:21 +02:00
Martin Baulig c21a1a986e [System]: Lazy-init X509ChainPolicy.ExtraStore when called from SystemCertificateValidator. Fixes #40899.
AppleTLS supports a lazily-initialized X509Certificate, but not X509Certificate2 so
we need to fall-back to using Mono.Security.X509 whenever we need an X509Certificate2.
To avoid unnecessary fallbacks, the private Mono.Net.Security APIs use X509Certificate
instead of X509Certificate2.

Since 'ExtraStore' returns X509Certificate2Collection, we need to convert these to
X509Certificate2.

(cherry picked from commit 05e2372339)
2016-05-10 13:40:49 -04:00
Marek Safar e06d95aee7 [mcs] More tweaks to undefined tie-breaking rules. Fixes #40945 2016-05-10 17:38:38 +02:00
Martin Baulig d2fd8af07c [System]: Fix certificate validation with empty hostname.
When the system certificate validator is invoked with an empty hostname
(caller does not want us to validate the hostname), then we need to pass
null to SecPolicyCreateSSL() and not the empty string.

(cherry picked from commit f29804d149)
2016-05-06 16:12:10 -04:00
Martin Baulig b83734b685 [System]: Add comment to the obsoletion of Mono-specific ServicePointManager APIs.
(cherry picked from commit 1b4921b573)
2016-05-06 15:59:19 -04:00
Martin Baulig f8449e3c83 [System]: Obsolete the Mono-specific cipher suite callbacks in ServicePointManager.
(cherry picked from commit fa75386bb8)
2016-05-05 17:22:32 -04:00
Martin Baulig 4c841588ab [corlib]: Cleanup X509Helper.Import().
Only attempt the automatic PEM->DER conversion when no password was given
and make this version of X509Helper.Import() also take care of the fallback.

(cherry picked from commit 63a214c3f0)
2016-05-05 17:22:23 -04:00
Martin Baulig 69e0c474af [corlib]: Try to convert the certificate from PEM to DER in X509Helper.Import().
(cherry picked from commit 0adfeefedd)
2016-05-04 20:07:18 -04:00
Marek Safar f4252bf31f [System.Runtime.Serialization] Remove redundant IVT to System.ServiceModel.Web 2016-05-03 19:11:14 -04:00
Marek Safar b1b43988be [System.Runtime.Serialization] Remove redundant IVT to System.ServiceModel 2016-05-03 19:10:59 -04:00
Zoltan Varga e714f39a69 [arm64] Dist arm64-codegen.h. Fixes #38223. 2016-04-29 23:25:29 -04:00
Alexander Köplinger 8a5a727862 [corlib] Ignore a TimeZoneInfo test on mobile that doesn't make sense there
It failed on maccore because it uses reflection on code that's excluded on mobile.
Exclude the test too, fixes part 1 of #40624

(cherry picked from commit f0f9b6ac90)
2016-04-26 09:39:51 -04:00
Alexander Köplinger b0e53d628a [corlib] Fix FileInfoTest.MoveTo_SameName test that failed on mobile
The MoveTo target is in the current working directory instead of in the temp dir, so it runs into permission issues.
Use the temp dir instead. Fixes part 2 of #40624

(cherry picked from commit c602e3b04c)
2016-04-26 09:39:51 -04:00
Sebastien Pouliot 6ee3ac5fdb [linker] Method decorated with System.Runtime.Serialization.*Attribute must be marked, Fixes #40574
Some serialization attributes are unlikely to have direct reference,
from IL, but will be needed at runtime to correctly serialize (or
deserialize) objects.

* OnDeserializedAttribute
* OnDeserializingAttribute
* OnSerializedAttribute
* OnSerializingAttribute

This, along with aad627c5e8, fixed bug
40574. The later part will have new unit tests in XI.

references:
https://bugzilla.xamarin.com/show_bug.cgi?id=40574
2016-04-24 16:36:18 -04:00
Marek Safar 95a02a52d4 [corlib] Disable core security icalls on mobile 2016-04-23 05:01:53 -04:00
Marek Safar 87d50fbdb5 [corlib] Remove System.Core security types 2016-04-22 09:04:37 -04:00
Sebastien Pouliot e7abfa0270 [System.Core] Add back AesManaged to tvOS and watchOS profiles
Switching maccore to use mono-4.5.0-branch introduced this bug where
AesManaged is not available in System.Core for both tvOS and watchOS
profiles (iOS is fine).

This results in unit tests failures on bots building maccore/master.

This fix the problem by importing the "main" monotouch_System.Core.
dll.sources into the other profiles - since they all share the same
feature set (in this case) and make it less likely to forget something
else in the future.

reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=40570
(cherry picked from commit eecca1fa0e)
2016-04-22 09:36:36 +02:00
Ludovic Henry 2a76e5b082 [corlib] Ifdef out calls to SynchronizationAttribute on monotouch
When WaitHandle was imported from referencesource in f6fa8f0, the code was refactored and basically all WaitHandle.Wait* calls end up in WaitOneNative or WaitMultiple now.

On monotouch those methods threw a NotSupportedException when exitContext == true even before the import, so this behavior got inherited to some other methods that didn't throw after the exception was removed from them in 93e31cb. This broke tests in maccore and other code that passed exitContext=true.

To fix this, we just ifdef out the calls to SynchronizationAttribute on monotouch since they don't make sense there anyway since remoting isn't available. The commit that initially added the exception in 2ce9fc1 only did that to make the behavior consistent when the linker is enabled. By removing the calls we get the same result.

Do the same for Monitor so we're consistent.

(cherry picked from commit 06dff0b90e)
2016-04-21 12:43:02 +02:00
Marek Safar 95278910f3 [mcs] null operator receiver type needs to be convertible to null. Fixes #40493 2016-04-20 14:28:53 +02:00
Alexander Köplinger 480bcd4b70 [utils] Fix MONO_SIGNAL_USE_UCONTEXT_T not being defined on tvOS simulator
In the maccore tvossimulator tests we were seeing the following assertion with the Mono 4.5 preview:

```
error: * Assertion: should not be reached at /Users/builder/data/lanes/1381/0d6923b4/source/maccore/external/mono/mono/utils/mono-context.c:194

0   dont link                           0x000000010175702d mono_handle_native_sigsegv + 253
1   libsystem_platform.dylib            0x000000010a0cfeaa _sigtramp + 26
2   ???                                 0x0000000001bfc4db 0x0 + 29344987
3   libsystem_c.dylib                   0x0000000109e56cbc abort + 129
4   dont link                           0x00000001018d1503 _ZL12log_callbackPKcS0_S0_iPv + 67
5   dont link                           0x00000001018c26d0 monoeg_assertion_message + 192
6   dont link                           0x00000001018af6de mono_sigctx_to_monoctx + 30
7   dont link                           0x000000010183f473 sgen_suspend_thread + 323
8   dont link                           0x000000010183f58e sgen_thread_handshake + 126
9   dont link                           0x000000010183fb20 sgen_client_stop_world + 1296
10  dont link                           0x0000000101871283 sgen_stop_world + 67
11  dont link                           0x0000000101870d43 sgen_perform_collection + 99
12  dont link                           0x0000000101872576 sgen_gc_collect + 102
13  dont link                           0x00000001018d1886 _ZL7pump_gcPv + 54
14  libsystem_pthread.dylib             0x000000010a0b7c13 _pthread_body + 131
15  libsystem_pthread.dylib             0x000000010a0b7b90 _pthread_body + 0
16  libsystem_pthread.dylib             0x000000010a0b5375 thread_start + 13
```

This was caused by a4e257a07f, the issue is that the check was changed from UCONTEXT_REG_RAX to MONO_SIGNAL_USE_UCONTEXT_T, but that is only available when HAVE_SIGACTION is defined which it is not in this case.

Discussed with Zoltan, fixing this by enabling MONO_SIGNAL_USE_UCONTEXT_T on all apple platforms for now.

(cherry picked from commit 04669f1ea9)
2016-04-20 01:06:50 +02:00
Marek Safar 510af4b6e7 [mcs] Don't do empty array interpolation on user code, weird code expects empty array not to be equal 2016-04-19 19:21:14 +02:00
Marek Habersack ae83f6bd02 Support custom Xamarin Android HttpClient handler
Make it possible to select a default System.Net.HttpClient handler
on Android. Selection of the handler is handled on the Xamarin Android
side.
2016-04-19 18:37:52 +02:00
Rolf Bjarne Kvinge d445cca2f2 [offsets-tool] Fix path to Options.cs 2016-04-19 11:59:26 +02:00
60 changed files with 657 additions and 329 deletions

No files matched your search

@@ -1035,7 +1035,7 @@ namespace Microsoft.Build.BuildEngine {
evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
#if XBUILD_12
// see http://msdn.microsoft.com/en-us/library/vstudio/hh162058(v=vs.120).aspx
if (effective_tools_version == "12.0") {
if (effective_tools_version == "12.0" || effective_tools_version == "14.0") {
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath32", toolsPath, PropertyType.Reserved));
var frameworkToolsPath = ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version451);
@@ -128,6 +128,10 @@ namespace Microsoft.Build.Tasks {
relatedFiles = tempRelatedFiles.Values.ToArray ();
resolvedDependencyFiles = tempResolvedDepFiles.Values.ToArray ();
#if XBUILD_14
DependsOnSystemRuntime = resolvedDependencyFiles.Any (x => Path.GetFileName (x.ItemSpec) == "System.Runtime.dll").ToString ();
#endif
tempResolvedFiles.Clear ();
tempCopyLocalFiles.Clear ();
tempSatelliteFiles.Clear ();
@@ -40,65 +40,16 @@ namespace Mono.Security.Protocol.Tls
public static CipherSuiteCollection GetSupportedCiphers (bool server, SecurityProtocolType protocol)
{
CipherSuiteCollection suites;
switch (protocol) {
case SecurityProtocolType.Default:
case SecurityProtocolType.Tls:
suites = CipherSuiteFactory.GetTls1SupportedCiphers ();
break;
return CipherSuiteFactory.GetTls1SupportedCiphers ();
case SecurityProtocolType.Ssl3:
suites = CipherSuiteFactory.GetSsl3SupportedCiphers ();
break;
return CipherSuiteFactory.GetSsl3SupportedCiphers ();
case SecurityProtocolType.Ssl2:
default:
throw new NotSupportedException ("Unsupported security protocol type");
}
IEnumerable<string> list = null;
#if INSIDE_SYSTEM
// if SSL/TLS support is built-in System.dll (e.g. monotouch) then we can access ServicePointManager
// extension directly
var cb = server ? ServicePointManager.ServerCipherSuitesCallback : ServicePointManager.ClientCipherSuitesCallback;
if (cb == null)
return suites; // e.g. no callback was set
list = cb ((System.Net.SecurityProtocolType) (int) protocol, suites.GetNames ());
#elif !BOOTSTRAP_BASIC
// Mono.Security must work on MS.NET so it cannot depend on any Mono-specific extensions
PropertyInfo pi = null;
if (server) {
if (server_callback == null)
server_callback = spm.GetProperty ("ServerCipherSuitesCallback", BindingFlags.Static | BindingFlags.Public);
pi = server_callback;
} else {
if (client_callback == null)
client_callback = spm.GetProperty ("ClientCipherSuitesCallback", BindingFlags.Static | BindingFlags.Public);
pi = client_callback;
}
if (pi == null)
return suites; // e.g. MS runtime - return every supported suites
var cb = (Delegate) pi.GetGetMethod ().Invoke (null, null);
if (cb == null)
return suites; // e.g. no callback was set - return every supported suites
list = (IEnumerable<string>) cb.DynamicInvoke (new object[] {
(System.Net.SecurityProtocolType) (int) protocol, suites.GetNames ()
});
#else
// TODO: right now the callback is only available when using System.Net.* types for SSL/TLS
return suites;
#endif
CipherSuiteCollection allowed = new CipherSuiteCollection (protocol);
if (list != null) {
foreach (var name in list) {
// add any supported (ignore unknowns) ciphers requested by the callback
var cipher = suites [name];
if (cipher != null)
allowed.Add (cipher);
}
}
return allowed;
}
#region Private Static Methods
@@ -169,17 +169,6 @@ public class TlsTest {
ServicePointManager.CertificatePolicy = new TestCertificatePolicy ();
ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType) (int) protocol;
ServicePointManager.ClientCipherSuitesCallback += (System.Net.SecurityProtocolType p, IEnumerable<string> allCiphers) => {
Console.WriteLine ("Protocol: {0}", p);
// var ciphers = allCiphers;
var ciphers = from cipher in allCiphers where !cipher.Contains ("EXPORT") select cipher;
string prefix = p == System.Net.SecurityProtocolType.Tls ? "TLS_" : "SSL_";
// var ciphers = new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA", prefix + "RSA_WITH_AES_256_CBC_SHA" };
foreach (var cipher in ciphers)
Console.WriteLine ("\t{0}", cipher);
return ciphers;
};
Uri uri = new Uri (url);
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (uri);
@@ -1,2 +1 @@
#include common_System.Core.dll.sources
#include interpreter_System.Core.dll.sources
#include monotouch_System.Core.dll.sources
@@ -1,2 +1 @@
#include common_System.Core.dll.sources
#include interpreter_System.Core.dll.sources
#include monotouch_System.Core.dll.sources
+3
View File
@@ -6,6 +6,9 @@ LIBRARY = System.Net.Http.dll
LIB_REFS = System.Core System
LIB_MCS_FLAGS = $(EXTRA_LIB_MCS_FLAGS)
ifeq (monodroid,$(PROFILE))
LIB_MCS_FLAGS += -d:XAMARIN_MODERN
endif
TEST_LIB_REFS = System System.Core
TEST_MCS_FLAGS =
@@ -0,0 +1,38 @@
using System;
using System.Reflection;
namespace System.Net.Http {
public partial class HttpClient {
public HttpClient ()
: this (GetDefaultHandler (), true)
{
}
static HttpMessageHandler GetDefaultHandler ()
{
Type type = Type.GetType("Android.Runtime.AndroidEnvironment, Mono.Android");
if (type == null)
return GetFallback ("Invalid Mono.Android assembly? Cannot find Android.Runtime.AndroidEnvironment");
MethodInfo method = type.GetMethod ("GetHttpMessageHandler", BindingFlags.Static | BindingFlags.NonPublic);
if (method == null)
return GetFallback ("Your Xamarin.Android version does not support obtaining of the custom HttpClientHandler");
object ret = method.Invoke (null, null);
if (ret == null)
return GetFallback ("Xamarin.Android returned no custom HttpClientHandler");
var handler = ret as HttpMessageHandler;
if (handler == null)
return GetFallback ($"{ret?.GetType()} is not a valid HttpMessageHandler");
return handler;
}
static HttpMessageHandler GetFallback (string message)
{
Console.WriteLine (message + ". Defaulting to System.Net.Http.HttpClientHandler");
return new HttpClientHandler ();
}
}
}
@@ -0,0 +1,2 @@
#include System.Net.Http.dll.sources
System.Net.Http/HttpClient.android.cs
@@ -62,11 +62,6 @@ using System.Runtime.InteropServices;
[assembly: AllowPartiallyTrustedCallers]
[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
[assembly: SecurityCritical (SecurityCriticalScope.Explicit)]
// for SyndicationElementExtension
// FIXME: mcs in 2-10 branch breaks System.ServiceModel build on resolving this. So, disabling it so far.
// [assembly: InternalsVisibleTo ("System.ServiceModel, PublicKey=00000000000000000400000000000000")]
#endif
[assembly: InternalsVisibleTo ("System.ServiceModel, PublicKey=" + AssemblyRef.FrameworkPublicKeyFull)]
[assembly: InternalsVisibleTo ("System.ServiceModel.Web, PublicKey=" + AssemblyRef.MicrosoftPublicKey)]
[assembly: ComVisible (false)]
@@ -65,16 +65,12 @@ namespace Mono.Net.Security
public static X509Chain CreateX509Chain (XX509CertificateCollection certs)
{
var chain = new X509Chain ();
chain.ChainPolicy = new X509ChainPolicy ();
chain.ChainPolicy = new X509ChainPolicy ((X509CertificateCollection)(object)certs);
#if !MOBILE
chain.ChainPolicy.RevocationMode = revocation_mode;
#endif
for (int i = 1; i < certs.Count; i++) {
chain.ChainPolicy.ExtraStore.Add (certs [i]);
}
return chain;
}
@@ -12,12 +12,20 @@ using System.Collections.Generic;
namespace System.Net {
/*
* The idea behind this API was to let the application filter the set of cipher suites received / send to
* the remote side. This concept does not any longer work with the new native implementations.
*/
[Obsolete ("This API is no longer supported.")]
public delegate IEnumerable<string> CipherSuitesCallback (SecurityProtocolType protocol, IEnumerable<string> allCiphers);
public partial class ServicePointManager {
[Obsolete ("This API is no longer supported.", true)]
public static CipherSuitesCallback ClientCipherSuitesCallback { get; set; }
[Obsolete ("This API is no longer supported.", true)]
public static CipherSuitesCallback ServerCipherSuitesCallback { get; set; }
}
}
}
@@ -147,7 +147,8 @@ namespace System.Security.Cryptography.X509Certificates {
certArray = FromIntPtrs (secCerts);
host = CFStringCreateWithCharacters (IntPtr.Zero, hostName, (IntPtr) hostName.Length);
if (!string.IsNullOrEmpty (hostName))
host = CFStringCreateWithCharacters (IntPtr.Zero, hostName, (IntPtr) hostName.Length);
sslsecpolicy = SecPolicyCreateSSL (true, host);
int code = SecTrustCreateWithCertificates (certArray, sslsecpolicy, out sectrust);
@@ -35,7 +35,8 @@ namespace System.Security.Cryptography.X509Certificates {
private OidCollection apps;
private OidCollection cert;
private X509Certificate2Collection store;
private X509CertificateCollection store;
private X509Certificate2Collection store2;
private X509RevocationFlag rflag;
private X509RevocationMode mode;
private TimeSpan timeout;
@@ -49,6 +50,24 @@ namespace System.Security.Cryptography.X509Certificates {
Reset ();
}
/*
* Lazy-init ExtraStore from X509CertificateCollection.
* This is called from Mono.Net.Security.SystemCertificateValidator.CreateX509Chain.
*
* AppleTLS supports a lazily-initialized X509Certificate, but not X509Certificate2 so
* we need to fall-back to using Mono.Security.X509 whenever we need an X509Certificate2.
* To avoid unnecessary fallbacks, the private Mono.Net.Security APIs use X509Certificate
* instead of X509Certificate2.
*
* Since 'ExtraStore' returns X509Certificate2Collection, we need to convert these to
* X509Certificate2.
*/
internal X509ChainPolicy (X509CertificateCollection store)
{
this.store = store;
Reset ();
}
// properties
public OidCollection ApplicationPolicy {
@@ -60,7 +79,18 @@ namespace System.Security.Cryptography.X509Certificates {
}
public X509Certificate2Collection ExtraStore {
get { return store; }
get {
if (store2 != null)
return store2;
store2 = new X509Certificate2Collection ();
if (store != null) {
foreach (var cert in store) {
store2.Add (new X509Certificate2 (cert));
}
}
return store2;
}
}
public X509RevocationFlag RevocationFlag {
@@ -106,7 +136,7 @@ namespace System.Security.Cryptography.X509Certificates {
{
apps = new OidCollection ();
cert = new OidCollection ();
store = new X509Certificate2Collection ();
store2 = null;
rflag = X509RevocationFlag.ExcludeRoot;
mode = X509RevocationMode.Online;
timeout = TimeSpan.Zero;
@@ -95,80 +95,6 @@ public class SslStreamTest {
}
}
[Test]
public void ClientCipherSuitesCallback ()
{
try {
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA" };
};
// client will only offers AES 128 - that's fine since the server support it (and many more ciphers)
AuthenticateClientAndServer_ClientSendsNoData ();
}
finally {
ServicePointManager.ClientCipherSuitesCallback = null;
}
}
[Test]
public void ServerCipherSuitesCallback ()
{
try {
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
// server only accept AES 256 - that's fine since the client support it (and many more ciphers)
AuthenticateClientAndServer_ClientSendsNoData ();
}
finally {
ServicePointManager.ServerCipherSuitesCallback = null;
}
}
[Test]
public void CipherSuitesCallbacks ()
{
try {
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA", prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA", prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
// both client and server supports AES (128 and 256) - server will select 128 (first choice)
AuthenticateClientAndServer_ClientSendsNoData ();
}
finally {
ServicePointManager.ClientCipherSuitesCallback = null;
ServicePointManager.ServerCipherSuitesCallback = null;
}
}
[Test]
public void MismatchedCipherSuites ()
{
try {
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA" };
};
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
// mismatch! server will refuse and send back an alert
AuthenticateClientAndServer (false, false);
}
finally {
ServicePointManager.ClientCipherSuitesCallback = null;
ServicePointManager.ServerCipherSuitesCallback = null;
}
}
private void StartClientAndAuthenticate (ClientServerState state,
IPEndPoint endPoint) {
try {
-2
View File
@@ -75,10 +75,8 @@ CC_PROFILE := $(filter monotouch% xammac, $(PROFILE))
ifdef CC_PROFILE
BUILT_SOURCES = \
CommonCrypto/AesCryptoServiceProvider.g.cs \
CommonCrypto/MD5CryptoServiceProvider.g.cs \
CommonCrypto/SHA256Managed.g.cs \
CommonCrypto/AesManaged.g.cs \
CommonCrypto/RC2CryptoServiceProvider.g.cs \
CommonCrypto/SHA384Managed.g.cs \
CommonCrypto/DESCryptoServiceProvider.g.cs \
@@ -602,6 +602,12 @@ namespace System
get;
}
#if MOBILE
static int get_core_clr_security_level ()
{
return 1;
}
#else
//seclevel { transparent = 0, safe-critical = 1, critical = 2}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int get_core_clr_security_level ();
@@ -616,6 +622,7 @@ namespace System
public override bool IsSecuritySafeCritical {
get { return get_core_clr_security_level () == 1; }
}
}
#endif
}
}
@@ -296,6 +296,12 @@ namespace System.Reflection {
throw new InvalidOperationException ("Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true.");
}
#if MOBILE
static int get_core_clr_security_level ()
{
return 1;
}
#else
//seclevel { transparent = 0, safe-critical = 1, critical = 2}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int get_core_clr_security_level ();
@@ -311,5 +317,6 @@ namespace System.Reflection {
public override bool IsSecuritySafeCritical {
get { return get_core_clr_security_level () == 1; }
}
#endif
}
}
@@ -502,9 +502,16 @@ namespace System.Reflection {
return CustomAttributeData.GetCustomAttributes (this);
}
#if MOBILE
static int get_core_clr_security_level ()
{
return 1;
}
#else
//seclevel { transparent = 0, safe-critical = 1, critical = 2}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int get_core_clr_security_level ();
#endif
public override bool IsSecurityTransparent {
get { return get_core_clr_security_level () == 0; }
@@ -752,8 +759,15 @@ namespace System.Reflection {
return CustomAttributeData.GetCustomAttributes (this);
}
#if MOBILE
static int get_core_clr_security_level ()
{
return 1;
}
#else
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int get_core_clr_security_level ();
#endif
public override bool IsSecurityTransparent {
get { return get_core_clr_security_level () == 0; }
@@ -12,35 +12,22 @@ namespace System.Security.Cryptography.X509Certificates
return new X509CertificateImplApple (handle, false);
}
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
static X509CertificateImpl Import (byte[] rawData)
{
MX.X509Certificate x509;
IntPtr handle;
if (password == null) {
handle = CFHelpers.CreateCertificateFromData (rawData);
if (handle != IntPtr.Zero)
return new X509CertificateImplApple (handle, true);
var handle = CFHelpers.CreateCertificateFromData (rawData);
if (handle != IntPtr.Zero)
return new X509CertificateImplApple (handle, true);
MX.X509Certificate x509;
try {
x509 = new MX.X509Certificate (rawData);
} catch (Exception e) {
try {
x509 = new MX.X509Certificate (rawData);
} catch (Exception e) {
try {
x509 = X509Helper.ImportPkcs12 (rawData, null);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
} else {
// try PKCS#12
try {
x509 = X509Helper.ImportPkcs12 (rawData, password);
}
catch {
// it's possible to supply a (unrequired/unusued) password
// fix bug #79028
x509 = new MX.X509Certificate (rawData);
x509 = ImportPkcs12 (rawData, null);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
@@ -148,34 +148,46 @@ namespace System.Security.Cryptography.X509Certificates
}
}
#if !MONOTOUCH && !XAMMAC
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
static byte[] PEM (string type, byte[] data)
{
if (nativeHelper != null)
return nativeHelper.Import (rawData, password, keyStorageFlags);
string pem = Encoding.ASCII.GetString (data);
string header = String.Format ("-----BEGIN {0}-----", type);
string footer = String.Format ("-----END {0}-----", type);
int start = pem.IndexOf (header) + header.Length;
int end = pem.IndexOf (footer, start);
string base64 = pem.Substring (start, (end - start));
return Convert.FromBase64String (base64);
}
static byte[] ConvertData (byte[] data)
{
if (data == null || data.Length == 0)
return data;
// does it looks like PEM ?
if (data [0] != 0x30) {
try {
return PEM ("CERTIFICATE", data);
} catch {
// let the implementation take care of it.
}
}
return data;
}
#if !MONOTOUCH && !XAMMAC
static X509CertificateImpl Import (byte[] rawData)
{
MX.X509Certificate x509;
if (password == null) {
try {
x509 = new MX.X509Certificate (rawData);
} catch (Exception e) {
try {
x509 = new MX.X509Certificate (rawData);
} catch (Exception e) {
try {
x509 = ImportPkcs12 (rawData, null);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
} else {
// try PKCS#12
try {
x509 = ImportPkcs12 (rawData, password);
}
catch {
// it's possible to supply a (unrequired/unusued) password
// fix bug #79028
x509 = new MX.X509Certificate (rawData);
x509 = ImportPkcs12 (rawData, null);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
@@ -183,6 +195,26 @@ namespace System.Security.Cryptography.X509Certificates
}
#endif
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
if (password == null) {
rawData = ConvertData (rawData);
return Import (rawData);
}
MX.X509Certificate x509;
// try PKCS#12
try {
x509 = ImportPkcs12 (rawData, password);
} catch {
// it's possible to supply a (unrequired/unusued) password
// fix bug #79028
x509 = new MX.X509Certificate (rawData);
}
return new X509CertificateImplMono (x509);
}
public static byte[] Export (X509CertificateImpl impl, X509ContentType contentType, byte[] password)
{
ThrowIfContextInvalid (impl);
+12 -12
View File
@@ -159,33 +159,33 @@ namespace System.Threading
public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) {
try {
if (exitContext) {
#if MONOTOUCH
throw new NotSupportedException ("exitContext == true is not supported");
#else
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
}
return Wait (obj, millisecondsTimeout);
}
finally {
if (exitContext) SynchronizationAttribute.EnterContext ();
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
#endif
}
}
public static bool Wait(object obj, TimeSpan timeout, bool exitContext) {
try {
if (exitContext) {
#if MONOTOUCH
throw new NotSupportedException ("exitContext == true is not supported");
#else
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
}
return Wait (obj, timeout);
}
finally {
if (exitContext) SynchronizationAttribute.EnterContext ();
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
#endif
}
}
+16 -18
View File
@@ -47,16 +47,13 @@ namespace System.Threading
static int WaitMultiple(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll)
{
#if MONOTOUCH
if (exitContext)
throw new NotSupportedException ("exitContext == true is not supported");
#endif
int release_last = -1;
try {
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
for (int i = 0; i < waitHandles.Length; ++i) {
try {
@@ -70,51 +67,52 @@ namespace System.Threading
}
if (WaitAll)
return WaitAll_internal (waitHandles, millisecondsTimeout, exitContext);
return WaitAll_internal (waitHandles, millisecondsTimeout);
else
return WaitAny_internal (waitHandles, millisecondsTimeout, exitContext);
return WaitAny_internal (waitHandles, millisecondsTimeout);
} finally {
for (int i = release_last; i >= 0; --i) {
waitHandles [i].SafeWaitHandle.DangerousRelease ();
}
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
#endif
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int WaitAll_internal(WaitHandle[] handles, int ms, bool exitContext);
private static extern int WaitAll_internal(WaitHandle[] handles, int ms);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int WaitAny_internal(WaitHandle[] handles, int ms, bool exitContext);
private static extern int WaitAny_internal(WaitHandle[] handles, int ms);
static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{
#if MONOTOUCH
if (exitContext)
throw new NotSupportedException ("exitContext == true is not supported");
#endif
bool release = false;
try {
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.ExitContext ();
#endif
waitableSafeHandle.DangerousAddRef (ref release);
return WaitOne_internal (waitableSafeHandle.DangerousGetHandle (), (int) millisecondsTimeout, exitContext);
return WaitOne_internal (waitableSafeHandle.DangerousGetHandle (), (int) millisecondsTimeout);
} finally {
if (release)
waitableSafeHandle.DangerousRelease ();
#if !DISABLE_REMOTING
if (exitContext)
SynchronizationAttribute.EnterContext ();
#endif
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern int WaitOne_internal(IntPtr handle, int ms, bool exitContext);
static extern int WaitOne_internal(IntPtr handle, int ms);
static int SignalAndWaitOne (SafeWaitHandle waitHandleToSignal,SafeWaitHandle waitHandleToWaitOn, int millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{
@@ -123,7 +121,7 @@ namespace System.Threading
waitHandleToSignal.DangerousAddRef (ref releaseHandleToSignal);
waitHandleToWaitOn.DangerousAddRef (ref releaseHandleToWaitOn);
return SignalAndWait_Internal (waitHandleToSignal.DangerousGetHandle (), waitHandleToWaitOn.DangerousGetHandle (), millisecondsTimeout, exitContext);
return SignalAndWait_Internal (waitHandleToSignal.DangerousGetHandle (), waitHandleToWaitOn.DangerousGetHandle (), millisecondsTimeout);
} finally {
if (releaseHandleToSignal)
waitHandleToSignal.DangerousRelease ();
@@ -133,6 +131,6 @@ namespace System.Threading
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern int SignalAndWait_Internal (IntPtr toSignal, IntPtr toWaitOn, int ms, bool exitContext);
static extern int SignalAndWait_Internal (IntPtr toSignal, IntPtr toWaitOn, int ms);
}
}
+1 -1
View File
@@ -57,7 +57,7 @@ namespace System {
* of icalls, do not require an increment.
*/
#pragma warning disable 169
private const int mono_corlib_version = 145;
private const int mono_corlib_version = 146;
#pragma warning restore 169
[ComVisible (true)]
@@ -656,7 +656,9 @@ namespace MonoTests.System.IO
{
string name = "FIT.MoveTo.SameName.Test";
string path1 = TempFolder + DSC + name;
string path2 = name;
string path2 = TempFolder + DSC + "same";
Directory.CreateDirectory (path2);
path2 += DSC + name;
DeleteFile (path1);
DeleteFile (path2);
@@ -1671,6 +1671,9 @@ namespace MonoTests.System.IO
} catch (FileNotFoundException) {
// Only run this test on platforms where /dev/zero exists
Assert.Ignore();
} catch (DirectoryNotFoundException) {
// Only run this test on platforms where /dev exists
Assert.Ignore();
}
// this shouldn't throw
@@ -304,7 +304,7 @@ namespace MonoTests.System.Threading
});
}
Assert.IsTrue (ce.Wait (1000), "#1");
Assert.IsTrue (ce.Wait (10000), "#1");
}
}
}
@@ -783,6 +783,7 @@ namespace MonoTests.System
Assert.IsTrue (timeZones.Count > 0, "GetSystemTimeZones should not return an empty collection.");
}
#if !MOBILE
[Test]
public void WindowsRegistryTimezoneWithParentheses ()
{
@@ -791,6 +792,7 @@ namespace MonoTests.System
var name = method.Invoke (null, new object [] { " <---> Central Standard Time (Mexico) ||<<>>" });
Assert.AreEqual (name, "Central Standard Time (Mexico)", "#1");
}
#endif
}
[TestFixture]
+13
View File
@@ -0,0 +1,13 @@
// CS0023: The `?' operator cannot be applied to operand of type `T'
// Line: 11
class C2<T>
{
C2<T> i;
T field;
public void Foo ()
{
var x = i?.field;
}
}
+15
View File
@@ -0,0 +1,15 @@
// CS0023: The `?' operator cannot be applied to operand of type `T'
// Line: 13
interface IFoo<T>
{
T Call ();
}
class C1
{
U Foo<T, U> (IFoo<T> t)
{
return t?.Call ();
}
}
+10
View File
@@ -0,0 +1,10 @@
// CS0023: The `?' operator cannot be applied to operand of type `T'
// Line: 8
class X
{
static void Bug<T>(System.Func<T> func)
{
var r = func?.Invoke ();
}
}
-26
View File
@@ -1,26 +0,0 @@
// CS0121: The call is ambiguous between the following methods or properties: `A.GetValues(string[], string)' and `A.GetValues(string, params string[])'
// Line: 23
// CSC BUG: Correct according the spec, no identity conversion to do tie-breaking
class A
{
public int GetValues (string[] s, string value = null)
{
return 1;
}
public int GetValues (string s, params string [] args)
{
return 2;
}
}
class B
{
public static void Main ()
{
var a = new A ();
a.GetValues (null);
}
}
+8 -3
View File
@@ -1263,10 +1263,15 @@ namespace Mono.CSharp
if (conditionalAccess) {
if (!ec.ConditionalAccess.Statement) {
if (ec.ConditionalAccess.Type.IsNullableType)
Nullable.LiftedNull.Create (ec.ConditionalAccess.Type, Location.Null).Emit (ec);
else
var t = ec.ConditionalAccess.Type;
if (t.IsNullableType)
Nullable.LiftedNull.Create (t, Location.Null).Emit (ec);
else {
ec.EmitNull ();
if (t.IsGenericParameter)
ec.Emit (OpCodes.Unbox_Any, t);
}
}
ec.Emit (OpCodes.Br, ec.ConditionalAccess.EndLabel);
+3 -1
View File
@@ -3926,7 +3926,9 @@ array_creation_expression
if ($4 == null)
report.Error (1586, GetLocation ($1), "Array creation must have array size or array initializer");
$$ = new ArrayCreation ((FullNamedExpression) $2, (ComposedTypeSpecifier) $3, (ArrayInitializer) $4, GetLocation ($1));
$$ = new ArrayCreation ((FullNamedExpression) $2, (ComposedTypeSpecifier) $3, (ArrayInitializer) $4, GetLocation ($1)) {
NoEmptyInterpolation = true
};
}
| NEW rank_specifier array_initializer
{
+1 -1
View File
@@ -535,7 +535,7 @@ namespace Mono.CSharp {
void ResolveConditionalAccessReceiver (ResolveContext rc)
{
// LAMESPEC: Not sure why this is explicitly disalloed with very odd error message
// LAMESPEC: Not sure why this is explicitly disallowed with very odd error message
if (!rc.HasSet (ResolveContext.Options.DontSetConditionalAccessReceiver) && method_group.HasConditionalAccess ()) {
Error_OperatorCannotBeApplied (rc, loc, "?", method_group.Type);
}
+20 -12
View File
@@ -469,8 +469,13 @@ namespace Mono.CSharp {
return false;
}
protected static TypeSpec LiftMemberType (ResolveContext rc, TypeSpec type)
protected TypeSpec LiftMemberType (ResolveContext rc, TypeSpec type)
{
var tps = type as TypeParameterSpec;
if (tps != null && !(tps.IsReferenceType || tps.IsValueType)) {
Error_OperatorCannotBeApplied (rc, loc, "?", type);
}
return TypeSpec.IsValueType (type) && !type.IsNullableType ?
Nullable.NullableInfo.MakeType (rc.Module, type) :
type;
@@ -1332,7 +1337,7 @@ namespace Mono.CSharp {
{
}
public ExpressionStatement ResolveStatement (BlockContext ec)
public virtual ExpressionStatement ResolveStatement (BlockContext ec)
{
Expression e = Resolve (ec);
if (e == null)
@@ -4653,7 +4658,9 @@ namespace Mono.CSharp {
AParametersCollection candidate_pd = ((IParametersMember) candidate).Parameters;
AParametersCollection best_pd = ((IParametersMember) best).Parameters;
bool better_at_least_one = false;
int candidate_better_count = 0;
int best_better_count = 0;
bool are_equivalent = true;
int args_count = args == null ? 0 : args.Count;
int j = 0;
@@ -4708,30 +4715,31 @@ namespace Mono.CSharp {
//
// No optional parameters tie breaking rules for delegates overload resolution
//
if ((this.restrictions & Restrictions.CovariantDelegate) != 0)
if ((restrictions & Restrictions.CovariantDelegate) != 0)
return false;
better_at_least_one = false;
++j;
while (j < args_count && !args [j++].IsDefaultArgument) ;
break;
++best_better_count;
continue;
}
// for at least one argument, the conversion to 'ct' should be better than
// the conversion to 'bt'.
if (result != 0)
better_at_least_one = true;
++candidate_better_count;
}
if (better_at_least_one)
if (candidate_better_count != 0 && best_better_count == 0)
return true;
if (best_better_count > 0 && candidate_better_count == 0)
return false;
//
// LAMESPEC: Tie-breaking rules for not equivalent parameter types
//
if (!are_equivalent) {
while (j < args_count && !args [j++].IsDefaultArgument) ;
//
// A candidate with no default parameters is still better when there
// is no better expression conversion
+14 -2
View File
@@ -7023,6 +7023,16 @@ namespace Mono.CSharp
}
}
bool statement_resolve;
public override ExpressionStatement ResolveStatement (BlockContext bc)
{
statement_resolve = true;
var es = base.ResolveStatement (bc);
statement_resolve = false;
return es;
}
protected override Expression DoResolve (ResolveContext rc)
{
ResolveConditionalAccessReceiver (rc);
@@ -7111,7 +7121,7 @@ namespace Mono.CSharp
var method = mg.BestCandidate;
type = mg.BestCandidateReturnType;
if (conditional_access_receiver)
if (conditional_access_receiver && !statement_resolve)
type = LiftMemberType (ec, type);
if (arguments == null && method.DeclaringType.BuiltinType == BuiltinTypeSpec.Type.Object && method.Name == Destructor.MetadataName) {
@@ -7862,6 +7872,8 @@ namespace Mono.CSharp
{
}
public bool NoEmptyInterpolation { get; set; }
public ComposedTypeSpecifier Rank {
get {
return this.rank;
@@ -8398,7 +8410,7 @@ namespace Mono.CSharp
public override void Emit (EmitContext ec)
{
if (EmitOptimizedEmpty (ec))
if (!NoEmptyInterpolation && EmitOptimizedEmpty (ec))
return;
var await_field = EmitToFieldSource (ec);
+36
View File
@@ -0,0 +1,36 @@
class C
{
}
class Foo
{
public int SetValue (string name, string value, string defaultValue = null, bool preserveExistingCase = false)
{
return 1;
}
public int SetValue (string name, C value, C defaultValue = default(C), bool relativeToProject = true, C relativeToPath = default(C), bool mergeToMainGroup = false, string condition = null)
{
return 2;
}
public int SetValue (string name, object value, C defaultValue = null)
{
return 3;
}
}
class Test
{
static int Main()
{
var f = new Foo ();
C b = null;
C c = null;
if (f.SetValue ("a", b, c) != 2)
return 1;
return 0;
}
}
+25
View File
@@ -0,0 +1,25 @@
class A
{
public int GetValues (string[] s, string value = null)
{
return 1;
}
public int GetValues (string s, params string [] args)
{
return 2;
}
}
class B
{
public static int Main ()
{
var a = new A ();
if (a.GetValues (null) != 1)
return 1;
return 0;
}
}
+22
View File
@@ -0,0 +1,22 @@
class X
{
public static int Main ()
{
var a = new byte[] { };
var b = new byte[] { };
if (a.Equals (b))
return 1;
if (ReferenceEquals (a, b))
return 2;
b = new byte[0];
if (a.Equals (b))
return 3;
if (ReferenceEquals (a, b))
return 4;
return 0;
}
}
+55
View File
@@ -0,0 +1,55 @@
using System;
interface IFoo<T>
{
T Call ();
}
class C1
{
public void Foo<T> (IFoo<T> t) where T : class
{
t?.Call ();
var x = t?.Call ();
}
public void Foo2<T> (IFoo<T> t)
{
t?.Call ();
}
}
class C2<T> where T : class
{
C2<T> i;
T field;
public void Foo ()
{
var x = i?.field;
}
}
class Program
{
static void Test<T>(Func<T> func) where T : struct
{
var r = func?.Invoke ();
}
static void Test2<T>(Func<T> func)
{
func?.Invoke ();
}
static void Main()
{
new C1 ().Foo<Program> (null);
new C1 ().Foo2<Program> (null);
new C2<string> ().Foo ();
Test (() => 1);
Test (() => 2);
}
}
+106 -5
View File
@@ -10586,7 +10586,7 @@
</type>
<type name="ExtensibleTester`1[U]">
<method name="Void Direct()" attrs="134">
<size>24</size>
<size>25</size>
</method>
<method name="Void .ctor(U)" attrs="6278">
<size>15</size>
@@ -14348,7 +14348,7 @@
</type>
<type name="TestIssue.Program">
<method name="Int32 Main()" attrs="150">
<size>31</size>
<size>32</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
@@ -14936,7 +14936,7 @@
<size>7</size>
</method>
<method name="Int32 Main()" attrs="150">
<size>36</size>
<size>37</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
@@ -30747,6 +30747,56 @@
</method>
</type>
</test>
<test name="gtest-optional-38.cs">
<type name="C">
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="Foo">
<method name="Int32 SetValue(System.String, System.String, System.String, Boolean)" attrs="134">
<size>10</size>
</method>
<method name="Int32 SetValue(System.String, C, C, Boolean, C, Boolean, System.String)" attrs="134">
<size>10</size>
</method>
<method name="Int32 SetValue(System.String, System.Object, C)" attrs="134">
<size>10</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="Test">
<method name="Int32 Main()" attrs="145">
<size>50</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="gtest-optional-39.cs">
<type name="A">
<method name="Int32 GetValues(System.String[], System.String)" attrs="134">
<size>10</size>
</method>
<method name="Int32 GetValues(System.String, System.String[])" attrs="134">
<size>10</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="B">
<method name="Int32 Main()" attrs="150">
<size>37</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="gtest-partial-01.cs">
<type name="B`1[U]">
<method name="Void .ctor()" attrs="6278">
@@ -43639,7 +43689,7 @@
<test name="test-555.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
<size>360</size>
<size>361</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
@@ -52042,6 +52092,16 @@
</method>
</type>
</test>
<test name="test-934.cs">
<type name="X">
<method name="Int32 Main()" attrs="150">
<size>106</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="test-94.cs">
<type name="Base">
<method name="Int32 IVehicle.Start()" attrs="481">
@@ -68791,7 +68851,7 @@
<size>14</size>
</method>
<method name="Boolean MoveNext()" attrs="486">
<size>167</size>
<size>168</size>
</method>
<method name="Void Dispose()" attrs="486">
<size>15</size>
@@ -69657,6 +69717,47 @@
</method>
</type>
</test>
<test name="test-null-operator-04.cs">
<type name="C1">
<method name="Void Foo[T](IFoo`1[T])" attrs="134">
<size>38</size>
</method>
<method name="Void Foo2[T](IFoo`1[T])" attrs="134">
<size>17</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="C2`1[T]">
<method name="Void Foo()" attrs="134">
<size>33</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="Program">
<method name="Void Test[T](System.Func`1[T])" attrs="145">
<size>31</size>
</method>
<method name="Void Test2[T](System.Func`1[T])" attrs="145">
<size>17</size>
</method>
<method name="Void Main()" attrs="145">
<size>102</size>
</method>
<method name="Int32 &lt;Main&gt;m__0()" attrs="145">
<size>9</size>
</method>
<method name="Int32 &lt;Main&gt;m__1()" attrs="145">
<size>9</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="test-null-operator-05.cs">
<type name="CI">
<method name="Void set_Item(System.String, System.String)" attrs="2182">
@@ -527,6 +527,7 @@ namespace Mono.Linker.Steps {
if (type.HasMethods) {
MarkMethodsIf (type.Methods, IsVirtualAndHasPreservedParent);
MarkMethodsIf (type.Methods, IsStaticConstructorPredicate);
MarkMethodsIf (type.Methods, HasSerializationAttribute);
}
DoAdditionalTypeProcessing (type);
@@ -740,6 +741,25 @@ namespace Mono.Linker.Steps {
return method.IsConstructor && method.IsStatic;
}
static bool HasSerializationAttribute (MethodDefinition method)
{
if (!method.HasCustomAttributes)
return false;
foreach (var ca in method.CustomAttributes) {
var cat = ca.AttributeType;
if (cat.Namespace != "System.Runtime.Serialization")
continue;
switch (cat.Name) {
case "OnDeserializedAttribute":
case "OnDeserializingAttribute":
case "OnSerializedAttribute":
case "OnSerializingAttribute":
return true;
}
}
return false;
}
static bool IsSerializable (TypeDefinition td)
{
return (td.Attributes & TypeAttributes.Serializable) != 0;
@@ -104,7 +104,10 @@
Text="OutDir property must end with a slash."/>
</Target>
<Target Name="PrepareForBuild">
<PropertyGroup>
<PrepareForBuildDependsOn>AssignLinkMetadata</PrepareForBuildDependsOn>
</PropertyGroup>
<Target Name="PrepareForBuild" DependsOnTargets="$(PrepareForBuildDependsOn)">
<Message Importance="High" Text="Configuration: $(Configuration) Platform: $(Platform)"/>
<!-- Look for app.config, if $(AppConfig) is specified, then use that. Else look in
@@ -124,6 +127,18 @@
/>
</Target>
<Target Name="AssignLinkMetadata">
<AssignLinkMetadata Items="@(EmbeddedResource)" Condition="'@(EmbeddedResource)' != '' and '%(EmbeddedResource.DefiningProjectFullPath)' != '$(MSBuildProjectFullPath)'">
<Output TaskParameter="OutputItems" ItemName="_EmbeddedResourceWithLinkAssigned" />
</AssignLinkMetadata>
<ItemGroup>
<EmbeddedResource Remove="@(_EmbeddedResourceWithLinkAssigned)" />
<EmbeddedResource Include="@(_EmbeddedResourceWithLinkAssigned)" />
<_EmbeddedResourceWithLinkAssigned Remove="@(_EmbeddedResourceWithLinkAssigned)" />
</ItemGroup>
</Target>
<PropertyGroup>
<GetFrameworkPathsDependsOn />
</PropertyGroup>
@@ -1,6 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<UsingTask TaskName="Microsoft.Build.Tasks.AL" AssemblyName="Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.Build.Tasks.AssignTargetPath" AssemblyName="Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.Build.Tasks.AssignLinkMetadata" AssemblyName="Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.Build.Tasks.AssignCulture" AssemblyName="Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.Build.Tasks.AssignProjectConfiguration" AssemblyName="Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.Build.Tasks.CallTarget" AssemblyName="Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+1
View File
@@ -0,0 +1 @@
EXTRA_DIST = arm64-codegen.h
+1 -1
View File
@@ -81,7 +81,7 @@
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
#define MONO_CORLIB_VERSION 145
#define MONO_CORLIB_VERSION 146
typedef struct
{
+3 -1
View File
@@ -74,7 +74,7 @@ void
sgen_set_bridge_implementation (const char *name)
{
if (!init_bridge_processor (&bridge_processor, name))
g_warning ("Invalid value for bridge implementation, valid values are: 'new' and 'old'.");
g_warning ("Invalid value for bridge implementation, valid values are: 'new', 'old' and 'tarjan'.");
}
gboolean
@@ -375,6 +375,8 @@ sgen_bridge_processing_finish (int generation)
if (compare_bridge_processors ())
compare_to_bridge_processor.processing_after_callback (generation);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_BRIDGE: Complete, was running for %.2fms", mono_time_since_last_stw () / 10000.0f);
bridge_processing_in_progress = FALSE;
}
+2
View File
@@ -727,6 +727,8 @@ extern MonoNativeTlsKey thread_info_key;
#define SGEN_TV_GETTIME(tv) tv = mono_100ns_ticks ()
#define SGEN_TV_ELAPSED(start,end) ((gint64)(end-start))
guint64 mono_time_since_last_stw (void);
typedef MonoSemType SgenSemaphore;
#define SGEN_SEMAPHORE_INIT(sem,initial) mono_os_sem_init ((sem), (initial))
+1 -1
View File
@@ -2726,7 +2726,7 @@ sgen_client_log_timing (GGTimingInfo *info, mword last_major_num_sections, mword
full_timing_buff [0] = '\0';
if (!info->is_overflow)
sprintf (full_timing_buff, "total %.2fms, bridge %.2fms", info->stw_time / 10000.0f, (int)info->bridge_time / 10000.0f);
sprintf (full_timing_buff, "total %.2fms", info->stw_time / 10000.0f);
if (info->generation == GENERATION_OLD)
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s los %dK/%dK",
info->is_overflow ? "_OVERFLOW" : "",
+13 -1
View File
@@ -65,9 +65,11 @@ typedef struct {
/*
* Bridge data for a single managed object
*
* FIXME: Optimizations:
*
* Don't allocate a scrs array for just one source. Most objects have
* Don't allocate a srcs array for just one source. Most objects have
* just one source, so use the srcs pointer itself.
*/
typedef struct _HashEntry {
@@ -80,10 +82,12 @@ typedef struct _HashEntry {
struct _HashEntry *forwarded_to;
} dfs1;
struct {
// Index in sccs array of SCC this object was folded into
int scc_index;
} dfs2;
} v;
// "Source" managed objects pointing at this destination
DynPtrArray srcs;
} HashEntry;
@@ -92,12 +96,19 @@ typedef struct {
double weight;
} HashEntryWithAccounting;
// The graph of managed objects/HashEntries is reduced to a graph of strongly connected components
typedef struct _SCC {
int index;
int api_index;
// How many bridged objects does this SCC hold references to?
int num_bridge_entries;
gboolean flag;
/*
* Index in global sccs array of SCCs holding pointers to this SCC
*
* New and old xrefs are typically mutually exclusive. Only when TEST_NEW_XREFS is
* enabled we do both, and compare the results. This should only be done for
* debugging, obviously.
@@ -110,6 +121,7 @@ typedef struct _SCC {
#endif
} SCC;
// Maps managed objects to corresponding HashEntry stricts
static SgenHashTable hash_table = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_BRIDGE_HASH_TABLE, INTERNAL_MEM_BRIDGE_HASH_TABLE_ENTRY, sizeof (HashEntry), mono_aligned_addr_hash, NULL);
static guint32 current_time;
+11 -2
View File
@@ -41,11 +41,12 @@ typedef struct {
DynArray array;
} DynSCCArray;
/*
* Bridge data for a single managed object
*
* FIXME: Optimizations:
*
* Don't allocate a scrs array for just one source. Most objects have
* Don't allocate a srcs array for just one source. Most objects have
* just one source, so use the srcs pointer itself.
*/
typedef struct _HashEntry {
@@ -56,8 +57,10 @@ typedef struct _HashEntry {
int finishing_time;
// "Source" managed objects pointing at this destination
DynPtrArray srcs;
// Index in sccs array of SCC this object was folded into
int scc_index;
} HashEntry;
@@ -66,13 +69,19 @@ typedef struct {
double weight;
} HashEntryWithAccounting;
// The graph of managed objects/HashEntries is reduced to a graph of strongly connected components
typedef struct _SCC {
int index;
int api_index;
// How many bridged objects does this SCC hold references to?
int num_bridge_entries;
// Index in global sccs array of SCCs holding pointers to this SCC
DynIntArray xrefs; /* these are incoming, not outgoing */
} SCC;
// Maps managed objects to corresponding HashEntry stricts
static SgenHashTable hash_table = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_OLD_BRIDGE_HASH_TABLE, INTERNAL_MEM_OLD_BRIDGE_HASH_TABLE_ENTRY, sizeof (HashEntry), mono_aligned_addr_hash, NULL);
static int current_time;
+14 -6
View File
@@ -32,6 +32,18 @@
static void sgen_unified_suspend_restart_world (void);
static void sgen_unified_suspend_stop_world (void);
static TV_DECLARE (end_of_last_stw);
guint64 mono_time_since_last_stw ()
{
if (end_of_last_stw == 0)
return 0;
TV_DECLARE (current_time);
TV_GETTIME (current_time);
return TV_ELAPSED (end_of_last_stw, current_time);
}
unsigned int sgen_global_stop_count = 0;
inline static void*
@@ -241,8 +253,7 @@ sgen_client_restart_world (int generation, GGTimingInfo *timing)
{
TV_DECLARE (end_sw);
TV_DECLARE (start_handshake);
TV_DECLARE (end_bridge);
unsigned long usec, bridge_usec;
unsigned long usec;
/* notify the profiler of the leftovers */
/* FIXME this is the wrong spot at we can STW for non collection reasons. */
@@ -269,6 +280,7 @@ sgen_client_restart_world (int generation, GGTimingInfo *timing)
time_restart_world += TV_ELAPSED (start_handshake, end_sw);
usec = TV_ELAPSED (stop_world_time, end_sw);
max_pause_usec = MAX (usec, max_pause_usec);
end_of_last_stw = end_sw;
SGEN_LOG (2, "restarted (pause time: %d usec, max: %d)", (int)usec, (int)max_pause_usec);
@@ -284,12 +296,8 @@ sgen_client_restart_world (int generation, GGTimingInfo *timing)
*/
release_gc_locks ();
TV_GETTIME (end_bridge);
bridge_usec = TV_ELAPSED (end_sw, end_bridge);
if (timing) {
timing [0].stw_time = usec;
timing [0].bridge_time = bridge_usec;
}
}
-6
View File
@@ -924,11 +924,6 @@ processing_stw_step (void)
#if defined (DUMP_GRAPH)
printf ("-----------------\n");
#endif
/*
* bridge_processing_in_progress must be set with the world
* stopped. If not there would be race conditions.
*/
bridge_processing_in_progress = TRUE;
SGEN_TV_GETTIME (curtime);
@@ -1134,7 +1129,6 @@ processing_after_callback (int generation)
cache_hits = cache_misses = 0;
ignored_objects = 0;
bridge_processing_in_progress = FALSE;
}
static void
+4 -4
View File
@@ -96,10 +96,10 @@ gboolean ves_icall_System_Threading_Events_ResetEvent_internal (HANDLE handle);
void ves_icall_System_Threading_Events_CloseEvent_internal (HANDLE handle);
HANDLE ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error);
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext);
gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext);
gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms, gboolean exitContext);
gint32 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms, gboolean exitContext);
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms);
gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms);
gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms);
gint32 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms);
MonoArray* ves_icall_System_Threading_Thread_ByteArrayToRootDomain (MonoArray *arr);
MonoArray* ves_icall_System_Threading_Thread_ByteArrayToCurrentDomain (MonoArray *arr);
+4 -7
View File
@@ -1600,8 +1600,7 @@ mono_wait_uninterrupted (MonoInternalThread *thread, gboolean multiple, guint32
return ret;
}
/* FIXME: exitContext isnt documented */
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext)
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms)
{
HANDLE *handles;
guint32 numhandles;
@@ -1638,8 +1637,7 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_ha
return ret == WAIT_FAILED ? 0x7fffffff : ret;
}
/* FIXME: exitContext isnt documented */
gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext)
gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms)
{
HANDLE handles [MAXIMUM_WAIT_OBJECTS];
uintptr_t numhandles;
@@ -1687,8 +1685,7 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_ha
}
}
/* FIXME: exitContext isnt documented */
gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms, gboolean exitContext)
gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms)
{
guint32 ret;
MonoInternalThread *thread = mono_thread_internal_current ();
@@ -1712,7 +1709,7 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gin
}
gint32
ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms, gboolean exitContext)
ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms)
{
guint32 ret;
MonoInternalThread *thread = mono_thread_internal_current ();
-1
View File
@@ -816,7 +816,6 @@ typedef struct {
gboolean is_overflow;
gint64 total_time;
gint64 stw_time;
gint64 bridge_time;
} GGTimingInfo;
void sgen_stop_world (int generation);
+2 -2
View File
@@ -31,7 +31,7 @@
/*HACK, move this to an eventual mono-signal.c*/
#if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
defined(__FreeBSD__) || defined(__OpenBSD__)
#ifdef HAVE_SIGACTION
#if defined(HAVE_SIGACTION) || defined(__APPLE__) // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction
#define MONO_SIGNAL_USE_UCONTEXT_T 1
#endif
#endif
@@ -152,7 +152,7 @@ typedef struct {
#if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__)
#ifdef HAVE_SIGACTION
#if defined(HAVE_SIGACTION) || defined(__APPLE__) // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction
#define MONO_SIGNAL_USE_UCONTEXT_T 1
#endif
+2 -3
View File
@@ -7,12 +7,11 @@ CPPSHARP_REFS = -r:$(CPPSHARP_DIR)/CppSharp.dll \
SRC_ROOT = ../..
MONO_OPTIONS_SRC = $(SRC_ROOT)/mono/mcs/class/Mono.Options/Mono.Options/Options.cs
MONO_OPTIONS_SRC = $(SRC_ROOT)/mcs/class/Mono.Options/Mono.Options/Options.cs
.stamp-clone:
@if [ ! -d $(CPPSHARP_DIR) ]; then \
git clone git@github.com:xamarin/CppSharpBinaries.git $(CPPSHARP_DIR); \
touch $@; \
git clone git://github.com/xamarin/CppSharpBinaries.git $(CPPSHARP_DIR) && touch $@; \
fi
MonoAotOffsetsDumper.exe: .stamp-clone MonoAotOffsetsDumper.cs $(MONO_OPTIONS_SRC)