Compare commits

...
167 Commits
Author SHA1 Message Date
Alexander Köplinger d9001b5ae7 Bump bockbuild to get GTK NSPasteboardType change (#18815)
Backport of https://github.com/mono/mono/pull/18080.

Approved for 2019-08 by @marek-safar in https://github.com/mono/mono/pull/18080#issuecomment-585451815
2020-02-12 23:46:45 +01:00
Alexander Köplinger e69d4b57d7 Bump bockbuild for Pango patch
Fixes bug #1048838, correct SF font not loading in VSMac

Backport of https://github.com/mono/mono/pull/18566
2020-01-28 13:13:48 +01:00
Alexander Köplinger fd9f379d29 [sdks] Use Xcode 11.3 stable version for iOS/Mac SDKs
As requested by the xamarin-macios team.

(cherry picked from commit 7e65a73d4d)
2019-12-18 22:08:19 +01:00
monojenkins e3084ecece [debugger] skip suspend for unattached threads (#18138)
[2019-08] [debugger] skip suspend for unattached threads

When the debugger tries to suspend all the VM threads, it can happen with cooperative-suspend that it tries to suspend a thread that has previously been attached, but then did a "light" detach (that only unsets the domain). With the domain set to `NULL`, looking up a JitInfo for a given `ip` will result into a crash, but it isn't even necessarily needed for the purpose of suspending a thread.

More details: Consider the following:
```
(lldb) c
error: Process is running.  Use 'process interrupt' to pause execution.
Process 12832 stopped
* thread #9, name = 'tid_a31f', queue = 'NSOperationQueue 0x8069b670 (QOS: UTILITY)', stop reason = breakpoint 1.1
    frame #0: 0x00222870 WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical(info=0x81365400, user_data=0xb04dc718) at debugger-agent.c:2716:6
   2713         MonoDomain *domain = (MonoDomain *) mono_thread_info_get_suspend_state (info)->unwind_data [MONO_UNWIND_DATA_DOMAIN];
   2714         if (!domain) {
   2715                 /* not attached */
-> 2716                 ji = NULL;
   2717         } else {
   2718                 ji = mono_jit_info_table_find_internal ( domain, MONO_CONTEXT_GET_IP (&mono_thread_info_get_suspend_state (info)->ctx), TRUE, TRUE);
   2719         }
Target 0: (WatchWCSessionAppWatchOSExtension) stopped.
(lldb) bt
* thread #9, name = 'tid_a31f', queue = 'NSOperationQueue 0x8069b670 (QOS: UTILITY)', stop reason = breakpoint 1.1
  * frame #0: 0x00222870 WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical(info=0x81365400, user_data=0xb04dc718) at debugger-agent.c:2716:6
    frame #1: 0x004e177b WatchWCSessionAppWatchOSExtension`mono_thread_info_safe_suspend_and_run(id=0xb0767000, interrupt_kernel=0, callback=(WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical at debugger-agent.c:2708), user_data=0xb04dc718) at mono-threads.c:1358:19
    frame #2: 0x00222799 WatchWCSessionAppWatchOSExtension`notify_thread(key=0x03994508, value=0x81378c00, user_data=0x00000000) at debugger-agent.c:2747:2
    frame #3: 0x00355bd8 WatchWCSessionAppWatchOSExtension`mono_g_hash_table_foreach(hash=0x8007b4e0, func=(WatchWCSessionAppWatchOSExtension`notify_thread at debugger-agent.c:2733), user_data=0x00000000) at mono-hash.c:310:4
    frame #4: 0x0021e955 WatchWCSessionAppWatchOSExtension`suspend_vm at debugger-agent.c:2844:3
    frame #5: 0x00225ff0 WatchWCSessionAppWatchOSExtension`process_event(event=EVENT_KIND_THREAD_START, arg=0x039945d0, il_offset=0, ctx=0x00000000, events=0x805b28e0, suspend_policy=2) at debugger-agent.c:4012:3
    frame #6: 0x00227c7c WatchWCSessionAppWatchOSExtension`process_profiler_event(event=EVENT_KIND_THREAD_START, arg=0x039945d0) at debugger-agent.c:4072:2
    frame #7: 0x0021b174 WatchWCSessionAppWatchOSExtension`thread_startup(prof=0x00000000, tid=2957889536) at debugger-agent.c:4149:2
    frame #8: 0x0037912d WatchWCSessionAppWatchOSExtension`mono_profiler_raise_thread_started(tid=2957889536) at profiler-events.h:103:1
    frame #9: 0x003d53da WatchWCSessionAppWatchOSExtension`fire_attach_profiler_events(tid=0xb04dd000) at threads.c:1120:2
    frame #10: 0x003d4d83 WatchWCSessionAppWatchOSExtension`mono_thread_attach(domain=0x801750a0) at threads.c:1547:2
    frame #11: 0x003df1a1 WatchWCSessionAppWatchOSExtension`mono_threads_attach_coop_internal(domain=0x801750a0, cookie=0xb04dcc0c, stackdata=0xb04dcba8) at threads.c:6008:3
    frame #12: 0x003df287 WatchWCSessionAppWatchOSExtension`mono_threads_attach_coop(domain=0x00000000, dummy=0xb04dcc0c) at threads.c:6045:9
    frame #13: 0x005034b8 WatchWCSessionAppWatchOSExtension`::xamarin_switch_gchandle(self=0x80762c20, to_weak=false) at runtime.m:1805:2
    frame #14: 0x005065c1 WatchWCSessionAppWatchOSExtension`::xamarin_retain_trampoline(self=0x80762c20, sel="retain") at trampolines.m:693:2
    frame #15: 0x657ea520 libobjc.A.dylib`objc_retain + 64
    frame #16: 0x4b4d9caa WatchConnectivity`__66-[WCSession onqueue_handleDictionaryMessageRequest:withPairingID:]_block_invoke + 279
    frame #17: 0x453c7df7 Foundation`__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #18: 0x453c7cf4 Foundation`-[NSBlockOperation main] + 88
    frame #19: 0x453cacee Foundation`__NSOPERATION_IS_INVOKING_MAIN__ + 27
    frame #20: 0x453c6ebd Foundation`-[NSOperation start] + 835
    frame #21: 0x453cb606 Foundation`__NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 27
    frame #22: 0x453cb12e Foundation`__NSOQSchedule_f + 194
    frame #23: 0x453cb26e Foundation`____addOperations_block_invoke_4 + 20
    frame #24: 0x65de007b libdispatch.dylib`_dispatch_call_block_and_release + 15
    frame #25: 0x65de126f libdispatch.dylib`_dispatch_client_callout + 14
    frame #26: 0x65de3788 libdispatch.dylib`_dispatch_continuation_pop + 421
    frame #27: 0x65de2ee3 libdispatch.dylib`_dispatch_async_redirect_invoke + 818
    frame #28: 0x65df087d libdispatch.dylib`_dispatch_root_queue_drain + 354
    frame #29: 0x65df0ff3 libdispatch.dylib`_dispatch_worker_thread2 + 109
    frame #30: 0x66024fa0 libsystem_pthread.dylib`_pthread_wqthread + 208
    frame #31: 0x66024e44 libsystem_pthread.dylib`start_wqthread + 36
```

Going further, `info` is about this thread:
```
(lldb) p/x *(int *)(((char *) info->node.key) + 0xa0)
(int) $2 = 0x01243f93
(lldb) thread list
Process 12832 stopped
  thread #1: tid = 0x1243ee1, 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10, name = 'tid_303', queue = 'com.apple.main-thread'
  thread #2: tid = 0x1243ee6, 0x65f816e2 libsystem_kernel.dylib`__recvfrom + 10
  thread #3: tid = 0x1243ee7, 0x65f81aea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #4: tid = 0x1243ee9, 0x65f7e3d2 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
  thread #5: tid = 0x1243eea, 0x65f816e2 libsystem_kernel.dylib`__recvfrom + 10, name = 'Debugger agent'
  thread #6: tid = 0x1243f1d, 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10, name = 'com.apple.uikit.eventfetch-thread'
  thread #8: tid = 0x1243f93, 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10, name = 'tid_6d0f', queue = 'NSOperationQueue 0x8069b300 (QOS: UTILITY)'
* thread #9: tid = 0x12443a9, 0x00222870 WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical(info=0x81365400, user_data=0xb04dc718) at debugger-agent.c:2716:6, name = 'tid_a31f', queue = 'NSOperationQueue 0x8069b670 (QOS: UTILITY)', stop reason = breakpoint 1.1
  thread #10: tid = 0x1244581, 0x65f7fd32 libsystem_kernel.dylib`__workq_kernreturn + 10
(lldb) thread select 8
* thread #8, name = 'tid_6d0f', queue = 'NSOperationQueue 0x8069b300 (QOS: UTILITY)'
    frame #0: 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10
libsystem_kernel.dylib`mach_msg_trap:
->  0x65f7e396 <+10>: retl
    0x65f7e397 <+11>: nop

libsystem_kernel.dylib`mach_msg_overwrite_trap:
    0x65f7e398 <+0>:  movl   $0xffffffe0, %eax         ; imm = 0xFFFFFFE0
    0x65f7e39d <+5>:  calll  0x65f85f44                ; _sysenter_trap
(lldb) bt
* thread #8, name = 'tid_6d0f', queue = 'NSOperationQueue 0x8069b300 (QOS: UTILITY)'
  * frame #0: 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x65f7e8ff libsystem_kernel.dylib`mach_msg + 47
    frame #2: 0x66079679 libxpc.dylib`_xpc_send_serializer + 104
    frame #3: 0x660794da libxpc.dylib`_xpc_pipe_simpleroutine + 80
    frame #4: 0x66079852 libxpc.dylib`xpc_pipe_simpleroutine + 43
    frame #5: 0x66043a8f libsystem_trace.dylib`___os_activity_stream_reflect_block_invoke_2 + 30
    frame #6: 0x65de126f libdispatch.dylib`_dispatch_client_callout + 14
    frame #7: 0x65de3d71 libdispatch.dylib`_dispatch_block_invoke_direct + 257
    frame #8: 0x65de3c62 libdispatch.dylib`dispatch_block_perform + 112
    frame #9: 0x6604349a libsystem_trace.dylib`_os_activity_stream_reflect + 725
    frame #10: 0x6604ef19 libsystem_trace.dylib`_os_log_impl_stream + 468
    frame #11: 0x6604e44d libsystem_trace.dylib`_os_log_impl_flatten_and_send + 6410
    frame #12: 0x6604cb3b libsystem_trace.dylib`_os_log + 137
    frame #13: 0x6604f4aa libsystem_trace.dylib`_os_log_impl + 31
    frame #14: 0x4b4eb4e9 WatchConnectivity`WCSerializePayloadDictionary + 393
    frame #15: 0x4b4d7c4d WatchConnectivity`-[WCSession onqueue_sendResponseDictionary:identifier:] + 195
    frame #16: 0x4b4da435 WatchConnectivity`__66-[WCSession onqueue_handleDictionaryMessageRequest:withPairingID:]_block_invoke.411 + 35
    frame #17: 0x453c7df7 Foundation`__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #18: 0x453c7cf4 Foundation`-[NSBlockOperation main] + 88
    frame #19: 0x453cacee Foundation`__NSOPERATION_IS_INVOKING_MAIN__ + 27
    frame #20: 0x453c6ebd Foundation`-[NSOperation start] + 835
    frame #21: 0x453cb606 Foundation`__NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 27
    frame #22: 0x453cb12e Foundation`__NSOQSchedule_f + 194
    frame #23: 0x453cb067 Foundation`____addOperations_block_invoke_2 + 20
    frame #24: 0x65dedf49 libdispatch.dylib`_dispatch_block_async_invoke2 + 77
    frame #25: 0x65de4461 libdispatch.dylib`_dispatch_block_async_invoke_and_release + 17
    frame #26: 0x65de126f libdispatch.dylib`_dispatch_client_callout + 14
    frame #27: 0x65de3788 libdispatch.dylib`_dispatch_continuation_pop + 421
    frame #28: 0x65de2ee3 libdispatch.dylib`_dispatch_async_redirect_invoke + 818
    frame #29: 0x65df087d libdispatch.dylib`_dispatch_root_queue_drain + 354
    frame #30: 0x65df0ff3 libdispatch.dylib`_dispatch_worker_thread2 + 109
    frame #31: 0x66024fa0 libsystem_pthread.dylib`_pthread_wqthread + 208
    frame #32: 0x66024e44 libsystem_pthread.dylib`start_wqthread + 36
```
which is a thread in a "light" detach state (aka. coop detach), where we only unset the domain:
https://github.com/mono/mono/blob/4cefdcb7ce2d939ee78fb45d1b4913eb3bc064fd/mono/metadata/threads.c#L6084-L6111

Fixes https://github.com/mono/mono/issues/17926



<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->


Backport of #18105.

/cc @lewurm
2019-12-12 19:06:03 +01:00
monojenkins da5b1c675d [2019-08] Enable GSS on android (#18116)
Backport of #17838.
2019-12-11 14:04:12 +01:00
monojenkins bef1e63358 [interp] track valuetype stack for CEE_RET too (#17998)
Backport of #17968

Fixes https://github.com/mono/mono/issues/17924
2019-12-03 10:47:01 -05:00
Bernhard Urban-Forster 56325f4097 [arm] if mtriple is provided, do not set -march
E.g. when passing `-march=arm -mtriple=armv7s-ios`, `-march` will win and thus ignore `armv7s`.

Fixes https://github.com/mono/mono/issues/17931

* Caused by 5e318afd2e
* Related with 4cd5068230
* Almost fixed by e431093f73

Hopefully we are done with it.
2019-12-02 17:24:04 +01:00
monojenkins c4a1b40fbd [2019-08] [runtime] Treat calling a non-virtual method through… (#17961)
* [runtime] Treat calling a non-virtual method through an open delegate the same as the normal case instead of the OPEN_VIRTUAL case.

* [amd64] Fix the return value mapping in gsharedvt calls, the return address might be in different registers in the caller and callee.

* [runtime] Always initialize del->method_ptr even if interp_method is set, JITted code makes calls through it in mixed mode.

* Add a test for open delegates and gsharedvt.

* Increase nrgctx trampoline count, its needed by dynamic-method-churn.exe in full-aot-interp mode.
2019-12-02 17:20:35 +01:00
Ankit Jain 0c9250280d [2019-08] bump msbuild+roslyn to track mono-2019-08 (#17954)
* Bump msbuild to track mono-2019-08

* Bump roslyn to 3.4.0-beta4-19569-03

.. to match version from `dotnet/toolset` `releaes/3.1.1xx`: https://github.com/dotnet/toolset/blob/597688dfa01a77b8f502bfea9d79feecfc63e33d/eng/Versions.props#L36

* Bump nuget.exe to 5.4.0
2019-11-29 11:20:11 +01:00
Ankit Jain 14aac0c541 Bump msbuild to track mono-2019-08 (#17854) 2019-11-25 10:29:09 -06:00
monojenkins a77128ca79 [merp] Remove extraneous waitpid invocation (#17762)
The extraneous call basically guarantees that the following waitpid invocation will fail. Fixes merp stating that its process has failed when it hasn't.
2019-11-14 12:17:44 +01:00
monojenkins 296a9afdb2 [MacSDK] Bump xamarin-gtk-theme.py to latest revision from private bockbuild (#17786)
This adds some accessibility fixes from https://github.com/mono/xamarin-gtk-theme/pull/35

Backport of #17785.
2019-11-14 09:26:22 +01:00
Larry Ewing e59c3fbb68 Bump msbuild packages to 1e1d0f2caad3731357cca18b298536e514f5519b (#17724)
Pull in dotnet/toolset versions

```
Microsoft.NET.Sdk: 3.1.100-preview3.19553.1 (from 3.1.100-preview2.19528.2)
Microsoft.NET.Sdk.Razor: 3.1.0-preview3.19553.1 (from 3.1.0-preview2.19528.1)
Microsoft.NET.Sdk.Web: 3.1.100-preview3.19554.3 (from 3.1.100-preview2.19529.1)
Microsoft.DotNet.Cli.Runtime: 3.1.100-preview3.19554.3 (from 3.1.100-preview2.19529.1)
```
2019-11-06 11:06:29 +01:00
Alexander Köplinger 062f0ab8ca [sdks] Use Xcode 11.2 stable version for iOS/Mac SDKs
As requested by the xamarin-macios team.
2019-11-04 15:25:39 +01:00
monojenkins e1ef774391 [2019-08] Bump CoreFX to pickup corefx PR #367 to fix #17133. (#17622)
Bump CoreFX to pickup mono/corefx#367 to fix #17133.

Backport of #17590.
2019-11-01 14:20:37 -04:00
Ankit Jain 6d1f88e0ad Bump msbuild to get SDK updates from https://github.com/mono/msbuild/pull/150 2019-11-01 11:22:36 -05:00
Larry Ewing a3f3bfc4c3 Bump nuget to the latest suggested version 2019-11-01 11:22:36 -05:00
Larry Ewing 9bd3079f1c [2019-08] bump msbuild with more p2 packages 2019-11-01 11:22:36 -05:00
Thays Grazia 6ac1ff75a2 [dim][regression] Explicit interface override (#17583) (#17627)
* Precedence order:
-> Override interface method in class
-> Method in class
-> DIM
2019-10-30 21:41:45 -03:00
Alexander Köplinger a119807a01 [acceptance-tests] Bump mono/roslyn to get build fix
See https://github.com/mono/roslyn/commit/6bfcd4e770609a38b8523e83ce1ec943162f30bb

(cherry picked from commit 1340095581)
2019-10-29 21:44:45 +01:00
Aleksey Kliger d234d34b70 [2019-08][merp] Install sigterm handler in EnableMicrosoftTelemetry
Partly revert https://github.com/mono/mono/pull/17296 backports.

Follow-up work for backports of https://github.com/mono/mono/pull/17537 backports.

Addresses https://github.com/mono/mono/issues/17419
2019-10-28 14:31:34 -04:00
monojenkins 444a9a3fc4 [2019-08] [merp] Introduce a new 'dump mode' that allows different signal behavior when dumping (#17568)
* [merp] Introduce a new 'dump mode' that allows different signal behavior when dumping

The primary reason for this is gaining the ability to interpret SIGTERM properly as a crashing signal when outside of 'dump mode', and as a utility signal during the 'thread summarizer' dumping process.
2019-10-26 18:49:25 -04:00
Steve Pfister 8946e49a97 Added SR.missing from original backport 2019-10-24 21:31:39 -05:00
Steve Pfister 5c784c9747 Bump to mono/corefx@fb41040
Includes upstream corefx changes that makes NTLM auth work for more scenarios.

Backport of https://github.com/mono/mono/pull/17530
2019-10-24 21:31:39 -05:00
Larry Ewing fdb704901e Revert "[2019-08] rollback msbuild/roslyn updates for a preview" (#17543)
This reverts commit 1b2e536b22.
now that packages have been built.
2019-10-24 17:40:31 -04:00
monojenkins 92a177923c [2019-08] [debugger] Changing how debugger handles exception w… (#17524)
* Removing all fixes to fix #15203 and #17083, and trying a new approach to fix this #17084, together.

The thing is when we are executing on hybrid suspend the caller is executed inside try catch in the runtime_invoke_ method that is generated. And this try catch should be ignored for the debugger exception, otherwise it's the last try catch in main thread, but should always be considered to generate the stack trace.

Fixes #17084

* This test check the case that we were missing. On preemptive this test always runs perfectly, on Hybrid, never run well until this PR.

* Changing how call unit test. Changing variable name.
2019-10-24 11:54:14 -04:00
Larry Ewing 1b2e536b22 [2019-08] rollback msbuild/roslyn updates for a preview 2019-10-23 16:22:43 -04:00
Ankit Jain ec4ef9bc34 Bump roslyn-binaries to get roslyn 3.4.0-beta3-19521-01
.. from https://github.com/mono/roslyn-binaries/pull/20 .
2019-10-23 11:46:23 -05:00
Ankit Jain cc8deca901 Bump msbuild to pick up sdks+roslyn updates
.. from https://github.com/mono/msbuild/pull/147 .
2019-10-23 11:46:23 -05:00
Ankit Jain 335f0109c5 Bump msbuild to track mono-2019-08 2019-10-23 11:46:23 -05:00
Zoltan Varga 90d6e496e4 Fix checks so stack overflows work again. 2019-10-23 11:38:40 -05:00
Zoltan Varga 4b60e7f930 [jit] Avoid running mono_handle_native_crash () on the altstack, it can't produce a backtrace. AMD64 only for now. 2019-10-23 11:38:40 -05:00
Marius Ungureanu 989333d6ae Bump Bockbuild to pick-up gtk# binding change (#17486)
Fixes https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1005448
Which causes quite a few broken clipboard bugs and possible memory corruption
2019-10-23 14:32:30 +02:00
monojenkins baa12e5d24 [profiler] Fix coverage profiler on macos (#17422)
If we have coverage profiling enabled for a method (mono_profiler_coverage_instrumentation_enabled, with coverage_filter callback), then we should be able to allocate a coverage info structure (mono_profiler_coverage_alloc). After https://github.com/mono/mono/commit/52429673dc617fd437518757c04c7448211075e9, coverage_filter was reporting wrapper methods as ok to profile, while mono_profiler_coverage_alloc was refusing to allocate the necessary structure, leading to crashes.
2019-10-22 13:24:39 +03:00
monojenkins ef75d4bef7 [2019-08] BeginConnect complete to early when not using callback. (#17416)
* BeginConnect complete to early when not using callback.

The following commit, https://github.com/mono/mono/commit/068e8fe0424806753d7ab72a7b9bf0e54b58408b#diff-33b28a9dc0b8032650ed77213481a99f
changed the way we do DNS resolve in BeginConnect using host name. Instead
of doing a blocking DNS resolve, it switched to an async DNS resolve, followed
by an async connect. The returned IAsyncResult was just representing the
completion of the DNS resolve task and not the underlying connect. It
also turns out that part of doing EndConnect, we did some validation
of the used IAsyncResult making sure it was an instance of SocketAsyncResult,
meaning that if EndConnect was called on the returned IAsyncResult from
BeginConnect, EndConnect would throw and exception.

NOTE, this only happens if you use pattern like this:

var result = sock.BeginConnect (hostName, port, null, null);
result.AsyncWaitHandle.WaitOne (2000);
sock.EndConnect (result);

It did not happened if you used callbacks, since then EndConnect would
be called as part of callback and that IAsyncResult was of correct type,
or if you did a BeginConnect with an EndPoint or IPAddress[] since that
won't trigger the DNS resolve.

Fix is to make sure we hand out the SocketAsyncResult instance that will
be used in our internal connect calls from BeginConnect. We also make
sure, we chain the DNS resolve task together with a task doing the async
connect (using the same SocketAsyncResult instance). This will make sure
the IAsyncResult returned from BeginConnect is the same one as used in
internal connect call, so it will only complete when the connect call
completes.

* Adding test for BeginConnect using host name.

* Bump API snapshot submodule

Backport of #17035.
2019-10-21 17:48:30 +02:00
monojenkins 01dbbb746f [2019-08] Enable GSS on Linux (#17410)
* Fix GSS on Linux

* fix build

* use gssapi_krb5

* enable on linux

* [csproj] Update project files

* enabled GSS for monodroid

* [csproj] Update project files
2019-10-18 11:34:18 +02:00
Filip Navara 51a3dc37da Fix SafeHandle marshalling in ref/in/out parameters (#17330)
* Fix SafeHandle marshalling in ref/in/out parameters

* Reorder code to make it exception safe, update comments

* Revert the code reordering because it breaks the invariant that new handle returned from native code should always create new SafeHandle on the managed side

* Fix test_0_safehandle_ref test. The test was expecting incorrect behavior, verified on .NET Core 3 and .NET Framework 4.8.

* Address PR feedback

* Fix cut & paste error

* Fix build

* Really fix the test_0_safehandle_ref tests

* Add more tests for SafeHandle marshalling

* Add exclusion for broken CoreFX test
2019-10-17 14:12:31 +02:00
Cody Russell 3eb5f34f54 [GTK] Bump bockbuild for GtkViewport autoscrolling patch. (#17321)
(cherry picked from commit 37dc33a257)
2019-10-16 17:03:54 +02:00
Kyle White b601371d5f Update MERP event type to MonoAppCrash
* Update parameters in MERP WerReportMetadata xml

To enable backend analysis, we need to update our parameters to match our back end event type, which is MonoAppCrash.

It doesn't make sense to me that the previous implementation constructed the XML here in Mono, but depended on the user (VSMac in this case) to add the "correct" event type.  The parameters in the XML, must match exactly what is expected for the given EventType, and so we should ensure they are always in-sync by defining them here.  Thus, I removed the usage of `eventType` in `mono_merp_enable` and hard coded the expected eventType.

* [merp] Don't pass eventType from managed

The eventType must me MONO_MERP_EVENT_TYPE_STR ("MonoAppCrash") - the backend
determines the format of the other fields based on the event type, so it
doesn't make sense to pass other values from managed since the runtime controls
the other fields.

For compatability Mono.Runtime.EnableMicrosoftTelemetry will still take a
string parameter (now called "unused" instead of "eventType_str") but it will
not pass it down to the internal call.

* Bump corlib version

* [merp] Revert paramerters in WerReportMetadata.xml

Still need event type to be `MonoAppCrash` but the parameters will be the same as before.
2019-10-15 19:10:14 +02:00
Alexander Köplinger 6184ff007b [2019-08][ci] Use Xcode11.1 and 11.2beta2 for XI/XM Mono SDK builds (#17324)
As requested by the xamarin-macios team.
2019-10-15 11:44:41 +02:00
monojenkins 8969f2cc99 [2019-08] [merp] Include any managed methods in the 'unmanaged_frames' portion … (#17316)
* [merp] Include any managed methods in the 'unmanaged_frames' portion of the output also

This can help correlate the two lists when we have mixed managed & unmanaged stacks in our crash output.

* Wehn symbol/function address is not found, still output the IaP

* Don't set native_offset to ip, that's not what it means

* [merp] Bump protocol version

* Minor formatting fix


* Remove unused var

* Refactor filling in managed info for stack frame
2019-10-14 17:12:39 -04:00
monojenkins 3009440108 [2019-08][merp] Don't install SIGTERM handler in EnableMicrosoftTelemetry (#17308)
* [merp] Don't call install_state_summarizer in EnableMicrosoftTelemetry

install_state_summarizer installs a SIGTERM handler. Unfortunately
sigterm_signal_handler assumes that it will only be called when a crash is
already in progress (it assumes it won't be the supervisor, and so it doesn't
setup the memory for capturing a crash report among other things).

* [merp] Register SIGTERM handler in dump_native_stacktrace

Previously it was installed by EnableMicrosoftTelemetry, which is too early.
Now we get here without a handler installed even when mono_merp_enabled returns true.
2019-10-14 20:54:05 +02:00
Alexander Köplinger df5e13f95d [tests] Bump corefx to get Azure testhost change (#17275)
* Bump corefx to get Azure testhost change

See https://github.com/mono/corefx/pull/360

* Update ClientWebSocketTest as well

(cherry picked from commit d457346e06)
2019-10-11 09:39:00 +02:00
monojenkins 11e1499c22 [2019-08] [merp] Print missing status marker file for stage 1 (setup) (#17220)
* [merp] Print missing status marker file for stage 1 (setup)

* Zeroing is not necessary, snprintf() always null-terminates in this case

* Remove unused variable
2019-10-10 23:34:08 -04:00
Vlad Brezae 7dbad3c361 [arm] Fix fetching of method addresses (#17253)
[2019-08][arm] Fix fetching of method addresses

After https://github.com/mono/mono/commit/9ff3b0d65ee4, in an aot image we can emit addresses either as bl offset (which uses 4 bytes) or as ldr pc, =<label>; <addr> (which uses 8 bytes). Before this commit we were dereferencing an instruction pointer, in get_call_table_entry, assuming 8 bytes per entry. This could overflow and crash if we used in fact only 4 bytes per entry. Fix this by including the entry size in the aot image.

Fixes random crashes on arm CI on full-aotmixed suite.

Backport of https://github.com/mono/mono/pull/17099
2019-10-09 21:45:56 +02:00
monojenkins 9a88a36789 [sgen] Fix invalid value passed to write barrier (#17247)
[2019-08] [sgen] Fix invalid value passed to write barrier

When doing memory copy dest is the destination address and src is the source address. If we are copying a single reference, we need to emit a write barrier and pass to the write barrier the value, not the pointer where the value is stored. Otherwise nursery checks will fail and we won't mark the card table.

Backport of #17236.

/cc @marek-safar @BrzVlad
2019-10-09 15:46:05 +02:00
Alexander Köplinger 0f241c975c [2019-08] Add drawing type converters to mobile profiles (#17240)
* [2019-08] Add drawing type converters to mobile profiles

Needed for https://github.com/xamarin/xamarin-android/issues/3726

* Bump API snapshot submodule

* [csproj] Update project files
2019-10-09 12:16:40 +02:00
Ankit Jain 7ebe1a1763 Update Roslyn to 3.4.0-beta2-19477-01
.. to match roslyn-binaries PR: https://github.com/mono/roslyn-binaries/pull/19
2019-10-08 12:06:41 -05:00
Ankit Jain b759449ba8 Bump msbuild to track mono-2019-08
.. which updates SDKs and roslyn (match what mono has) in
https://github.com/mono/msbuild/pull/144 :

```
Microsoft.NET.Sdk:                      3.1.100-preview1.19506.1
Microsoft.NET.Sdk.Web:                  3.1.100-preview1.19506.3
Microsoft.NET.Sdk.Razor:                3.1.0-preview1.19506.2

Microsoft.NETCore.App:                  3.1.0-preview1.19506.1
Microsoft.DotNet.Cli.Runtime:           3.1.100-preview1.19506.9

NuGet.Build.Tasks:                      5.3.0-rtm.6251

Roslyn:                                 3.4.0-beta2-19477-01
Based on dotnet/toolset release/3.1.1xx branch HEAD
(e9c6794f1f124e273571237eb72a949ee5c950c6):

https://github.com/dotnet/toolset/blob/e9c6794f1f124e273571237eb72a949ee5c950c6/eng/Versions.props#L36
```
2019-10-08 12:06:41 -05:00
monojenkins 617f399efc [IO] Remove read-only logic in mono_w32_get_disk_free_space (#17211)
[2019-08] [IO] Remove read-only logic in mono_w32_get_disk_free_space

Fixes #17151

This brings us in line with GetDiskFreeSpaceExW on Windows as well as .NET Core.

I checked with the Android folks and it seems like this won't fail their test - all they check is that the returned value isn't `long.MaxValue`.

Backport of #17177.

/cc @akoeplinger @CoffeeFlux
2019-10-08 02:15:58 +02:00
monojenkins 77258ea112 [2019-08] [debugger][exception] Debugger breaks on handled exceptions (#17202)
* If there is a perform_wait_callback in the stack there will be another catch generated by the owner thread, so we don't need to throw, we can continue and find the next catch. Fixes #17083

* Reverting unit test changed on commit 405d521.

* Fixing assert when calling mono_jit_info_get_method if it was a trampoline.
2019-10-07 17:10:58 -04:00
Ankit Jain f83c321f88 Bump msbuild to track mono-2019-08 (#17193)
.. to track https://github.com/mono/msbuild/pull/143 .
	`Update SDKs to track vs16.4 and `.NET Core 3.1 Dev``
2019-10-07 16:10:44 +02:00
monojenkins 1ecd094b44 [2019-08] [Mono.Debugger.Soft] Fix VirtualMachine detaching (#17077)
* Revert "[Mono.Debugger.Soft] Properly close connections"

This reverts commit 2da7707373.

This was previously reverted because it was causing issues and it still does. It is a hack fix. We signal the connection for closing and next we send the dispose command over the network. This is obviously racy.

* [Mono.Debugger.Soft] Make sure receiving thread always closes

When we want to close the connection, setting the close flag is not enough, because a thread can be already stuck in a blocking receive, without getting to check the flag. We fix this by additionaly breaking the connection, by using socket.Shutdown.

Fixes https://github.com/mono/mono/issues/7377

* Bump API snapshot submodule
2019-10-06 09:57:37 +03:00
monojenkins 54a33be9de [merp] Put thread into async context before running summarizer (#17197)
[2019-08] [merp] Put thread into async context before running summarizer

Followup work for https://github.com/mono/mono/pull/17090

In order to get managed method info for unmanaged stacktraces, we call
`mini_jit_info_table_find_ext` which calls `decode_exception_debug_info` which may
allocate if it's not in async context.

Do the switch in `mono_threads_summarize_execute` so that non-supervising threads
all switch when they run the `sigterm_signal_handler`.  `mono_threads_summarize`
already does it for the supervisor thread.

Fixes https://github.com/mono/mono/issues/17180



Backport of #17194.

/cc @lambdageek
2019-10-05 21:05:59 +02:00
Alexander Köplinger 72128bb00d Bump libgdiplus to 6.0.4
(cherry picked from commit 0600ea1256)
2019-10-05 17:46:04 +02:00
Johan Lorensson 65a972c033 Always do copy_stack_data on entering GC safe/unsafe mode. (#17184) 2019-10-05 10:01:40 -04:00
monojenkins 9e6def1553 [merp] exit_status is 0 if we ran the uploader successfully (#17187)
Not 1 (TRUE)
2019-10-04 17:22:59 -04:00
monojenkins 8a707cc012 [2019-08] [reflection] Only duplicate MonoMarshalSpec strings for custom types (#17189)
[2019-08] [reflection] Only duplicate MonoMarshalSpec strings for custom types

Fixes #16570

We were treating the union as though it was a different type than it really is, and so we got junk data for the pointers and attempting to access them caused a crash.

Also fixed a typo seen along the way.

Backport of #17175.

/cc @lambdageek @CoffeeFlux
2019-10-04 22:46:03 +02:00
monojenkins bd72952cf8 [2019-08] [merp] Don't overrun buffer in copy_summary_string_safe … (#17178)
* [merp] Don't overrun buffer in copy_summary_string_safe

MonoFrameSummary:str_destr is an array of MONO_MAX_SUMMARY_NAME_LEN bytes, not
MONO_MAX_SUMMARY_NAME_LEN + 1 bytes.

Fixes Coverity CID 1454563

* [merp] Use g_strlcpy for copy_summary_string_safe

Fixes Coverity CID 1454563

We would sometimes write to MonoSummaryFrame:str_descr which is
MONO_MAX_SUMMARY_NAME_LEN bytes long at index MONO_MAX_SUMMARY_NAME_LEN which
is one past the end of the array.

* nit: rename confusing parameter names

old names were confusing - we were copying from 'out' to 'in'.  Now we copy to
'dest' from 'src'
2019-10-04 01:20:33 -04:00
Ankit Jain b6efc0cc90 Bump msbuild to track xplat-master (#17132)
.. which is tracking dotnet branch `release/3.1.1xx`.
2019-10-03 23:47:01 +02:00
monojenkins 2869cd5f67 Bump ikvm to get https://github.com/mono/ikvm-fork/pull/13 (#17170) 2019-10-03 20:46:55 +02:00
monojenkins a64a25695d [2019-08] [merp] Use macOS version not Darwin version in MERP reports (#17147)
* Use macOS version not Darwin version in MERP

Fixes #17004

* Update mono-merp.c

Ensure this is only for Mac

* Don't allocate in macos_version_string

Use a static buffer.

Also some formatting fixes.

* Simplify error path code when getting the product version


* Add G_STRING_CONSTANT_AND_LENGTH macro

Cherrypicked from
https://github.com/mono/mono/commit/8c288f06664c65050b153da0a8952209adc958a0
2019-10-03 10:44:50 -04:00
Alexis Christoforides 57f068438d [2019-08] [merp] Add API method that whitelists all native libraries (#17128)
Backport of #16899 and #15622

* [merp] Add API method that whitelists all native libraries

This is so that complex consumers such as Visual Studio for Mac can forego attempting to enumerate all loaded libraries, register them one at a time and potentially keep the list updated

* Set out_module, to avoid getting no useful information in the printout

It seems that without this, most/all entries in the unmanaged frames list are have no useful information.

* Add stub of new function when crash reporting is disabled

* Remove problematic assert from SIGILL handler

mono_handle_native_crash() function can actually return if the native crash has triggered or has been trigerred by  more than one signal. So it is possible to reach the point of the assert

* Guard writing to out_module

* Fix pointing to stack on string && some add tracing

* [merp] Fix logic of 'is_managed' attribute

* [merp] Output native library module name when 'whitelist all' mode is enabled (#16899)

Contributes to  https://github.com/mono/mono/issues/16689

* Bump MONO_CORLIB_VERSION
2019-10-01 22:08:28 -04:00
Alexander Köplinger 528103728f [2019-08] Update NETStandard2.1 APIs (#17123)
* Update NETStandard2.1 APIs (#17080)

Contributes to #17064

* Add System.Data.DataSetExtensions to mobile profiles

* Bump API snapshot submodule
2019-09-30 22:59:41 +02:00
monojenkins d8441deead [crashing] Remove Mono signal handlers when starting to handle a crash (#17078)
[2019-08] [crashing] Remove Mono signal handlers when starting to handle a crash

Fixes https://github.com/mono/mono/issues/16803

Backport of #17002.

/cc @marek-safar @alexischr
2019-09-27 01:36:00 +02:00
monojenkins 7ae0f38fd7 [runtime] Respect runtime_version in mono_init_internal (#17086)
[2019-08] [runtime] Respect runtime_version in mono_init_internal

In 6d2c77fb33 we changed the representation of
the runtimes that we will probe from a NULL-terminated array to a linked list.
Unfortunately we made a typo, and in the case where the caller of
`mono_init_internal` provided a runtime_version, we still picked
`DEFAULT_RUNTIME_VERSION` instead of the given `runtime_version`.

This is an issue for embedders like XA that use the "mobile" runtime - all
their BCL assemblies are compiled with the "mobile" version number (2.0.5.0) but
Mono running with the default runtime configuration will remap to 4.0.0.0.  As
a result, when there are references to 2.0.5.0 assemblies, the load requests
will be remapped to 4.0.0.0 which will never see the already loaded 2.0.5.0
assemblies, and we will fall back on the embedder's preload hook or filesystem
probing every single time.  This is a performance fail.




Backport of #17085.

/cc @lambdageek
2019-09-26 21:36:12 +02:00
Rolf Bjarne Kvinge 61ca7fe3a4 [sdks] Bump min iOS version to 7.0. (#17070)
Because that's the min iOS version in all current versions of Xamarin.iOS.
2019-09-26 14:14:22 +02:00
Steve Pfister c99adb97ed [2019-08] Fix time zone issue when jumping into DST (#17027)
There is an issue with jumping into DST for some time zones when the incorrect date-time offset is returned for date-time in UTC (which comes from DateTime.Now). The fix is to just check if the incoming date-time is in UTC
Also I added set of tests for some time zones but they verify jumping into DST in general.

Fixes #16395

Backport of https://github.com/mono/mono/pull/16430
2019-09-25 17:03:13 +02:00
Alexander Köplinger 6a8aced231 [2019-08] Bump bockbuild to get recent fixes (#17058)
- https://github.com/mono/bockbuild/pull/121
- https://github.com/mono/bockbuild/pull/122

Backport of https://github.com/mono/mono/pull/17054
2019-09-25 16:56:28 +02:00
monojenkins af008b207d [2019-08] [threads] clear small_id_key TLS when unregistering a thread (#17015)
[2019-08] [threads] clear small_id_key TLS when unregistering a thread

Fixes
```
* thread #12, name = 'tid_a507', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1be66144)
  * frame #0: 0x1be66144 libsystem_c.dylib`__abort + 184
    frame #1: 0x1be6608c libsystem_c.dylib`abort + 152
    frame #2: 0x003e1fa0 monotouchtest`log_callback(log_domain=0x00000000, log_level="error", message="* Assertion at ../../../../../mono/utils/hazard-pointer.c:158, condition `mono_bitset_test_fast (small_id_table, id)' not met\n", fatal=4, user_data=0x00000000) at runtime.m:1251:3
    frame #3: 0x003abf44 monotouchtest`monoeg_g_logv_nofree(log_domain=0x00000000, log_level=G_LOG_LEVEL_ERROR, format=<unavailable>, args=<unavailable>) at goutput.c:149:2 [opt]
    frame #4: 0x003abfb4 monotouchtest`monoeg_assertion_message(format=<unavailable>) at goutput.c:184:22 [opt]
    frame #5: 0x003904dc monotouchtest`mono_thread_small_id_free(id=<unavailable>) at hazard-pointer.c:0:2 [opt]
    frame #6: 0x003a0a74 monotouchtest`unregister_thread(arg=0x15c88400) at mono-threads.c:588:2 [opt]
    frame #7: 0x00336110 monotouchtest`mono_thread_detach_if_exiting at threads.c:1571:4 [opt]
    frame #8: 0x003e7a14 monotouchtest`::xamarin_release_trampoline(self=0x166452f0, sel="release") at trampolines.m:644:3
    frame #9: 0x001cdc40 monotouchtest`::-[__Xamarin_NSTimerActionDispatcher release](self=0x166452f0, _cmd="release") at registrar.m:83445:3
    frame #10: 0x1ce2ae68 Foundation`_timerRelease + 80
    frame #11: 0x1c31b56c CoreFoundation`CFRunLoopTimerInvalidate + 612
    frame #12: 0x1c31a554 CoreFoundation`__CFRunLoopTimerDeallocate + 32
    frame #13: 0x1c31dde4 CoreFoundation`_CFRelease + 220
    frame #14: 0x1c2be6e8 CoreFoundation`__CFArrayReleaseValues + 500
    frame #15: 0x1c2be4c4 CoreFoundation`CFArrayRemoveAllValues + 104
    frame #16: 0x1c31ff64 CoreFoundation`__CFSetApplyFunction_block_invoke + 24
    frame #17: 0x1c3b2e18 CoreFoundation`CFBasicHashApply + 116
    frame #18: 0x1c31ff10 CoreFoundation`CFSetApplyFunction + 160
    frame #19: 0x1c3152cc CoreFoundation`__CFRunLoopDeallocate + 204
    frame #20: 0x1c31dde4 CoreFoundation`_CFRelease + 220
    frame #21: 0x1c304a80 CoreFoundation`__CFTSDFinalize + 144
    frame #22: 0x1bfa324c libsystem_pthread.dylib`_pthread_tsd_cleanup + 644
    frame #23: 0x1bf9cc08 libsystem_pthread.dylib`_pthread_exit + 80
    frame #24: 0x1bf9af24 libsystem_pthread.dylib`pthread_exit + 36
    frame #25: 0x0039df84 monotouchtest`mono_threads_platform_exit(exit_code=<unavailable>) at mono-threads-posix.c:145:2 [opt]
    frame #26: 0x0033bb84 monotouchtest`start_wrapper(data=0x1609e1c0) at threads.c:1296:2 [opt]
    frame #27: 0x1bf9b914 libsystem_pthread.dylib`_pthread_body + 128
    frame #28: 0x1bf9b874 libsystem_pthread.dylib`_pthread_start + 44
    frame #29: 0x1bfa3b94 libsystem_pthread.dylib`thread_start + 4
```


Debugged by @lambdageek. Contributes to https://github.com/mono/mono/issues/10641

Edit: C/p into PR description so it's in the commit message:

We think what happens is:

1. `start_wrapper` runs `unregister_thread` when the thread is exiting.  At that point the `small_id` for the thread is cleared from the hazard pointer bitset by `mono_thread_small_id_free (small_id)`

2. Some other TLS destructor runs and attaches the thread again (which runs `mono_thread_info_register_small_id` which first calls `mono_thread_info_get_small_id` which tries to get the small id from the `small_id_key` TLS key and so the new `MonoThreadInfo` has the same `small_id` as the previously destroyed `MonoThreadInfo` - but the hazard pointer bitset is **not** updated).

3. This other TLS destructor runs and calls `mono_thread_detach_if_exiting` which calls `unregister_thread` again.

4. `unregister_thread` calls `	mono_thread_small_id_free (small_id)` a second time which asserts because we already cleared that id from the hazard pointer bitset.



Backport of #16973.

/cc @lewurm
2019-09-24 23:15:54 +02:00
monojenkins 6d40f13121 [2019-08] [debugger] Crash when debugging iOS application that throws (#16989)
* Doing the same fix from Android to IOS, I removed the ifdef, I don't think that this will happen when not using IOS nor Android, but I prefer to let the if there to avoid the exception. On mini-exceptions.c check if there is no ji we can continue and generate the exception without checking wrapper_type.

Fixes #16824

* Removing unnecessary check.
2019-09-24 20:50:09 +02:00
Jo Shields 4546440471 Add mono-hang-watchdog.in to tarball (#17018)
Remove custom distdir target and use standard EXTRA_DIST to do so.

(cherry picked from commit 75c21692a0)
2019-09-24 16:09:53 +02:00
monojenkins 4c31bdabf3 [2019-08] [debugger] New way to filter exceptions to support VSWin features (#17000)
* Creating a new version of MOD_KIND_EXCEPTION_ONLY to support VsWin features, discussed with Joaquin Jares. Because we don't have this functionality of get every other exception that is not specified, VsWin was getting every exception and filtering later. But this causes a slowness during the debugger because we stop all thread on each exception that we get, even if they are caught and we don't want to stop.

* Fixing other unit test because now we have 2 nested classes. Fixing indentation.

* Creating a flag in the MOD_KIND_EXCEPTION_ONLY protocol event and not creating a new protocol event.

* Changing what was suggested by Zoltan.

* Coding style

* Bump API snapshot submodule
2019-09-24 11:08:20 -03:00
Alexander Köplinger d73a286a2c [ci] Make ios/mac sdks archive URL more predictable
Requested by xamarin-macios team.

(cherry picked from commit 0a3c9c451b)
2019-09-24 15:27:12 +02:00
monojenkins dacef517fa [merp] Use function names even in 'private crashes' mode (#17003)
Partially fixes https://github.com/mono/mono/issues/16689

Backport of #16897.
2019-09-24 11:41:06 +02:00
monojenkins d1ca1a5d2e [2019-08] [System.Xml] Fix deserialization issue (#17014)
[This ](https://github.com/mono/mono/pull/11194/files#diff-ae54d9565e735005686191de0f19ed50R431-R435)change in `XmlTypeMapElementInfo.GetElement`  introduced the logic for handling the case of derived types deserialization. 
For some cases (like https://github.com/mono/mono/issues/16918) it breaks existing functionality because it returns wrong element for given element name after searching withing derived types collection.

![image](https://user-images.githubusercontent.com/3258267/65416085-bedc0500-ddff-11e9-941c-f24045c64121.png)

Unfortunately, what I can do here is just reverting the related changes.

Fixes https://github.com/mono/mono/issues/16918

Backport of #16965.

/cc @marek-safar @MaximLipnin
2019-09-24 11:35:39 +02:00
monojenkins 1d55b355f3 Correctly check for HAVE_STAT_BIRTHTIME in configure.ac checks for System.Native (#17001)
The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in https://github.com/mono/mono/commit/8f5cef936491e8b20888bbf18d426482c890637c.

Fixes https://github.com/mono/mono/issues/16974
2019-09-24 10:12:30 +02:00
monojenkins bb522edb0d [2019-08] Restore Previous ExecutionContext Capture Behavior (#16997)
Restores previous ExecutionContext Capture behavior where we were copying a new SynchronizationContext as opposed to a reference to the existing one.

The old behavior caused SynchronizationContextAwaitTaskContinuations to not post to a SynchronizationContext.

Fixes https://github.com/mono/mono/issues/16759

Reverts a fix for https://github.com/mono/mono/issues/12421

Backport of https://github.com/mono/mono/pull/16945
2019-09-23 19:06:16 -04:00
Bernhard Urban 7f7b5c9f3e [interp] avoid exception checkpoint when in thread is in GC Safe state (#16967)
[2019-08] [interp] avoid exception checkpoint when in thread is in GC Safe state

Backport of https://github.com/mono/mono/pull/16955
2019-09-23 21:46:06 +02:00
Alexander Köplinger c87f99dd81 [ci] Fix typo in sdks-archive.groovy 2019-09-23 15:53:44 +02:00
Alexander Köplinger 065499c2ef [ci] Fix typo in sdks-archive.groovy 2019-09-23 15:48:59 +02:00
Alexander Köplinger 9f7b2c8d0a [ci] Fix typo in sdks-archive.groovy 2019-09-23 15:44:44 +02:00
Alexander Köplinger 2c003ec71d [ci] Build iOS/Mac Mono sdks archive using Xcode 11
This was requested by the xamarin-macios team.

(cherry picked from commit 6ad929c317)
2019-09-23 15:43:33 +02:00
Bernhard Urban e02e823ef7 [arm64_32] fix pointer size in CallInfo
Note that in the output below `a`, `b`, etc. are NSObjects, so they are really passed as pointer.

Before:
```
* thread #1, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x04f301d4 aWatchOSExtension`::xamarin_localized_string_format_9(format="hello%@%@%@%@%@%@%@%@%@", a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=0x00000000) at nsstring-localization.m:81:9
   78   void *
   79   xamarin_localized_string_format_9 (NSString *format, id a, id b, id c, id d, id e, id f, id g, id h, id i)
   80   {
-> 81           return [NSString localizedStringWithFormat: format, a, b, c, d, e, f, g, h, i];
   82   }
   83
   84   }
(lldb) mbt 4
* thread #1
  * frame #0: 0x04f301d4 aWatchOSExtension`::xamarin_localized_string_format_9(format="hello%@%@%@%@%@%@%@%@%@", a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=0x00000000) at nsstring-localization.m:81:9
    frame #1: 0x04d9984c aWatchOSExtension`interp_to_native_trampoline + 156
    frame #2: 0x04f41d5c aWatchOSExtension`ves_pinvoke_method(frame=0x05167af8, sig=0x1518afd0, addr=(aWatchOSExtension`::xamarin_localized_string_format_9(NSString *, id, id, id, id, id, id, id, id, id) at nsstring-localization.m:80), string_ctor=0, context=0x14550960, save_last_error=0) at interp.c:1411:2 [opt]
    NSString::xamarin_localized_string_format_9 @ 68 "calli.nat" || frame #3: 0x04f3bfa4 aWatchOSExtension`interp_exec_method_full(frame=0x05167d38, context=<unavailable>, clause_args=0x00000000, error=0x05168540) at interp.c:3290:5 [opt]
```

After:
```
* thread #1, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x04c2c1e0 aWatchOSExtension`::xamarin_localized_string_format_9(format="hello%@%@%@%@%@%@%@%@%@", a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8) at nsstring-localization.m:81:9
   78   void *
   79   xamarin_localized_string_format_9 (NSString *format, id a, id b, id c, id d, id e, id f, id g, id h, id i)
   80   {
-> 81           return [NSString localizedStringWithFormat: format, a, b, c, d, e, f, g, h, i];
   82   }
   83
   84   }
```
2019-09-23 11:53:10 +02:00
monojenkins 70d6903053 [2019-08] [merp] Use a separate program as the hang supervisor. (#16900)
* [merp] Use a separate program as the hang supervisor.

Fixes https://github.com/mono/mono/issues/15646

macOS does not like signals being sent from the forked supervisor process, possibly towards anywhere but definitely when sent to the parent process. The following message is currently spewed after the supervisor process attempting to send a SIGSEGV to a hanged Mono process:
"The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec()."

We follow that direction and introduce a new binary that, when available in the mono executable's binary directory, is used to abort the parent process for us.

* Experiment: remove line possibly causing bad compilation under C++
2019-09-20 16:21:34 +02:00
Rolf Bjarne Kvinge 4bff2b6370 [offsets-tool] Install clang into the user-specific python directory.
Because the system location isn't world writeable on Catalina.
2019-09-20 16:19:44 +02:00
EgorBo 81894ec8ca Implement WriteCore and ReadCore in DeflateStream 2019-09-20 16:18:28 +02:00
Alexander Köplinger bfbf823ca1 [ci] Remove more XCODE32_DIR usages (#16964)
Follow-up to https://github.com/mono/mono/pull/16936

(cherry picked from commit 74b9ca426a)
2019-09-20 14:01:06 +02:00
Alexander Köplinger ce01b20a4d Add net_4.8.xml to EXTRA_DIST and bump binary-reference-assemblies again
The file was missed in https://github.com/mono/mono/pull/16912.
Also pull in another reference assemblies update.

(cherry picked from commit 857284b412)
2019-09-20 12:00:41 +02:00
Alexander Köplinger 7a587d7fa6 Add .NET 4.8 reference assemblies (#16912)
Brings in https://github.com/mono/reference-assemblies/pull/20

(cherry picked from commit f6a080bb79)
2019-09-20 12:00:35 +02:00
Rolf Bjarne Kvinge 35e454a8f6 [sdks] Remove the mac32 build. (#16936)
Xamarin.Mac doesn't need nor use it anymore.

This also removes the last part of the mono archive that required Xcode 9.4.
2019-09-19 14:34:30 -05:00
monojenkins 75eb342f53 [2019-08] [System] Make FileSystemWatcher backend non-static (#16926)
[2019-08] [System] Make FileSystemWatcher backend non-static

The FileSystemWatcher `watcher` field is the backend IFileWatcher that's
supposed to be used for the actual operations.

Each backend has a `bool GetInstance (out watcher)` method that returns a
singleton object, so each new instance of FileSystemWatcher gets the same
IFileWatcher instance.  (They will get different `watcher_handle` instances
which are used by some backends to uniquely identify this FileSystemWatcher).

However when the first FileSystemWatcher instance is `Dispose`d, it will set
`watcher = null` which will prevent the remaining instances from calling

    watcher?.StopDispatching (watcher_handle);
    watcher?.Dispose (watcher_handle);

which means that the backend won't properly cleanup resources for any other FSW
instances that have other `watcher_handle` values.

Addresses https://github.com/mono/mono/issues/16709



<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->


Backport of #16922.

/cc @steveisok @lambdageek
2019-09-19 14:45:54 -04:00
monojenkins 5881981f79 [2019-08] [mini] Add missing membars when initializing rgctx entries (#16909)
[2019-08] [mini] Add missing membars when initializing rgctx entries

Whenever we are publishing changes to the rgctx arrays, we are racing with rgctx_lazy_fetch_trampoline, so we need to make sure any pointers we set there must have their contents initialized.


Backport of #16904.

/cc @marek-safar @BrzVlad
2019-09-18 11:36:20 -04:00
monojenkins 6290b6cd6e Temporarily disable embedded ppdb data decompression (#16911)
Backport of #16868.
2019-09-18 14:57:42 +02:00
monojenkins a0e7f9eaf2 [2019-08] [arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter (#16886)
[2019-08] [arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter

Main objective for reviewers: This PR shouldn't change anything for `arm64`.

Context: "Debug Mode" on the Apple Watch allows execution of regular machine code and thus is pretty similar to FullAOT on iPhone, i.e. it doesn't require bitcode, but _still_ doesn't allow `signal(3)` so cooperative suspend is required.

Apple Watch Series 4 and onward use an ARM64 chip, but with a different ABI, also known as `arm64_32`. This PR changes the AOT compiler and related trampolines so that the AOT compiler can generate all necessary code to run the interpreter on this target.


Changes:

--------------------------------------

[arm64_32] set register size to 8 in cross compiler too 

-----------------------------------------

 [machine] update `target_mgreg_t` definition

`SIZEOF_REGISTER` is usually the same as `TARGET_SIZEOF_VOID_P`, except when `MONO_ARCH_ILP32 is defined.

`target_mgreg_t` should represent the width of the hardware register, that is, `SIZEOF_REGISTER`.

---------------------------------------------

[arm64_32] fix AOT image layout 

---------------------------------------------

 [arm64_32] make trampolines bitwidth aware

* replace pointer loads/stores with bitwidth-dependent macro
* reflect `specific` trampolines so that only two instructions are used for ILP32, since the related pair in the data page only needs 2 * 32bits too
* replace some `sizeof (target_mgreg_t)` with `TARGET_SIZEOF_VOID_P` (former is hardware register size, latter is pointer size)

---------------------------------------------
These regression tests are _not_ passing: https://github.com/mono/mono/issues/16864 Also some of monotouch-tests are crashing, see https://github.com/mono/mono/issues/16819

Here is a screenshot of a debug session in VSMac:
<img width="1321" alt="Screenshot 2019-09-16 at 19 13 22" src="https://user-images.githubusercontent.com/75403/64981326-1dfbc000-d8bc-11e9-9d16-48036f36b638.png">


Contributes to https://github.com/mono/mono/issues/10641


Backport of #16865.

/cc @lewurm
2019-09-17 17:06:03 -04:00
monojenkins 6275840a7f Rename bundle identifier for the various Mono.frameworks we create for Xamarin.iOS. Fixes xamarin/xamarin-macios#7005. (#16901)
This is the equivalent of
https://github.com/xamarin/xamarin-macios/commit/a9abc07cb357f9f012e3da66c70fa09d96bf02f7,
just for the Mono.frameworks in the mono archive.

Fixes https://github.com/xamarin/xamarin-macios/issues/7005.
2019-09-17 21:18:06 +02:00
monojenkins 25f6093283 [corlib] Fix building nunit-lite twice (#16895)
We sometimes saw the following build error in Mono SDKs builds on Jenkins:

```
[2019-09-16T01:03:30.709Z] CSC     [xammac] nunit-lite-console.exe
[2019-09-16T01:03:30.709Z] error CS0009: Metadata file '/Users/builder/jenkins/workspace/archive-mono/2019-08/mac/release/mcs/class/lib/xammac/nunitlite.dll' could not be opened -- PE image doesn't contain managed metadata.
```

Taking a closer look we found out that nunit-lite was trying to be built twice for the same profile which caused a race where the file was corrupted.

The reason for this is that the corlib Makefile defines two test assemblies: the normal PROFILE_corlib_test.dll and BinarySerializationOverVersionsTest.dll and
integrating the BinarySerializationOverVersionsTest.dll via the `test-vts` target incorrectly overwrote the `test` target instead of using `test-local`.

Backport of #16894.
2019-09-17 20:26:09 +02:00
monojenkins 7ec17ba1be [2019-08] [android sdk] Add aprofutil tool (#16884)
Backport of #16866.
2019-09-17 15:58:17 +02:00
monojenkins f755f3b539 [metadata] Fix leaks when handling a few attributes (#16850)
[2019-08] [metadata] Fix leaks when handling a few attributes

Callers of mono_reflection_create_custom_attr_data_args_noalloc were leaking some of the returned information. Accessed attributes are FixedBufferAttribute and UnmanagedFunctionPointerAttribute.

Backport of #16675.

/cc @BrzVlad
2019-09-16 20:16:02 -04:00
monojenkins 5f9a2db39b [2019-08] Fix infrequent hangs in test-runner. (#16854)
* Fix infrequent hangs in test-runner.

test-runner has been plagued with very infrequent hangs causing long
timeouts on CI. Turns out that there is a race in AsyncStreamReader
used by Process class for handling stdout/stderr when closing down
process. Since AsyncStreamReader::Dispose didn't make sure no pending
async read requests were still in flight before closing the stream
and underlying handle, it led to a race condition deadlocking the
complete process, hanging test-runner. A similar race has also been
observed but instead of causing a deadlock, it could also manifest as an
System.ObjectDisposedException when doing EndRead while another thread
is disposing the underlying stream. Hitting that race didn't deadlock
the process but failed to complete invoke of test-runner.

Fix is to better protect the async callback and the thread doing the
dispose call. In order to make sure we don't close underlying handle
while still having async reads in flight, fix also checks async result
for completion and if not completed when trying to dispose AsyncStreamReader
it will try to cancel outstanding pending IO and wait for completion
before closing the stream.

Since the issue has only been seen on Windows, the fix will try
to cancel pending IO and wait for completion before closing stream
on Windows. On other platforms, old behavior will be preserved, meaning
that the implementation will still be vunarable to race between pending
reads and close of stream, but since problem has not been observed on
other platforms and since there is no good way of cancel outstanding
blocking reads, old behavior is kept.

At some point in future we should look into replacing the implementation
of AsyncStreamReader and use cancelation tokens, but since we don't have
all corefx support around cancelation in Mono BCL, that currently won't
solve the issue, meaning that we need to bring in more classes. Since the
problem also occur in test-runner using the build BCL profile, even more
needs to be added to that profile in order to get similar support. But due
to the infrequency of the problem and that it has only been observed on
Windows, the isolated fix seems more reasonable.

Backport of #16793.
2019-09-16 16:32:33 +02:00
Bernhard Urban f31f5ea1f1 [2019-08] [threads] do not convert NULL thread name (#16828)
Avoids this warning printed in the VSMac application output when debugging:
```
2019-09-13 17:47:27.315540+0200 aWatchOSExtension[31768:24665480] ../../../../../mono/eglib/giconv.c:1029: assertion 'str != NULL' failed
```

With this trace:
```
(lldb) mbt
* thread #2
  * frame #0: 0x00583453 aWatchOSExtension`break_on_me at giconv.c:1023:2
    frame #1: 0x005834a6 aWatchOSExtension`monoeg_g_utf16_to_utf8(str=0x00000000, len=0, items_read=0x00000000, items_written=0x00000000, err=0x00000000) at giconv.c:1036:3
    frame #2: 0x0046d871 aWatchOSExtension`mono_thread_get_name_utf8(thread=0x24d08120) at threads.c:1812:16
    frame #3: 0x002cb7ef aWatchOSExtension`thread_commands(command=2, p="�>\x02\x18\x10", end="�>\x02\x18\x10", buf=0xb0ae0d20) at debugger-agent.c:8818:13
    frame #4: 0x002c7170 aWatchOSExtension`debugger_thread(arg=0x00000000) at debugger-agent.c:9932:10
    frame #5: 0x0047652b aWatchOSExtension`start_wrapper_internal(start_info=0x00000000, stack_ptr=0xb0ae1000) at threads.c:1221:3
    frame #6: 0x0047616c aWatchOSExtension`start_wrapper(data=0x7b63a050) at threads.c:1294:8
    frame #7: 0x077365f8 libsystem_pthread.dylib`_pthread_body + 137
    frame #8: 0x077397f7 libsystem_pthread.dylib`_pthread_start + 78
    frame #9: 0x077357ce libsystem_pthread.dylib`thread_start + 34
```

Introduced by b5c0c831da and seemingly fixed by accident in https://github.com/mono/mono/commit/7b64f1cd005ef4f8e7f0aa5655debca2754b1755#diff-f1a9287559d3aa620b058619f47f00c9R1832

Instead of backporting 7b64f1cd00 to 2019-08, I'm proposing this PR for the release branch.
2019-09-15 19:52:52 -05:00
monojenkins 20308e6f87 [aot] Do not wrap tool_prefix path when calling strip (#16820)
[2019-08] [aot] Do not put quotes around wrapped path

Should fix: https://github.com/xamarin/xamarin-android/issues/3619

As it results in double quoting, which vanishes the effect and breaks
AOT for XA on Windows.

The actual error:

    [aot-compiler stdout] Stripping the binary: ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Stable\MSBuild\Xamarin\Android\ndk\arm-linux-androideabi-"strip" --strip-symbol=\$a --strip-symbol=\$d obj\Release\90\aot\armeabi-v7a\libaot-Xamarin.Android.Arch.Core.Common.dll.so.tmp
    [aot-compiler stderr] '""C:\Program' is not recognized as an internal or external command,
    [aot-compiler stderr] operable program or batch file.
    [aot-compiler stderr] AOT of image C:\Users\peter\source\repos\App9\App9\App9.Android\obj\Release\90\android\assets\Xamarin.Android.Support.CoordinaterLayout.dll failed.


Backport of #16792.

/cc @lewurm @radekdoulik
2019-09-13 13:56:04 -04:00
Radek Doulik cecda47c48 [aprofutil] Add -p and -f options
-p PORT allows easier retrieval of AOT profile from the application
 running with aot profiler, using the socket connection on local PORT

-f instructs the tool to try setup adb port forwarding to/from Android
 device or emulator

Example usage, retrieve the AOT profile from Android:

    > mono aprofutil.exe -s -v -f -p 9998 -o my.aprof
    Calling 'adb forward tcp:9998 tcp:9998'...
    Reading from '127.0.0.1:9998'...
    Read total 94903 bytes...
    Summary:
    	Modules:          6
    	Types:          262
    	Methods:      1,162
    Going to write the profile to 'my.aprof'
2019-09-12 13:05:43 +02:00
Steve Pfister 824cc12ac3 Bump to mono/corefx@e79cf5b
Backport of https://github.com/mono/mono/pull/16774
2019-09-12 08:57:24 +02:00
Alexander Köplinger b77dc06a7e [aprofutil] Install the tool correctly (#16112)
It needed a few tweaks to be usable when Mono is installed to the prefix.
2019-09-11 12:08:38 -05:00
Radek Doulik 1848d78d60 [aotprof-tool] Initial import of AOT profiler tool (#15384)
* [aotprof-tool] Initial import

Imported https://github.com/radekdoulik/aotprofile-tool and updated it
to use Mono.Profiler.Log

* [aotprof-tool] Added man page

* [aotprof-tool] Use the shortened name in README.md
2019-09-11 12:08:38 -05:00
monojenkins da0086e304 [2019-08] Add RenamedEvent* to FSW sources from CoreFX (#16756)
Add RenamedEvent* to FSW sources from CoreFX

Fixes #16486 - This was only partially fixed until now

* [csproj] Update project files

* Add test files which test these code paths on corefx
2019-09-11 12:11:57 -04:00
monojenkins 0297b21b03 [msbuild][roslyn] Bump msbuild and roslyn to pull in new versions (#16768) 2019-09-11 07:42:21 -05:00
monojenkins 40631e3b9e [2019-08] [aot] move method_addresses to data.rel.so section to avoid text relocations (#16751)
[2019-08] [aot] move method_addresses to data.rel.so section to avoid text relocations

Another revert of a revert! 🎉 

After some discussions with @grendello and @radekdoulik, we came up with this solution. It's a better attempt to fix https://github.com/mono/mono/issues/16369 as it (1) works within the restrictions of Android 10 and (2) still works for armv7 AOT. 


`.text` relocations aren't allowed in Android 10 (and this change shouldn't hurt on Linux).

AOT compilation:
```console
$ MONO_PATH=/Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ \
MONO_ENV_OPTIONS="" \
./sdks/out/android-cross-arm-release/bin/armv7-linux-android-mono-sgen \
--aot=keep-temps,outfile=here.dll.so,asmwriter,mtriple=armv7-linux-gnueabi,tool-prefix=/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-,ld-flags= \
~/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll

Mono Ahead of Time compiler - compiling assembly /Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll
AOTID 7DDD05DA-37E0-813A-8C27-3E1634391BB3
Compiled: 144382/144382
Executing the native assembler: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-as"   -mfpu=vfp3 -o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ
Executing the native linker: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld"  -shared -o here.dll.so.tmp  /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o
Stripping the binary: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip" --strip-symbol=\$a --strip-symbol=\$d here.dll.so.tmp
Retained input file.
JIT time: 15031 ms, Generation time: 7374 ms, Assembly+Link time: 75130 ms.
```

Before:
```console
$ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ
        .align 3
jit_code_end:

        .byte 0,0,0,0
.text 1
        .align 3
method_addresses:
        .local method_addresses
        .type method_addresses,#function
ldr pc,=.Lm_0
.ltorg
ldr pc,=.Lm_1
.ltorg
$ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel
 0x00000016 (TEXTREL)                    0x0
 0x0000001e (FLAGS)                      TEXTREL
```

After switching to `.data.rel.so`:
```console
$ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_1YhAgn  # assembly file produced by AOT compiler
jit_code_end:

        .byte 0,0,0,0
.section ".data.rel.ro"
.subsection 0
        .align 3
method_addresses:
        .local method_addresses
        .type method_addresses,#object
ldr pc,=.Lm_0
.ltorg
ldr pc,=.Lm_1
.ltorg
$ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel
$ echo $?
1
```

Backport of #16729.

/cc @lewurm
2019-09-10 12:35:47 -04:00
Thays Grazia 68b77674e2 Vtable [i] can be null so this should be check before use it. Fixes #16712 2019-09-09 19:17:14 +02:00
Bernhard Urban 4a0b4f41ed [mini] publish global patches after JitInfo has been added
Fixes https://github.com/mono/mono/issues/14080

Consider the following example:

```csharp
static void CommonCallTarget () { }

static void TailA () {
    tailcall CommonCallTarget ();
}

static void TailB () {
    tailcall CommonCallTarget ();
}
```

Since `TailA` and `TailB` are tailcalling into `CommonCallTarget`, the resolution at patch-time is a bit tricky, that is, since it's a jump-like instruction the patching machinery won't know where it was called from. That's why we maintain a global hashtable `jump_target_hash` where each jump-site is signed up to be patched. At patch-time we know the target method (in the example `CommonCallTarget`), but since we don't know where we are coming from, we will just apply all patches for that target.

This works since ages, so why did it crash on arm64 sometimes?
When the patching happens, we check if the displacement between jump-site and target fits into it (24bit). If not, which happens not very often, we have to allocate a _thunk_:
https://github.com/mono/mono/blob/36296ce291f8a7b19de3eccb7a32c7e4ed9df8f2/mono/mini/mini-arm64.c#L928-L942

So instead of jumping to the target directly, we'll branch to the thunk. This is a little trampoline that loads the full address of the target and then finally branches to it. This one will live close-by the jump-site, because during compilation we will reserve specifically for that scenario some space after the generated code. For this, however, we need the JitInfo of the jump-site. And that's where the origin of the race is. Let's say:

* Thread A compiles `TailA`, and then jumps into it. Thus one patch point is in the `jump_target_hash`.
* Now Thread B compiles `TailB`, registers the patch point but has _not_ yet registered its JitInfo.
* Then Thread A continues, does the tailcall into `CommonCallTarget`, enters the patching machinery, which sees two patches. Now assume when applying the patch for `TailB` the displacement is too large, thus it tries to allocate a thunk but can't find the relevant JitInfo for it that it needs to emit the thunk. So it crashes as reported in https://github.com/mono/mono/issues/14080

As far as I can tell this only affects ARM64, ARM and PPC.
2019-09-09 18:33:23 +02:00
Thays Grazia 7a1f63fde6 [debugger][android] It was not initialising seq_points on MonoCompile on Android, so when was compiling dynamic methods, seq_points wasn't created and we got the assert when try to single step. 2019-09-06 23:28:08 +02:00
Martin Baulig 29b1ac19c9 Fix the tests. 2019-09-03 19:24:31 -05:00
Martin Baulig 71e34edce2 X509CertificateImplBtls.PrivateKey should allow to actually set the key. 2019-09-03 19:24:31 -05:00
monojenkins 1ecb6e59de [2019-08] [corlib] Add hack for Hebrew calendar data (#16641)
* [corlib] Add hack for Hebrew calendar data

* Fix month names for the Hebrew calendar

* [csproj] Update project files
2019-09-03 14:14:33 -04:00
monojenkins 17ba402d80 [2019-08] Remove MAX_PATH usage in w32process (#16595)
* Remove MAX_PATH usage in w32process

* Fixes

* Shrink buffer temporarily

* More fixes

* Reset buffer size to 260

* Fix length check and add notes

* Actually free things

* Add tracing and zero len at start

* Typo

* Fix another leak

* Simplify logic
2019-09-02 14:10:13 -05:00
monojenkins ded02bc115 [2019-08] [debugger][android] Fixing single step inside Exception on Android (#16597)
* Fixing single step inside Exception on Android... The method is null because on ss_create_init_args the IL is -1 when calling method Mono_UnhandledException_internal what I think it's expected, because of that I ignore the single step on android if there is no method. (debugger-engine.c) After that the sequence point cannot be found because it's calling a method of class DynamicMethodNameCounter what I think it's expected, because of that I remove the assert on android. (debugger-agent.c) Fixes #14772

* Changing comment to make it clear...
2019-08-31 08:23:52 -04:00
monojenkins 585f244aed [2019-08] Bump ikvm to pick up caa8e7f54279a47422626005d228447f5d3670d5. (#16574)
* Bump ikvm to pick up caa8e7f54279a47422626005d228447f5d3670d5.

* [monodis] Add a missing cattr parent case.
2019-08-30 12:28:45 +02:00
Alexander Köplinger 23cc371009 Build pkg-config as 64bit only, libtiff as universal and remove gtk-quartz-engine.py (#16548)
See https://github.com/mono/bockbuild/pull/116

(cherry picked from commit 309cf1bcee)

# Conflicts:
#	external/bockbuild
2019-08-29 20:31:53 +02:00
monojenkins ce6fa810dd [2019-08] Use the right FileSystemWatcher sources (#16554)
* Use the right FileSystemWatcher sources

The corefx code for FileSystemEventArgs has some changes to support
constructing one with a null filename.

Fixes #16486

* Remove the mono sources for the newly replaced files

* [csproj] Update project files
2019-08-29 14:35:26 +02:00
monojenkins bff42f3540 [2019-08] Implement Read and WriteAsyncMemory in Mono DeflateStream (#16549)
Resolves #16122

Since we put in the corefx version of GZipStream, it is expected that
our version of DeflateStream actually implements Write+ReadAsyncMemory.

This change does that by just calling the plain WriteAsync & ReadAsync
methods until we decide (or not) to pull in the corefx DeflateStream.

Backport of #16523.
2019-08-29 14:34:58 +02:00
monojenkins 076bab44f6 [2019-08] [arm/arm64] fix fconv/rconv issues with LLVM (#16532)
* [ci] add make -C mono/mini llvmaotcheck to FullAOT LLVM lanes

* [arm64] use opcode emulation for fconv/rconv

LLVM eagerly optimizes constants such as NaN in a way that does not align with .NET behaviour. In the future we can change it so that we only do opcode emulation when LLVM is used.

Fixes https://github.com/mono/mono/issues/16411

* [arm] account only 4 bytes on stack for single precision arguments

Fixes `test_0_arm64_small_stack_args` in gshared.cs when
* `test_0_arm64_small_stack_args` is compiled with LLVM
* `Foo3.Floats` is compiled with Mini

* [arm] use opcode emulation for fconv/rconv

* [llvmaotcheck] require sse3 being available for regression tests

* [amd64] use opcode emulation for fconv/rconv

* fix cast and signature for mono_rconv_u4
2019-08-28 13:28:52 +02:00
monojenkins 75f2ac15bd [threadpool-io] Throw if backend won't be able to register a FD (#16500)
The poll+select i/o selector backend can't handle file descriptor ids greater
than FD_SETSIZE.  This can happen if too many files are open and we want to
wait on it.

Previously, mono would fail in the i/o selector thread by which point it was
too late to do anything.

With this change we will fail eagerly on the thread that calls IOSelector.Add
by throwing a NotSupportedException.

Addresses https://github.com/mono/mono/issues/15931
2019-08-27 15:17:41 -04:00
Steve Pfister 44e1854943 Allow file:// based Uri's to be used in HttpClient when the BaseAddress is set
Fixes https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/967582

Bumps the HttpClient part in mono/corefx at: https://github.com/mono/corefx/commit/ee3acec16b37bec5016da129e1e3840097ca629b

The test that would have caught this failure was disabled previously via:
https://github.com/mono/mono/commit/2f411750acfd2132f9b4970ef8cf11d9a0f62df9

(cherry picked from commit 580defd967)
2019-08-27 20:02:46 +02:00
Alexander Köplinger 53cc8a61dc [acceptance-tests] Bump roslyn test repo to remove a problematic nuget feed
(cherry picked from commit 8d422436f5)
2019-08-27 19:48:29 +02:00
monojenkins 6717bcb8b6 [2019-08] [w32socket] Translate some errno codes to WSA_ errors imprecisely. (#16488)
* [w32socket] Translate some errno codes to WSA_ errors imprecisely.

These aren't a perfect match, but better than falling into the `default` case
where Mono asserts and crashes.

Addresses part of https://github.com/mono/mono/issues/16024

* [w32error] Add WSA_INVALID_PARAMETER and WSA_INVALID_HANDLE
2019-08-27 01:28:14 +02:00
monojenkins d82d780e42 [2019-08] [android] remove text relocations in AOT/arm32 (#16472)
* Revert "[aot] partial revert of #14043 (#14135)"

This reverts commit 223e0bd78d.

* Revert "[aot] change method table generation so that it works for larger assemblies on ARM (#14043)"

This reverts commit 9ff3b0d65e.
2019-08-27 01:25:25 +02:00
Alexander Köplinger 13bc35face [utils] Don't use MAP_32BIT on Apple platforms, fixes crash with XCode 11 beta6 (#16480)
As of XCode 11 beta6 the MacOSX SDK defines the MAP_32BIT symbol.

This causes the `mono_valloc()` function to try to use the `MAP_32BIT` flag for `mmap()`.

However as mentioned in the comment for the symbol in mman.h it seems to require a special entitlement which isn't available/documented anywhere yet.
This in turn causes the mmap call to fail presumably because we're missing that entitlement.

Instead we now skip setting this flag on Apple platforms to make `mmap()` behave like it did before.

Backport of https://github.com/mono/mono/pull/16441
2019-08-26 19:39:50 +02:00
monojenkins 8df98444c1 Pass --clr-memory-model in csc/vbc wrapper script (#16444)
[2019-08] Pass --clr-memory-model in csc/vbc wrapper script

Should help with random CSC crashes on ARM (we've been using it in the Mono build for a while).


Backport of #16439.

/cc @akoeplinger
2019-08-26 08:15:49 -04:00
monojenkins d63841057e [coop] Add a handle frame in construct_culture (#16442)
[2019-08] [coop] Add a handle frame in construct_culture

Otherwise we see warnings like these:

```
ves_icall_System_Globalization_CultureInfo_internal_get_cultures_raw USED 680 handles
```


Backport of #16299.

/cc @akoeplinger @lambdageek
2019-08-26 07:30:48 -04:00
monojenkins dc98767858 Fix issue in SafeHandle.DangerousReleaseInternal() that caused #16034. (#16423)
Using the CoreCLR version of this line fixed the problem and my investigations
also revealed why.

The `SafePipeHandle` contains a reference to both the Socket as well as the
`SafeSocketHandle`, taking ownership of them.  If there are no additional
references to either of them, so that both are collected in the same GC pass,
their finalizer may be invoked in any order.

If the Socket gets finalized first, it's `SafeSocketHandle` will have a `_mstate`
of 8 (two references) at the beginning of `DangerousReleaseInternal()` - which
will set it to 6 (one reference plus disposed flag).

Then when the `SafePipeHandle` gets collected, it will call `DangerousRelease ()`
on it's `SafeSocketHandle`.  As mentioned above, it's `_mstate` will be 6.
Now we own the handle, so we'll decrease it's reference count by one and set the
`Closed` flag - the new `_mstate` should thus be 3.

However, using

    new_state = (old_state & RefCount_Mask) - RefCount_One;

would set it to 1 - thus effectively clearing the `Disposed' flag.  And since it's
reference count is now also zero, the next finalize pass will then throw.

The CoreCLR version of this class uses

    new_state = old_state - RefCount_One;

which fixes this.

Backport of #16244.
2019-08-23 15:33:56 +02:00
Steve Pfister 472f0820d3 [2019-08] Add Compiler Server Workaround for 32-bit Linux (#16421)
Currently, if the process is 32-bit, roslyn tries to determine how much
memory is available. To do that, it tries to pinvoke into GlobalMemoryStatusEx,
which is not supported on mono.

Without it, the compiler server bombs on https://github.com/dotnet/roslyn/blob/0e63260c5afb3fb5b74c357dd250e500172bcd63/src/Compilers/Server/VBCSCompiler/NamedPipeClientConnection.cs#L55-L59

Backport of https://github.com/mono/mono/pull/16405
2019-08-23 14:48:26 +02:00
Alexander Köplinger 2ad05ee764 Bump corefx to get https://github.com/mono/corefx/pull/336 2019-08-23 14:44:13 +02:00
monojenkins 32ded2e340 [android] mono_dl_open_file: use g_file_test only on absolute paths (#16393)
The intention of calling `g_file_test (file, G_FILE_TEST_EXISTS)` where file is
the name of a shared library we want to open is to speed up probing for
non-existent libraries.

See https://github.com/mono/mono/pull/12074

The problem is that if file is just a simple "libdl.so" then `dlopen (file)`
doesn't just look for it in the current working directory, it will probe some
other paths too.  (For example on desktop linux you'd also look in all the
directories in LD_LIBRARY_PATH).  So the g_file_test() call is not a robust way
to avoid calling dlopen if the filename is relative.

But it actually broke more things: https://github.com/xamarin/xamarin-android/issues/3388

When probing for "libdl.so" on Android mono_lookup_pinvoke_call will first try
prepending some paths that it knows about and we end up calling
`dlopen ("/system/lib/libdl.so")` which will fail because Bionic has security
restrictions on what code can dlopen something from /system/lib with an
absolute path.  Eventually mono_lookup_pinvoke_call will go back to trying the
bare "libdl.so" which hits `g_file_test` and returns NULL.

The new code only does the file test if we pass it an absolute path, which
gives Bionic's dlopen a chance to deal with relative paths however it needs to.
2019-08-22 13:43:27 -04:00
monojenkins d80d33b053 [2019-08] [profiler] Rename helper functions to have common prefix (#16372)
* [profiler] Rename helper functions to have common prefix

Unfortunately https://github.com/mono/mono/pull/16335 didn't fix the new symbols showing up in the log profiler module.
The reason is that we actually pass `--disable-visibility-hidden` for iOS builds in https://github.com/mono/mono/blob/0b6d95e8ce7c882e2db9e89fa0dec850c687f65e/sdks/builds/ios.mk#L98.

Rename the helper functions instead to have a common prefix so they can be ignored in xamarin-macios tests.

* Fix Windows build
2019-08-20 22:57:39 +02:00
Alexander Köplinger 04c9f2f442 Bump corefx to get https://github.com/mono/corefx/pull/332 2019-08-20 20:53:25 +02:00
Jo Shields c0f0ff02fc Pass -fvisibility=hidden to profiler modules. (#16335)
* Pass -fvisibility=hidden to profiler modules.

This appears to not break the profilers:

```
directhex@breakfast:/tmp$ nm -g /tmp/ponyponyponypony/lib/libmono-profiler-log.so | grep close_socket_fd
directhex@breakfast:/tmp$
directhex@breakfast:/tmp$ /tmp/ponyponyponypony/bin/mono --profile=log:report bottle.exe
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 99 bottles of beer on the wall.

[..]

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

Mono log profiler data
	Profiler version: 3.0
	Data version: 17
	Arguments: log:report
	Architecture: x86-64
	Operating system: linux
	Mean timer overhead: 86 nanoseconds
	Program startup: Mon Aug 19 14:18:30 2019
	Program ID: 17715
	Server listening on: 41539

JIT summary
	Compiled methods: 753
	Generated code size: 228046
	JIT helpers: 0
	JIT helpers code size: 0

GC summary
	GC resizes: 0
	Max heap size: 0
	Object moves: 0

Metadata summary
	Loaded images: 3
	Loaded assemblies: 3

Exception summary
	Throws: 0
	Executed finally clauses: 3

Thread summary
	Thread: 0x7fcd968c9700, name: "Finalizer"
	Thread: 0x7fcd966c8700, name: "Profiler Sampler"
	Thread: 0x7fcd9b036780, name: "Main"
	Thread: 0x7fcd964c7700, name: "Profiler Helper"
	Thread: 0x7fcd954c5700, name: "Profiler Dumper"
	Thread: 0x7fcd95cc6700, name: "Profiler Writer"

Domain summary
	Domain: (nil), friendly name: "bottle.exe"

Context summary
	Context: (nil), domain: (nil)

Counters:
	Mono System:
		User Time                      : 70.000ms
		System Time                    : 0.000ms
		Total Time                     : 140.000ms
		Working Set                    : 22032384
		Private Bytes                  : 63455232
		Virtual Bytes                  : 449630208
		Page Faults                    : 3004
		CPU Load Average - 1min        : 1.870000
		CPU Load Average - 5min        : 2.670000
		CPU Load Average - 15min       : 2.900000
	Mono JIT:
		Methods from AOT               : 536
		Methods JITted using mono JIT  : 154
		Methods JITted using LLVM      : 0

```

* Add missing annotations and includes

(cherry picked from commit 3070ab6a96)
2019-08-20 16:18:12 +02:00
monojenkins a8c9ef3b66 [2019-08] Add missing Dispose() call on error in MonoTlsStream.CreateStream(). (#16328)
* Add missing `Dispose()` call on error in `MonoTlsStream.CreateStream()`.

* Remove the `finally` block to make it more easy to read.
2019-08-20 08:34:15 -04:00
Alexander Köplinger 31f480c436 Bump bockbuild to get gtksharp 2019-08-20 11:52:04 +02:00
monojenkins 6df5f69b26 [2019-08] [corlib] Fix sharing mode validation rules (#16281)
Fixes https://github.com/mono/mono/issues/16032

When we switched to corefx File.Copy on unix, the behavior changed where it opened a source and destination stream in order to pass the safe handles to Interop.Sys.CopyFile. This exposed a flaw in our sharing validation rules in MonoIO.Open, which threw an exception in this scenario:

new FileStream("source.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 2048, FileOptions.DeleteOnClose);
new FileStream("source.txt", FileMode.Open, FileAccess.Read, FileShare.Read, 2048, FileOptions.None);

Simplified the FileShare check down to:

1. If the caller specifies FileShare.None, then it's an exclusive lock and no
   sharing is allowed.

2. If the caller specifies some other FileShare option, then FileShare.None
    cannot be specified.
2019-08-16 07:55:46 -04:00
monojenkins 94ec04bfdb Exclude Authenticode tests on Watch (#16283)
1002a4de2b added Authenticode cert support on non-WatchOS. The tests,
however, were not non-WatchOS-only. Fix this, so Watch doesn't try to
run Authenticode tests.
2019-08-16 00:31:59 -04:00
monojenkins a5184ed8ed Add missing FCONV_TO_U8 on ILP32 (WatchOS 5) (#16277) 2019-08-15 13:57:36 -04:00
monojenkins 4087eba140 Fix failing OSX Android lane (#16275)
Linker order matters when using .a files, so zlib.a MUST come after
sgen.a if sgen.a was compiled with support for compressed ppdb
2019-08-15 10:40:36 -04:00
monojenkins 2ef68dc530 [cominterop] Fix copy-paste error in ComVisibleAttribute testing helper. (#16269)
This type was introduced with 29a95bafd8.

Backport of #16254.
2019-08-15 14:36:55 +02:00
monojenkins 64f9c2de6f [2019-08] Fix linking of OS-provided zlib (#16245)
* Fix linking of OS-provided zlib

This is a reduced version of https://github.com/mono/mono/pull/16091
without the Z_PREFIX stuff

* Get rid of HAVE_ZLIB, be explicit about HAVE_SYS_ZLIB vs HAVE_STATIC_ZLIB

Backport of #16177.
2019-08-14 21:20:12 +02:00
monojenkins 2f373a9ad4 (mono.1) Update the MONO_THREADS_SUSPEND description (#16237) 2019-08-14 19:23:47 +02:00
monojenkins c51c60988b [sre] Outline typebuilder_setup_fields loop body (#16204)
The loop body uses coop handles, so wrap it in HANDLE_FUNCTION_ENTER/HANDLE_FUNCTION_RETURN

Addresses part of #16179

Backport of #16184.
2019-08-14 12:29:43 +02:00
Marek Safar f333a19c3a Bump linker 2019-08-14 10:18:03 +02:00
Alexander Köplinger abf46116ef [pkg] Bump libgdiplus to 6.0.2
(cherry picked from commit b60aaea791)
2019-08-13 12:13:33 +02:00
Sebastien Pouliot ec590ad3eb [2019-08][sdk] Enable the SRE runtime code inside iOS builds
This will allow the interpreter to use System.Reflection.Emit.

Note: There is a small size increase (about 50kb) for an application
built in release mode with the LLVM backend (even if the interpreter
is now used).

Backport of https://github.com/mono/mono/pull/16151
2019-08-12 21:43:36 +02:00
UnknownShadow200 dc534a8d3f [WinForms] Fix NotifyIcon not showing in systray on 64bit linux
https://bugzilla.xamarin.com/show_bug.cgi?id=14976

Credit goes to datnhanlz for noting that removing XChangeProperty(DisplayHandle, hwnd.whole_window, _XEMBED_INFO, _XEMBED_INFO, 32, PropertyMode.Replace, atoms, 2); would also fix the bug.

Note that the type of Atom is actually unsigned long (see usr/include/X11/X.h), however the code used a C# int for the atoms. As such the code worked without a problem on 32 bit linux, but broke on 64 bit linux.

I switched to using IntPtr instead to make the code also work on 64-bit.
2019-08-12 21:22:30 +02:00
Ankit Jain 835c26154c [msbuild] Bump to track xplat-master and update roslyn (#16154)
Upstream msbuild doesn't have a branch for vs16.4, so tracking master
for now.

Prompted by mono/msbuild#126:

This includes:

- merge mono-2019-06
- SDK update to track dotnet release/3.0.100-preview8
- Roslyn updated to 3.3.0-beta2-19381-14
2019-08-12 17:03:28 +02:00
Nikita Voronchev 03be2643f5 [System.Drawing.Design] Allow context be a null in the ColorEditor.EditValue (#16174)
Backport of #16141
2019-08-12 12:26:54 +02:00
Alexander Köplinger f69128c70a Bump corefx to fix build break 2019-08-10 23:47:59 +02:00
Alexander Köplinger ac12ebc375 Bump corefx to get https://github.com/mono/corefx/pull/327 2019-08-10 16:22:01 +02:00
Alexander Köplinger 595b7821e3 Bump corefx to get https://github.com/mono/corefx/pull/323 2019-08-09 16:20:31 +02:00
Alexander Köplinger 409c0a7c2d [ci] Trigger PR builds for netcore only on master branch
The work is happening in master only for now.

(cherry picked from commit fde0a5b628)
2019-08-09 01:00:47 +02:00
Alexis Christoforides a9658665bf [2019-08] [System] Guard against attempting to creating out-of-range spans in m… (#16124)
* [System] Guard against attempting to creating out-of-range spans in macOS FileSystemWatcher

Backport of #16049
2019-08-09 00:16:37 +02:00
Alexander Köplinger 4fd89f9b11 [tests] Fix accessing field of MarshalByRefObject in remoting1.cs (#16119)
We need to copy it to a local variable first.
This was exposed by a new Roslyn optimization for String.Concat (see https://github.com/dotnet/roslyn/issues/37830).

(cherry picked from commit ec35e14636)
2019-08-09 00:13:22 +02:00
monojenkins 0707345b89 [2019-08] Fixed RuntimeType.GetConstructorCandidates("") to return 0 elements. (#16109)
* Fixed RuntimeType.GetConstructorCandidates("") to return 0 elements.

https://github.com/mono/mono/issues/16010

The current behavior for GetConstructorCandidates when the name is null, "",
or "*" is to return the set of constructors for the type. For "", .NET Core and
.NET Framework return 0 elements.  This PR adds a check for "" to match that
behavior.

* Removed unncessary changes

* Unnecessary spaces

* Made the if check a bit more readable

Backport of #16054.
2019-08-08 16:49:04 +02:00
monojenkins 0bb83d064d [2019-08] Bump linker (#16088)
* Bump linker

* Bump api-doc-tools and add NEW_CECIL define to mdoc

* Bump linker

* Bump API snapshot submodule

* [csproj] Update project files
2019-08-08 12:12:33 +02:00
monojenkins 3115d3a0c0 [2019-08] [arm] respect I1 and I2 on gsharedvt out transition (#16081)
* [arm] respect I1 and I2 on gsharedvt out transition

In order to trigger the problem, we must call into gsharedvt code ("in" transition) and then escape the gsharedvt world ("out" transition). The bug happens in the latter. Also some other stars need to align (I haven't fully understood it), thus the repro is quite long.

The provided repro only triggers with LLVM, which we don't have enabled on CI yet: https://github.com/mono/mono/issues/15999

Fixes https://github.com/mono/mono/issues/15261
Fixes https://github.com/mono/mono/issues/15262
Fixes https://github.com/mono/mono/issues/15263
Fixes https://github.com/mono/mono/issues/15307

* fix it on amd64 too

* more amd64
2019-08-07 12:43:11 +02:00
Thays Grazia 8c27e2adf9 allow emitting DIM 2019-08-07 09:26:13 +02:00
Aleksey Kliger f8e9a15ed7 [w32socket] Translate ELOOP and ENAMETOOLONG
Translate to WSAELOOP and WSAENAMETOOLONG, respectively.

See https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
2019-08-07 09:23:30 +02:00
monojenkins d1bd30f22d [2019-08] Bump api-doc-tools to latest master (#16050)
* Bump api-doc-tools to latest master

Disable building mdoc.exe in mcs mode since it no longer builds because of new C# features.

* Fix mcs build by disabling more mdoc invocations

* Bump monodroid_tools to compile against v4.7 reference assemblies

mdoc needs ValueTuple which is not in v4.6.

Backport of #16035.
2019-08-06 20:19:27 +02:00
monojenkins 1c57af4dc0 [2019-08] DeflateStream: check IsInvalid before disposing (#16053)
Backport of #16048.
2019-08-06 14:54:56 +02:00
Jo Shields 85cecac278 Bump version to 6.6 (#16029)
* Bump version to 6.6
2019-08-05 15:31:59 -04:00
332 changed files with 7764 additions and 6228 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
{
"name": "roslyn",
"url": "git://github.com/mono/roslyn.git",
"rev": "7a840bd5697ef6ea41f554a09d837636fba9d88d",
"rev": "6bfcd4e770609a38b8523e83ce1ec943162f30bb",
"remote-branch": "origin/mono-testing",
"branch": "mono-testing",
"directory": "roslyn"
+60 -18
View File
@@ -574,6 +574,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ilasm", "mcs/ilasm/ilasm.cs
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "al", "mcs/tools/al/al.csproj", "{0A20671F-CCA9-457D-886C-0828C7D64128}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aprofutil", "mcs/tools/aprofutil/aprofutil.csproj", "{658B566B-CED1-4C42-9926-C1AA930BA368}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "monolinker", "mcs/tools/linker/monolinker.csproj", "{D60432F1-3C12-4235-A1CC-4CA5575403BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "culevel", "mcs/tools/culevel/culevel.csproj", "{E8E246BD-CD0C-4734-A3C2-7F44796EC47B}"
@@ -4012,24 +4014,42 @@ Global
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|net_4_x.Build.0 = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|net_4_x.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|net_4_x.Build.0 = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monodroid.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monodroid.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch_tv.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch_tv.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch_watch.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch_watch.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|orbis.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|orbis.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|unreal.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|unreal.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|wasm.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|wasm.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|winaot.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|winaot.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|xammac.ActiveCfg = Debug|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|xammac.ActiveCfg = Release|net_4_x
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monodroid.ActiveCfg = Debug|monodroid
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monodroid.Build.0 = Debug|monodroid
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monodroid.ActiveCfg = Release|monodroid
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monodroid.Build.0 = Release|monodroid
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch.ActiveCfg = Debug|monotouch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch.Build.0 = Debug|monotouch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch.ActiveCfg = Release|monotouch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch.Build.0 = Release|monotouch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch_tv.ActiveCfg = Debug|monotouch_tv
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch_tv.Build.0 = Debug|monotouch_tv
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch_tv.ActiveCfg = Release|monotouch_tv
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch_tv.Build.0 = Release|monotouch_tv
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch_watch.ActiveCfg = Debug|monotouch_watch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|monotouch_watch.Build.0 = Debug|monotouch_watch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch_watch.ActiveCfg = Release|monotouch_watch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|monotouch_watch.Build.0 = Release|monotouch_watch
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|orbis.ActiveCfg = Debug|orbis
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|orbis.Build.0 = Debug|orbis
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|orbis.ActiveCfg = Release|orbis
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|orbis.Build.0 = Release|orbis
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|unreal.ActiveCfg = Debug|unreal
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|unreal.Build.0 = Debug|unreal
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|unreal.ActiveCfg = Release|unreal
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|unreal.Build.0 = Release|unreal
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|wasm.ActiveCfg = Debug|wasm
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|wasm.Build.0 = Debug|wasm
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|wasm.ActiveCfg = Release|wasm
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|wasm.Build.0 = Release|wasm
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|winaot.ActiveCfg = Debug|winaot
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|winaot.Build.0 = Debug|winaot
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|winaot.ActiveCfg = Release|winaot
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|winaot.Build.0 = Release|winaot
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|xammac.ActiveCfg = Debug|xammac
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Debug|xammac.Build.0 = Debug|xammac
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|xammac.ActiveCfg = Release|xammac
{AC3AC4DA-7C10-4AE9-A131-6DBBE61432E3}.Release|xammac.Build.0 = Release|xammac
{7C660E7A-C89B-4ACA-9458-492B6D14B168}.Debug|net_4_x.ActiveCfg = Debug|net_4_x
{7C660E7A-C89B-4ACA-9458-492B6D14B168}.Debug|net_4_x.Build.0 = Debug|net_4_x
{7C660E7A-C89B-4ACA-9458-492B6D14B168}.Release|net_4_x.ActiveCfg = Release|net_4_x
@@ -10100,6 +10120,28 @@ Global
{0A20671F-CCA9-457D-886C-0828C7D64128}.Release|winaot.ActiveCfg = Release|net_4_x
{0A20671F-CCA9-457D-886C-0828C7D64128}.Debug|xammac.ActiveCfg = Debug|net_4_x
{0A20671F-CCA9-457D-886C-0828C7D64128}.Release|xammac.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|net_4_x.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|net_4_x.Build.0 = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|net_4_x.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|net_4_x.Build.0 = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monodroid.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monodroid.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monotouch.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monotouch.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monotouch_tv.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monotouch_tv.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|monotouch_watch.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|monotouch_watch.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|orbis.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|orbis.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|unreal.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|unreal.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|wasm.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|wasm.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|winaot.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|winaot.ActiveCfg = Release|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Debug|xammac.ActiveCfg = Debug|net_4_x
{658B566B-CED1-4C42-9926-C1AA930BA368}.Release|xammac.ActiveCfg = Release|net_4_x
{D60432F1-3C12-4235-A1CC-4CA5575403BD}.Debug|net_4_x.ActiveCfg = Debug|net_4_x
{D60432F1-3C12-4235-A1CC-4CA5575403BD}.Debug|net_4_x.Build.0 = Debug|net_4_x
{D60432F1-3C12-4235-A1CC-4CA5575403BD}.Release|net_4_x.ActiveCfg = Release|net_4_x
+58 -56
View File
@@ -4,7 +4,7 @@
# This line is parsed by tools besides autoconf, such as msvc/mono.winconfig.targets.
# It should remain in the format they expect.
#
AC_INIT(mono, [6.5.0],
AC_INIT(mono, [6.6.0],
[https://github.com/mono/mono/issues/new])
AC_CONFIG_SRCDIR([README.md])
@@ -62,7 +62,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
# This line is parsed by tools besides autoconf, such as msvc/mono.winconfig.targets.
# It should remain in the format they expect.
#
MONO_CORLIB_VERSION=2cfaeda3-94a9-44e5-8fcb-51979a3398c9
MONO_CORLIB_VERSION=A144A63D-652C-4CCF-A9EE-8E5A091547F1
#
# Put a quoted #define in config.h.
@@ -692,12 +692,12 @@ AC_CHECK_HEADERS(linux/serial.h)
case "$host" in
# Use bundled zlib on Windows to be sure it is static.
*-mingw*|*-cygwin*)
have_zlib=no
have_sys_zlib=no
zlib_msg="bundled zlib"
;;
default)
AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
if test x$have_zlib = xyes; then
*)
AC_CHECK_HEADER(zlib.h, [have_sys_zlib=yes], [have_sys_zlib=no])
if test x$have_sys_zlib = xyes; then
AC_TRY_COMPILE([#include <zlib.h>], [
#if defined(ZLIB_VERNUM) && (ZLIB_VERNUM >= 0x1230)
#else
@@ -706,12 +706,16 @@ case "$host" in
],[
AC_MSG_RESULT(Using system zlib)
zlib_msg="system zlib"
AC_DEFINE(HAVE_SYS_ZLIB,1,[Have system zlib])
have_sys_zlib=yes
],[
AC_MSG_RESULT(Using embedded zlib)
have_zlib=no
AC_MSG_RESULT(zlib too old, using embedded zlib)
have_sys_zlib=no
zlib_msg="bundled zlib"
])
else
AC_MSG_RESULT(zlib not found, using embedded zlib)
have_sys_zlib=no
zlib_msg="bundled zlib"
fi
;;
esac
@@ -719,13 +723,19 @@ esac
AC_ARG_WITH(static-zlib, [ --with-static-zlib=PATH use the specified static zlib instead of -lz],[STATIC_ZLIB_PATH=$with_static_zlib],[STATIC_ZLIB_PATH=])
if test "x$STATIC_ZLIB_PATH" != "x"; then
have_static_zlib=yes
have_sys_zlib=no
zlib_msg="static zlib from $STATIC_ZLIB_PATH"
AC_SUBST(STATIC_ZLIB_PATH)
fi
AM_CONDITIONAL(HAVE_STATIC_ZLIB, test x$have_static_zlib = xyes)
AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes)
AC_DEFINE(HAVE_ZLIB,1,[Have system zlib])
AM_CONDITIONAL(HAVE_SYS_ZLIB, test x$have_sys_zlib = xyes)
if test x$have_static_zlib = xyes; then
AC_DEFINE(HAVE_STATIC_ZLIB, 1, [Use static zlib])
fi
if test x$have_sys_zlib = xyes; then
AC_DEFINE(HAVE_SYS_ZLIB, 1, [Use OS-provided zlib])
fi
# for mono/metadata/debug-symfile.c
AC_CHECK_HEADERS(elf.h)
@@ -1324,10 +1334,9 @@ with_wasm_default=no
with_bitcode_default=no
enable_cooperative_suspend_default=no
enable_hybrid_suspend_default=no
enable_copy_stack_data_default=yes
# For the sake of clearer error messages, these numbers should all be different from each other.
INVARIANT_AOT_OPTIONS=nimt-trampolines=2000,ntrampolines=10000,nrgctx-fetch-trampolines=256,ngsharedvt-trampolines=4400,nftnptr-arg-trampolines=4000
INVARIANT_AOT_OPTIONS=nimt-trampolines=2000,ntrampolines=10000,nrgctx-fetch-trampolines=256,ngsharedvt-trampolines=4400,nftnptr-arg-trampolines=4000,nrgctx-trampolines=21000
AOT_BUILD_ATTRS=$INVARIANT_AOT_OPTIONS
@@ -3382,13 +3391,29 @@ if test x$host_win32 = xno; then
AC_CHECK_DECL(ICANON, [AC_DEFINE(HAVE_ICANON, 1, [ICANON])], [], [[#include <termios.h>]])
AC_CHECK_DECL(TCSANOW, [AC_DEFINE(HAVE_TCSANOW, 1, [TCSANOW])], [], [[#include <termios.h>]])
AC_CHECK_MEMBER(struct stat.st_birthtimespec, [AC_DEFINE(HAVE_STAT_BIRTHTIME, 1, [struct stat.st_birthtime])], [], [[#include <sys/types.h>], [#include <sys/stat.h>]])
AC_CHECK_MEMBER(struct stat.st_atimespec, [AC_DEFINE(HAVE_STAT_TIMESPEC, 1, [struct stat.st_atimespec])], [], [[#include <sys/types.h>], [#include <sys/stat.h>]])
AC_CHECK_MEMBER(struct stat.st_atim, [AC_DEFINE(HAVE_STAT_TIM, 1, [struct stat.st_atim])], [], [[#include <sys/types.h>], [#include <sys/stat.h>]])
AC_CHECK_MEMBER(struct stat.st_atimensec, [AC_DEFINE(HAVE_STAT_NSEC, 1, [struct stat.st_atimensec])], [], [[#include <sys/types.h>], [#include <sys/stat.h>]])
AC_CHECK_MEMBER(struct dirent.d_namlen, [AC_DEFINE(HAVE_DIRENT_NAME_LEN, 1, [struct dirent.d_namlen])], [], [[#include <dirent.h>]])
AC_CHECK_MEMBER(struct statfs.f_fstypename, [AC_DEFINE(HAVE_STATFS_FSTYPENAME, 1, [struct statfs.f_fstypename])], [], [[#include <sys/mount.h>]])
AC_CHECK_MEMBER(struct statvfs.f_fstypename, [AC_DEFINE(HAVE_STATVFS_FSTYPENAME, 1, [struct statvfs.f_fstypename])], [], [[#include <sys/mount.h>]])
AC_CHECK_MEMBER(struct stat.st_birthtimespec,
[AC_DEFINE(HAVE_STAT_BIRTHTIME, 1, [struct stat.st_birthtimespec])],
[],
[#include <sys/types.h>
#include <sys/stat.h>])
AC_CHECK_MEMBER(struct stat.st_atimespec,
[AC_DEFINE(HAVE_STAT_TIMESPEC, 1, [struct stat.st_atimespec])],
[],
[#include <sys/types.h>
#include <sys/stat.h>])
AC_CHECK_MEMBER(struct stat.st_atim,
[AC_DEFINE(HAVE_STAT_TIM, 1, [struct stat.st_atim])],
[],
[#include <sys/types.h>
#include <sys/stat.h>])
AC_CHECK_MEMBER(struct stat.st_atimensec,
[AC_DEFINE(HAVE_STAT_NSEC, 1, [struct stat.st_atimensec])],
[],
[#include <sys/types.h>
#include <sys/stat.h>])
AC_CHECK_MEMBER(struct dirent.d_namlen, [AC_DEFINE(HAVE_DIRENT_NAME_LEN, 1, [struct dirent.d_namlen])], [], [#include <dirent.h>])
AC_CHECK_MEMBER(struct statfs.f_fstypename, [AC_DEFINE(HAVE_STATFS_FSTYPENAME, 1, [struct statfs.f_fstypename])], [], [#include <sys/mount.h>])
AC_CHECK_MEMBER(struct statvfs.f_fstypename, [AC_DEFINE(HAVE_STATVFS_FSTYPENAME, 1, [struct statvfs.f_fstypename])], [], [#include <sys/mount.h>])
AC_MSG_CHECKING(for struct statfs)
AC_TRY_COMPILE([
@@ -3753,6 +3778,7 @@ if test x$host_win32 = xno; then
AC_DEFINE(HAVE_GSSFW_HEADERS, 1, [GSS/GSS.h])
AC_DEFINE(HAVE_GSS_SPNEGO_MECHANISM, 1, [GSS_SPNEGO_MECHANISM])
enable_gss=yes
AC_DEFINE(ENABLE_GSS, 1, [ENABLE_GSS])
], [
AC_MSG_RESULT(no)
])
@@ -3764,6 +3790,7 @@ if test x$host_win32 = xno; then
],[
AC_MSG_RESULT(yes)
enable_gss=yes
AC_DEFINE(ENABLE_GSS, 1, [ENABLE_GSS])
], [
AC_MSG_RESULT(no)
])
@@ -4597,6 +4624,7 @@ if test "x$host" != "x$target"; then
aarch64*darwin*_ilp32)
TARGET=ARM6432;
AC_DEFINE(MONO_ARCH_ILP32, 1, [64 bit mode with 4 byte longs and pointers])
sizeof_register=8
AC_DEFINE(TARGET_WATCHOS, 1, [...])
;;
aarch64-*)
@@ -5647,38 +5675,6 @@ AM_CONDITIONAL([ENABLE_HYBRID_SUSPEND], [test x$enable_hybrid_suspend != xno])
dnl End of thread suspend policy
dnl *******************************
dnl *** Copy stack data support ***
dnl *******************************
dnl Disable copy_stack_data on platforms supporting full context and
dnl having access to full stack of running threads.
if test x$enable_copy_stack_data_default != xno; then
case $HOST in
X86 | AMD64)
if test x$target_osx = xyes; then
dnl Some host/target confusion, there's no host_osx (and
dnl host_darwin would be true on iOS not just macOS).
enable_copy_stack_data_default=no
elif test x$host_linux = xyes -o x$host_win32 = xyes; then
enable_copy_stack_data_default=no
fi
;;
esac
fi
AC_ARG_ENABLE(copy_stack_data, [ --enable-copy-stack-data Enable copy_stack_data feature for hybrid/cooperative suspend scenarios, (defaults to yes)], [], [enable_copy_stack_data=default])
if test x$enable_copy_stack_data = xdefault; then
enable_copy_stack_data=$enable_copy_stack_data_default
fi
if test x$enable_copy_stack_data != xno ; then
AC_DEFINE(ENABLE_COPY_STACK_DATA,1,[Enable copy_stack_data feature for hybrid/cooperative suspend scenarios])
fi
dnl End of Copy stack data support
dnl ***************************
dnl *** feature experiments ***
dnl ***************************
@@ -6030,8 +6026,8 @@ fi
AC_SUBST(mono_runtime)
AC_SUBST(mono_runtime_wrapper)
CSC_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.1.0-release/csc.exe
VBCS_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.1.0-release/VBCSCompiler.exe
CSC_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.4.0/csc.exe
VBCS_LOCATION=`cd $srcdir && pwd`/external/roslyn-binaries/Microsoft.Net.Compilers/3.4.0/VBCSCompiler.exe
if test $csc_compiler = mcs; then
CSC=$mcs_topdir/class/lib/build/mcs.exe
@@ -6068,6 +6064,7 @@ AC_CONFIG_FILES([po/mcs/Makefile.in])
AC_CONFIG_FILES([acceptance-tests/microbench-perf.sh],[chmod +x acceptance-tests/microbench-perf.sh])
AC_CONFIG_FILES([runtime/mono-wrapper],[chmod +x runtime/mono-wrapper])
AC_CONFIG_FILES([runtime/monodis-wrapper],[chmod +x runtime/monodis-wrapper])
AC_CONFIG_FILES([runtime/bin/mono-hang-watchdog],[chmod +x runtime/bin/mono-hang-watchdog])
AC_CONFIG_COMMANDS([runtime/etc/mono/1.0/machine.config],
[ depth=../../../..
@@ -6396,7 +6393,11 @@ elif test x$host_linux = xyes; then
MONO_NATIVE_CXXFLAGS=$CXXFLAGS
MONO_NATIVE_CFLAGS=$CFLAGS
MONO_NATIVE_LDFLAGS=$LDFLAGS
if test x$enable_gss = xyes; then
MONO_NATIVE_LDFLAGS="$MONO_NATIVE_LDFLAGS -lgssapi_krb5"
else
AC_MSG_WARN([GSS is not enabled, it requires libkrb5-dev package])
fi
mono_native=yes
mono_native_compat=no
MONO_NATIVE_PLATFORM=linux
@@ -6722,6 +6723,7 @@ tools/Makefile
tools/locale-builder/Makefile
tools/sgen/Makefile
tools/pedump/Makefile
tools/mono-hang-watchdog/Makefile
runtime/Makefile
msvc/Makefile
po/Makefile
+23
View File
@@ -18,6 +18,27 @@ convert.exe: $(srcdir)/convert.cs AgilityPack.dll
AgilityPack.dll:
$(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Xml.dll -target:library -out:$@ $(srcdir)/HtmlAgilityPack/*.cs
ifdef MCS_MODE
monoapi.zip:
touch $@
monoapi.tree: monoapi.zip
touch $@
mono-tools.zip:
touch $@
mono-tools.tree: mono-tools.zip
touch $@
mono-file-formats.zip:
touch $@
mono-file-formats.tree: mono-file-formats.zip
touch $@
else
monoapi.zip: monoapi.tree
@test -f $@ || { rm -f $< && $(MAKE) $<; }
@@ -36,5 +57,7 @@ mono-file-formats.zip: mono-file-formats.tree
mono-file-formats.tree: $(srcdir)/mono-file-formats.config $(srcdir)/docs.make
$(MDOC) assemble -o mono-file-formats -f man $<
endif
.doc-stamp:
+1 -1
+1 -1
+1 -1
+1 -1
+1 -1
View File
@@ -12,7 +12,7 @@ endif
if HAVE_STATIC_ZLIB
llvm_extra_libs = $(STATIC_ZLIB_PATH)
else
if HAVE_ZLIB
if HAVE_SYS_ZLIB
llvm_extra_libs=-lz
else
llvm_extra_libs=
+1
View File
@@ -1,5 +1,6 @@
man_MANS = \
al.1 \
aprofutil.1 \
cert2spc.1 \
certmgr.1 \
cert-sync.1 \
+91
View File
@@ -0,0 +1,91 @@
.TH aprofutil 1
.SH NAME
aprofutil \- Mono's AOT profile tool
.SH SYNOPSIS
.B aprofutil
\fR[\fIoptions\fR] <\fIyour-aot-profile.aotprofile\fR>
.SH DESCRIPTION
AOT profile tool is a tool to inspect AOT profiler files.
.PP
It can be used to show, filter and write the profiler file content in readable text form.
.SH OPTIONS
.nf
.RS
-h, --help, -? Show this message and exit
-a, --all Show modules, types and methods in the profile
-d, --modules Show modules in the profile
--filter-method=VALUE Filter by method with regex VALUE
--filter-module=VALUE Filter by module with regex VALUE
--filter-type=VALUE Filter by type with regex VALUE
-m, --methods Show methods in the profile
-o, --output=VALUE Write profile to OUTPUT file
-s, --summary Show summary of the profile
-t, --types Show types in the profile
-v, --verbose Output information about progress during the run
of the tool
.RE
.fi
.SH EXAMPLES
Display modules and summary of XA startup profile
.PP
.nf
.RS
mono aprofutil.exe -sd startup.aotprofile
.fi
.RE
.PP
Output:
.PP
.nf
.RS
Modules:
41C38B0A-2032-45CE-8638-0299CED65330 mscorlib
0326DF03-2158-4F7A-9A2B-B7A9419F021D Mono.Android
8FB63BB4-1195-4173-A9ED-0EC341B07C32 System
74C06E06-C1C7-4A4C-B64E-EAC7DBB08BBC Java.Interop
11E2319F-6A26-461C-9C46-C972248BEE4B System.Core
7999CC4B-D566-4ECA-8A72-469344172CA3 Xamarin.Forms.Platform.Android
C5089213-328B-451D-BA87-D6585C120780 Xamarin.Forms.Performance.Integration.Droid
D754F8AE-503C-41C8-B16F-647FC662507A Xamarin.Android.Support.v7.AppCompat
929ECB6D-1171-4C66-8470-DD32AC608969 Xamarin.Android.Support.Fragment
F841E23B-59A8-4AE2-9A84-D2FC1D891B4A Xamarin.Forms.Core
945CCBF8-C2DB-468B-B3BD-D7ACA37B69AD Xamarin.Forms.Performance.Integration
AF20FA19-F07E-4BD4-B5ED-104706EA660E Xamarin.Forms.Xaml
629C84F8-0988-42EF-8BC5-872173A0A71F FormsViewGroup
60398815-8E62-487E-A553-781F56A0849D Xamarin.Android.Support.Design
F0C550D7-665A-40B5-A307-8E9B49976D87 Xamarin.Android.Support.Core.UI
23A34485-DE75-440E-BA9D-E235F664E990 Xamarin.Android.Support.Compat
Summary:
Modules: 16
Types: 907
Methods: 4,230
.fi
.RE
.PP
Filter Java.Interop.Runtime type in XA startup profile
.PP
.nf
.RS
mono aprofutil.exe --filter-type Java.Interop.Runtime -sa startup.aotprofile
.fi
.RE
.PP
Output:
.PP
.nf
.RS
Modules:
0326DF03-2158-4F7A-9A2B-B7A9419F021D Mono.Android
Types:
Java.Interop.Runtime
Methods:
bool Java.Interop.Runtime:IsGCUserPeer (Android.Runtime.IJavaObject)
bool Java.Interop.Runtime:IsGCUserPeer (intptr)
Summary:
Modules: 1 (of 16)
Types: 1 (of 907)
Methods: 2 (of 4230)
.fi
.RE
.SH SEE ALSO
\fBmono-profilers\fR(1)
+20 -17
View File
@@ -1179,23 +1179,26 @@ If set, tells mono to attempt using native asynchronous I/O services. If not
set, a default select/poll implementation is used. Currently epoll and kqueue
are supported.
.TP
\fBMONO_THREADS_SUSPEND\fR
Selects a mechanism that Mono will use to suspend threads. May be set to
"preemptive", "coop", or "hybrid". Threads may need to be suspended by the
debugger, or using some .NET threading APIs, and most commonly when the SGen
garbage collector needs to stop all threads during a critical phase of garbage
collection. Preemptive mode is the mode that Mono has used historically, going
back to the Boehm days, where the garbage collector would run at any point and
suspend execution of all threads as required to perform a garbage collection.
The cooperative mode on the other hand requires the cooperation of all threads
to stop at a safe point. This makes for an easier to debug garbage collector.
As of Mono 4.3.0 it is a work in progress, and while it works, it has not been
used extensively. This option enables the feature and allows us to find spots
that need to be tuned for this mode of operation. Hybrid mode is a combination
of the two that retains better compatability with scenarios where Mono is
embedded in another application: threads that are running managed code or code
that comprises the Mono runtime will be cooperatively suspended, while threads
running embedder code will be preemptively suspended.
\fBMONO_THREADS_SUSPEND\fR Selects a mechanism that Mono will use to suspend
threads. May be set to "preemptive", "coop", or "hybrid". Threads may need to
be suspended by the debugger, or using some .NET threading APIs, and most
commonly when the SGen garbage collector needs to stop all threads during a
critical phase of garbage collection. Preemptive mode is the mode that Mono
has used historically, going back to the Boehm days, where the garbage
collector would run at any point and suspend execution of all threads as
required to perform a garbage collection. The cooperative mode on the other
hand requires the cooperation of all threads to stop at a safe point. This
makes for an easier to debug garbage collector and it improves the stability of
the runtime because threads are not suspended when accessing critical
resources. In scenarios where Mono is embedded in another application,
cooperative suspend requires the embedder code to follow coding guidelines in
order to cooperate with the garbage collector. Cooperative suspend in embedded
Mono is currently experimental. Hybrid mode is a combination of the two that
retains better compatability with scenarios where Mono is embedded in another
application: threads that are running managed code or code that comprises the
Mono runtime will be cooperatively suspended, while threads running embedder
code will be preemptively suspended. Hybrid suspend is the default on some
desktop platforms.
Alternatively, coop and hybrid mode can be enabled at compile time by using the
--enable-cooperative-suspend or --enable-hybrid-suspend flags, respectively,
+1
View File
@@ -38,5 +38,6 @@ NO_CONSOLE = yes
ifdef PLATFORM_WIN32
PROFILE_MCS_FLAGS += -d:MOBILE_DESKTOP_HOST -d:WIN_PLATFORM
endif
ENABLE_GSS=1
PROFILE_TEST_HARNESS_EXCLUDES = MobileNotWorking PKITS InetAccess AndroidNotWorking
+1 -1
View File
@@ -8,7 +8,7 @@ MCS = $(BOOTSTRAP_MCS)
profile-check:
@:
TARGET_NET_REFERENCE = v4.6
TARGET_NET_REFERENCE = v4.7
DEFAULT_REFERENCES = mscorlib
PROFILE_MCS_FLAGS = -d:NET_4_6 -d:MONO -d:MONODROID_TOOLS -d:WIN_PLATFORM -nowarn:1699 -nostdlib $(PLATFORM_DEBUG_FLAGS)
+4
View File
@@ -25,3 +25,7 @@ ifdef PLATFORM_MACOS
MONO_FEATURE_APPLETLS=1
ENABLE_GSS=1
endif
ifeq ($(HOST_PLATFORM),linux)
ENABLE_GSS=1
endif
+1 -3
View File
@@ -128,7 +128,7 @@ $(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
@if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
$(topdir)/build/deps/nunit-$(PROFILE).stamp:
cd ${topdir}/tools/nunit-lite && $(MAKE)
$(MAKE) -C ${topdir}/tools/nunit-lite
echo "stamp" >$@
tests_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
@@ -378,5 +378,3 @@ $(xtest_makefrag): $(xtest_response)
endif
.PHONY: patch-nunitlite-appconfig
+1 -1
View File
@@ -38,7 +38,7 @@ doc-update-recursive:
@echo "do not recurse the Facades folder"
System System.Core System.ComponentModel.DataAnnotations System.Numerics System.Numerics.Vectors System.Runtime.Serialization System.Transactions System.Xml \
System.ComponentModel.Composition System.ServiceModel System.Xml.Linq System.Data System.IO.Compression.FileSystem System.Runtime.InteropServices.RuntimeInformation \
System.ComponentModel.Composition System.ServiceModel System.Xml.Linq System.Data System.Data.DataSetExtensions System.IO.Compression.FileSystem System.Runtime.InteropServices.RuntimeInformation \
System.ServiceProcess System.Security System.Net.Http.WebRequest System.Net.Http System.ServiceProcess System.IO.Compression System.IdentityModel System.Web \
Facades/System.Drawing.Primitives Facades/System.Drawing.Common System.Drawing System.Web.Services:
@@ -29,72 +29,72 @@
<PropertyGroup Condition=" '$(Platform)' == 'monodroid' ">
<OutputPath>./../../../class/lib/monodroid/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;MONODROID;ANDROID</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;MONODROID;ANDROID;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch' ">
<OutputPath>./../../../class/lib/monotouch/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch_watch' ">
<OutputPath>./../../../class/lib/monotouch_watch/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch_tv' ">
<OutputPath>./../../../class/lib/monotouch_tv/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;MONOTOUCH_TV</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;MONOTOUCH_TV;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_full_interp' ">
<OutputPath>./../../../class/lib/testing_aot_full_interp/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;FULL_AOT_INTERP;DISABLE_COM</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;FULL_AOT_INTERP;DISABLE_COM;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_hybrid' ">
<OutputPath>./../../../class/lib/testing_aot_hybrid/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;MOBILE_DYNAMIC</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;MOBILE_DYNAMIC;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_full' ">
<OutputPath>./../../../class/lib/testing_aot_full/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_COM</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_COM;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'winaot' ">
<OutputPath>./../../../class/lib/winaot/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_COM;WIN_PLATFORM;WINAOT;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_COM;WIN_PLATFORM;WINAOT;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_winaot_interp' ">
<OutputPath>./../../../class/lib/testing_winaot_interp/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_COM;WIN_PLATFORM;WINAOT;FULL_AOT_INTERP;DISABLE_SECURITY;DISABLE_REMOTING</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_COM;WIN_PLATFORM;WINAOT;FULL_AOT_INTERP;DISABLE_SECURITY;DISABLE_REMOTING;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'xammac' ">
<OutputPath>./../../../class/lib/xammac/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_DYNAMIC;XAMMAC;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;XAMARIN_MODERN</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_DYNAMIC;XAMMAC;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;XAMARIN_MODERN;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'xammac_net_4_5' ">
<OutputPath>./../../../class/lib/xammac_net_4_5/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;NO_SYSTEM_DRAWING_DEPENDENCY;NO_WINFORMS_DEPENDENCY;NO_SYSTEM_WEB_DEPENDENCY;XAMMAC_4_5;XAMARIN_MODERN</DefineConstants>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;NO_SYSTEM_DRAWING_DEPENDENCY;NO_WINFORMS_DEPENDENCY;NO_SYSTEM_WEB_DEPENDENCY;XAMMAC_4_5;XAMARIN_MODERN;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'orbis' ">
<OutputPath>./../../../class/lib/orbis/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;ORBIS;DISABLE_COM</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;ORBIS;DISABLE_COM;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'unreal' ">
<OutputPath>./../../../class/lib/unreal/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;MOBILE;MOBILE_DYNAMIC;NET_3_5;NET_4_0;NET_4_5;MONO</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;MOBILE;MOBILE_DYNAMIC;NET_3_5;NET_4_0;NET_4_5;MONO;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'wasm' ">
<OutputPath>./../../../class/lib/wasm/Facades</OutputPath>
<IntermediateOutputPath>./../../../class/obj/$(AssemblyName)-Facades</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;WASM;DISABLE_COM;FEATURE_NO_BSD_SOCKETS;DISABLE_REMOTING;DISABLE_SECURITY</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;WASM;DISABLE_COM;FEATURE_NO_BSD_SOCKETS;DISABLE_REMOTING;DISABLE_SECURITY;FEATURE_TYPECONVERTER</DefineConstants>
</PropertyGroup>
<!-- @ALL_PROFILE_PROPERTIES@ -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@@ -13,7 +13,7 @@ KEYFILE = ../../Open.snk
LIBRARY_SNK = $(KEYFILE)
SIGN_FLAGS = /delaysign /nowarn:1616,1699
LIB_REFS = System
LIB_MCS_FLAGS = $(SIGN_FLAGS) $(EXTRA_LIB_MCS_FLAGS)
LIB_MCS_FLAGS = $(SIGN_FLAGS) $(EXTRA_LIB_MCS_FLAGS) -d:FEATURE_TYPECONVERTER
ifneq (,$(filter build net_4_x, $(PROFILE)))
$(error This profile shouldn't build System.Drawing.Common.dll, it already has System.Drawing.dll)
@@ -175,6 +175,7 @@
<ProjectReference Include="../../System.Transactions/System.Transactions.csproj" />
<ProjectReference Include="../../System.Runtime.Serialization/System.Runtime.Serialization.csproj" />
<ProjectReference Include="../../System.Data/System.Data.csproj" />
<ProjectReference Include="../../System.Data.DataSetExtensions/System.Data.DataSetExtensions.csproj" />
<ProjectReference Include="../../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'net_4_x' ">
+4 -4
View File
@@ -22,13 +22,13 @@ ifeq ($(PROFILE),build)
LIB_MCS_FLAGS += -d:SYSTEM_WEB_IMPLEMENTATION
else ifeq ($(PROFILE),wasm)
LIB_MCS_FLAGS += -d:SYSTEM_WEB_IMPLEMENTATION -unsafe
LIB_REFS += System.Transactions System.Runtime.Serialization System.Data
LIB_REFS += System.Transactions System.Runtime.Serialization System.Data System.Data.DataSetExtensions
else ifeq ($(PROFILE),xammac_net_4_5)
LIB_REFS += System.Web.Services System.Transactions System.Runtime.Serialization System.Data
LIB_REFS += System.Web.Services System.Transactions System.Runtime.Serialization System.Data System.Data.DataSetExtensions
else ifeq (2.1, $(FRAMEWORK_VERSION))
LIB_REFS += System.Web.Services System.Transactions System.Runtime.Serialization System.Data
LIB_REFS += System.Web.Services System.Transactions System.Runtime.Serialization System.Data System.Data.DataSetExtensions
else
LIB_REFS += System.Web System.Transactions System.Runtime.Serialization System.Data
LIB_REFS += System.Web System.Transactions System.Runtime.Serialization System.Data System.Data.DataSetExtensions
endif
ifneq (,$(filter build net_4_x, $(PROFILE)))
@@ -764,6 +764,16 @@
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.SqlTypes.SqlTypeException))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.SqlTypes.SqlXml))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.SqlTypes.StorageState))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.DataRowComparer))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.DataRowComparer<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.DataRowExtensions))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.DataTableExtensions))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.EnumerableRowCollection))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.EnumerableRowCollection<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.EnumerableRowCollectionExtensions))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.OrderedEnumerableRowCollection<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.TypedTableBase<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Data.TypedTableBaseExtensions))]
#endif
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.BooleanSwitch))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.ConditionalAttribute))]
@@ -821,6 +831,15 @@
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.TraceSwitch))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.SuppressMessageAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.AllowNullAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.DisallowNullAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.MaybeNullAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.NotNullAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.NotNullWhenAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Contracts.Contract))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Contracts.ContractAbbreviatorAttribute))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Diagnostics.Contracts.ContractArgumentValidatorAttribute))]
@@ -2443,6 +2462,9 @@
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ReadOnlySpanAction<,>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ReadOnlySequence<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ReadOnlySequenceSegment<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.ArrayBufferWriter<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.SequenceReader<>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.SequenceReaderExtensions))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.SpanAction<,>))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.StandardFormat))]
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Buffers.Binary.BinaryPrimitives))]
@@ -111,19 +111,19 @@
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Xml.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Xml.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Xml.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
+3
View File
@@ -77,6 +77,7 @@ mobile_common_dirs_parallel := \
System.Numerics \
System.Numerics.Vectors \
System.Data \
System.Data.DataSetExtensions \
Mono.Data.Sqlite \
System.Data.Services.Client \
System.IO.Compression \
@@ -179,6 +180,7 @@ wasm_dirs_parallel := \
System.ServiceModel.Internals \
System.Runtime.Serialization \
System.Data \
System.Data.DataSetExtensions \
System.Xml.Linq \
System.Numerics \
System.Numerics.Vectors \
@@ -213,6 +215,7 @@ xammac_4_5_dirs_parallel := \
System.Transactions \
System.EnterpriseServices \
System.Data \
System.Data.DataSetExtensions \
System.Runtime.Serialization \
System.Xml.Linq \
Mono.Data.Sqlite \
@@ -71,14 +71,14 @@
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
+6 -6
View File
@@ -199,19 +199,19 @@
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Core.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Core.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Core.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
@@ -89,14 +89,14 @@
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
@@ -149,19 +149,19 @@
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Core.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Core.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Core.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
@@ -307,8 +307,15 @@ namespace Mono.Debugger.Soft
public bool Subclasses {
get; set;
}
public bool NotFilteredFeature {
get; set;
}
public bool EverythingElse {
get; set;
}
}
class AssemblyModifier : Modifier {
public long[] Assemblies {
get; set;
@@ -429,7 +436,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
internal const int MINOR_VERSION = 53;
internal const int MINOR_VERSION = 54;
enum WPSuspendPolicy {
NONE = 0,
@@ -1311,6 +1318,8 @@ namespace Mono.Debugger.Soft
protected abstract int TransportSend (byte[] buf, int buf_offset, int len);
protected abstract void TransportSetTimeouts (int send_timeout, int receive_timeout);
protected abstract void TransportClose ();
// Shutdown breaks all communication, resuming blocking waits
protected abstract void TransportShutdown ();
internal VersionInfo Version;
@@ -1427,6 +1436,7 @@ namespace Mono.Debugger.Soft
internal void Close () {
closed = true;
TransportShutdown ();
}
internal bool IsClosed {
@@ -2632,6 +2642,10 @@ namespace Mono.Debugger.Soft
} else if (!em.Subclasses) {
throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
}
if (Version.MajorVersion > 2 || Version.MinorVersion >= 54) {
w.WriteBool (em.NotFilteredFeature);
w.WriteBool (em.EverythingElse);
}
} else if (mod is AssemblyModifier) {
w.WriteByte ((byte)ModifierKind.ASSEMBLY_ONLY);
var amod = (mod as AssemblyModifier);
@@ -2854,6 +2868,11 @@ namespace Mono.Debugger.Soft
{
socket.Close ();
}
protected override void TransportShutdown ()
{
socket.Shutdown (SocketShutdown.Both);
}
}
/* This is the interface exposed by the debugger towards the debugger agent */
@@ -6,9 +6,9 @@ namespace Mono.Debugger.Soft
public sealed class ExceptionEventRequest : EventRequest {
TypeMirror exc_type;
bool caught, uncaught, subclasses;
bool caught, uncaught, subclasses, not_filtered_feature, everything_else;
internal ExceptionEventRequest (VirtualMachine vm, TypeMirror exc_type, bool caught, bool uncaught) : base (vm, EventType.Exception) {
internal ExceptionEventRequest (VirtualMachine vm, TypeMirror exc_type, bool caught, bool uncaught, bool not_filtered_feature = false, bool everything_else = false) : base (vm, EventType.Exception) {
if (exc_type != null) {
CheckMirror (vm, exc_type);
TypeMirror exception_type = vm.RootDomain.Corlib.GetType ("System.Exception", false, false);
@@ -19,6 +19,8 @@ namespace Mono.Debugger.Soft
this.caught = caught;
this.uncaught = uncaught;
this.subclasses = true;
this.not_filtered_feature = not_filtered_feature;
this.everything_else = everything_else;
}
public TypeMirror ExceptionType {
@@ -41,7 +43,7 @@ namespace Mono.Debugger.Soft
public override void Enable () {
var mods = new List <Modifier> ();
mods.Add (new ExceptionModifier () { Type = exc_type != null ? exc_type.Id : 0, Caught = caught, Uncaught = uncaught, Subclasses = subclasses });
mods.Add (new ExceptionModifier () { Type = exc_type != null ? exc_type.Id : 0, Caught = caught, Uncaught = uncaught, Subclasses = subclasses, NotFilteredFeature = not_filtered_feature, EverythingElse = everything_else });
SendReq (mods);
}
}
@@ -150,8 +150,11 @@ namespace Mono.Debugger.Soft
}
public void Detach () {
conn.Close ();
// Notify the application that we are detaching
conn.VM_Dispose ();
// Close the connection. No further messages can be sent
// over the connection after this point.
conn.Close ();
notify_vm_event (EventType.VMDisconnect, SuspendPolicy.None, 0, 0, null, 0);
}
@@ -277,6 +280,13 @@ namespace Mono.Debugger.Soft
return new ExceptionEventRequest (this, exc_type, caught, uncaught);
}
public ExceptionEventRequest CreateExceptionRequest (TypeMirror exc_type, bool caught, bool uncaught, bool everything_else) {
if (Version.AtLeast (2, 54))
return new ExceptionEventRequest (this, exc_type, caught, uncaught, true, everything_else);
else
return new ExceptionEventRequest (this, exc_type, caught, uncaught);
}
public AssemblyLoadEventRequest CreateAssemblyLoadRequest () {
return new AssemblyLoadEventRequest (this);
}
@@ -350,6 +350,17 @@ class TestIfaces : ITest
}
}
public class RuntimeInvokeWithThrowClass
{
public RuntimeInvokeWithThrowClass()
{
}
public void RuntimeInvokeThrowMethod()
{
throw new Exception("thays");
}
}
public sealed class DebuggerTaskScheduler : TaskScheduler, IDisposable
{
private readonly BlockingCollection<Task> _tasks = new BlockingCollection<Task>();
@@ -507,6 +518,10 @@ public class Tests : TestsBase, ITest2
unhandled_exception_wrapper ();
return 0;
}
if (args.Length >0 && args [0] == "unhandled-exception-perform-wait-callback") {
unhandled_exception_perform_wait_callback ();
return 0;
}
if (args.Length >0 && args [0] == "unhandled-exception-endinvoke") {
unhandled_exception_endinvoke ();
return 0;
@@ -539,6 +554,10 @@ public class Tests : TestsBase, ITest2
run_step_out_void_async();
return 0;
}
if (args.Length > 0 && args [0] == "runtime_invoke_hybrid_exceptions") {
runtime_invoke_hybrid_exceptions();
return 0;
}
assembly_load ();
breakpoints ();
single_stepping ();
@@ -584,6 +603,7 @@ public class Tests : TestsBase, ITest2
inspect_enumerator_in_generic_struct();
if_property_stepping();
fixed_size_array();
test_new_exception_filter();
return 3;
}
@@ -595,6 +615,11 @@ public class Tests : TestsBase, ITest2
}
}
public class MyException : Exception {
public MyException(string message) : base(message) {
}
}
public static void if_property_stepping() {
var test = new TestClass();
if (test.OneLineProperty == "someInvalidValue6049e709-7271-41a1-bc0a-f1f1b80d4125")
@@ -827,6 +852,57 @@ public class Tests : TestsBase, ITest2
n.Buffer2 = new char4('a', 'b', 'c', 'd');
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void test_new_exception_filter () {
test_new_exception_filter1();
test_new_exception_filter2();
test_new_exception_filter3();
test_new_exception_filter4();
}
public static void test_new_exception_filter1 () {
try {
throw new Exception("excp");
}
catch (Exception e) {
}
}
public static void test_new_exception_filter2 () {
try {
throw new MyException("excp");
}
catch (Exception e) {
}
}
public static void test_new_exception_filter3 () {
try {
throw new ArgumentException();
}
catch (Exception e) {
}
try {
throw new Exception("excp");
}
catch (Exception e) {
}
}
public static void test_new_exception_filter4 () {
try {
throw new ArgumentException();
}
catch (Exception e) {
}
try {
throw new Exception("excp");
}
catch (Exception e) {
}
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void inspect_enumerator_in_generic_struct() {
TestEnumeratorInsideGenericStruct<String, String> generic_struct = new TestEnumeratorInsideGenericStruct<String, String>(new KeyValuePair<string, string>("0", "f1"));
@@ -1592,6 +1668,24 @@ public class Tests : TestsBase, ITest2
public static void unhandled_exception_endinvoke_2 () {
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void unhandled_exception_perform_wait_callback () {
try
{
var results = ResolveAsync().GetAwaiter().GetResult();
}
catch (SocketException sockEx)
{
//Console.WriteLine("correctly handled");
}
}
public static async Task<List<string>> ResolveAsync()
{
var addresses = await System.Net.Dns.GetHostAddressesAsync("foo.bar.baz");
return new List<string>(addresses.Select(addr => addr.ToString()));
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void unhandled_exception_endinvoke () {
Action action = new Action (() =>
@@ -2112,6 +2206,16 @@ public class Tests : TestsBase, ITest2
public static ref BlittableStruct get_ref_struct() {
return ref ref_return_struct;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void runtime_invoke_hybrid_exceptions () {
Type rtType = Type.GetType("RuntimeInvokeWithThrowClass");
ConstructorInfo rtConstructor = rtType.GetConstructor(Type.EmptyTypes);
object rtObject = rtConstructor.Invoke(new object[] { });
MethodInfo rtMethod = rtType.GetMethod("RuntimeInvokeThrowMethod");
rtMethod.Invoke(rtObject, new object[] { });
}
}
public class SentinelClass : MarshalByRefObject {
+70 -3
View File
@@ -1767,7 +1767,7 @@ public class DebuggerTests
t = frame.Method.GetParameters ()[7].ParameterType;
Assert.AreEqual ("Tests", t.Name);
var nested = (from nt in t.GetNestedTypes () where nt.IsNestedPublic select nt).ToArray ();
Assert.AreEqual (1, nested.Length);
Assert.AreEqual (2, nested.Length);
Assert.AreEqual ("NestedClass", nested [0].Name);
Assert.IsTrue (t.BaseType.IsAssignableFrom (t));
Assert.IsTrue (!t.IsAssignableFrom (t.BaseType));
@@ -4233,8 +4233,6 @@ public class DebuggerTests
var e = run_until ("unhandled_exception_endinvoke");
vm.Resume ();
var e1 = GetNextEvent (); //this should be the exception
vm.Resume ();
var e2 = GetNextEvent ();
Assert.IsFalse (e2 is ExceptionEvent);
@@ -4281,6 +4279,23 @@ public class DebuggerTests
vm = null;
}
[Test]
public void UnhandledException4 () {
vm.Exit (0);
Start (dtest_app_path, "unhandled-exception-perform-wait-callback");
var req = vm.CreateExceptionRequest (null, false, true);
req.Enable ();
var e = run_until ("unhandled_exception_perform_wait_callback");
vm.Resume ();
var e2 = GetNextEvent ();
Assert.IsTrue (e2 is VMDeathEvent);
vm = null;
}
[Test]
public void GCWhileSuspended () {
// Check that objects are kept alive during suspensions
@@ -5086,6 +5101,58 @@ public class DebuggerTests
Assert.AreEqual("d", min.Value);
}
[Test]
public void TestExceptionFilterWin () {
Event e = run_until ("test_new_exception_filter1");
var req2 = vm.CreateExceptionRequest (vm.RootDomain.Corlib.GetType ("System.Exception"), true, true, false);
req2.Enable ();
vm.Resume ();
Event ev = GetNextEvent ();
var l = ev.Thread.GetFrames ()[0].Location;
Assert.IsInstanceOfType (typeof (ExceptionEvent), ev);
req2.Disable ();
run_until ("test_new_exception_filter2");
req2 = vm.CreateExceptionRequest (null, true, true, false);
req2.Enable ();
vm.Resume ();
ev = GetNextEvent ();
Assert.IsInstanceOfType (typeof (ExceptionEvent), ev);
req2.Disable ();
run_until ("test_new_exception_filter3");
var req3 = vm.CreateExceptionRequest (vm.RootDomain.Corlib.GetType ("System.ArgumentException"), false, true, false);
req3.Enable ();
req2 = vm.CreateExceptionRequest (null, true, true, true);
req2.Enable ();
vm.Resume ();
ev = GetNextEvent ();
Assert.IsInstanceOfType (typeof (ExceptionEvent), ev);
req2.Disable ();
req3.Disable ();
run_until ("test_new_exception_filter4");
req2 = vm.CreateExceptionRequest (null, true, true, true);
req2.Enable ();
req2 = vm.CreateExceptionRequest (vm.RootDomain.Corlib.GetType ("System.ArgumentException"), false, true, false);
req2.Enable ();
vm.Resume ();
ev = GetNextEvent ();
}
[Test]
public void TestRuntimeInvokeHybridSuspendExceptions () {
TearDown ();
Start (dtest_app_path, "runtime_invoke_hybrid_exceptions", forceExit: true);
var req2 = vm.CreateExceptionRequest (null, false, true, false);
req2.Enable ();
vm.Resume ();
var ev = GetNextEvent ();
Assert.IsInstanceOfType (typeof (ExceptionEvent), ev);
vm.Exit (0);
vm = null;
}
#endif
} // class DebuggerTests
} // namespace
@@ -1,3 +1,5 @@
using System.Text;
namespace Mono.Profiler.Aot
{
//
@@ -31,6 +33,11 @@ namespace Mono.Profiler.Aot
public string Mvid {
get; set;
}
public override string ToString ()
{
return Name;
}
}
public class GenericInstRecord : ProfileRecord
@@ -43,6 +50,27 @@ namespace Mono.Profiler.Aot
public TypeRecord[] Types {
get; set;
}
public override string ToString ()
{
if (Types == null || Types.Length <= 0)
return "";
var sb = new StringBuilder ("<");
var first = true;
foreach (var type in Types) {
if (!first)
sb.Append (", ");
else
first = false;
sb.Append (type.ToString ());
}
sb.Append (">");
return sb.ToString ();
}
}
public class TypeRecord : ProfileRecord
@@ -62,9 +90,27 @@ namespace Mono.Profiler.Aot
get; set;
}
public string FullName {
get {
string prefix;
if (Name.Length > 0 && Name [0] == '.')
prefix = Module.ToString ();
else
prefix = "";
return $"{prefix}{Name}{GenericInst}";
}
}
public GenericInstRecord GenericInst {
get; set;
}
public override string ToString ()
{
return FullName;
}
}
public class MethodRecord : ProfileRecord
@@ -97,5 +143,10 @@ namespace Mono.Profiler.Aot
public int ParamCount {
get; set;
}
public override string ToString ()
{
return $"{Signature.Replace ("(", $" {Type}:{Name} (")}";
}
}
}
@@ -88,19 +88,19 @@
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Core.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Core.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Core.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
@@ -30,6 +30,76 @@
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-net_4_x-$(HostPlatform)</IntermediateOutputPath>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monodroid' ">
<OutputPath>./../../class/lib/monodroid</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monodroid</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;MONODROID;ANDROID;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch' ">
<OutputPath>./../../class/lib/monotouch</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monotouch</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch_watch' ">
<OutputPath>./../../class/lib/monotouch_watch</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monotouch_watch</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;FEATURE_NO_BSD_SOCKETS;MONOTOUCH_WATCH;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch_tv' ">
<OutputPath>./../../class/lib/monotouch_tv</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monotouch_tv</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MOBILE;MOBILE_LEGACY;MONO;MONOTOUCH;DISABLE_COM;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;FULL_AOT_RUNTIME;MONOTOUCH_TV;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_full_interp' ">
<OutputPath>./../../class/lib/testing_aot_full_interp</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-testing_aot_full_interp</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;FULL_AOT_INTERP;DISABLE_COM;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_hybrid' ">
<OutputPath>./../../class/lib/testing_aot_hybrid</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-testing_aot_hybrid</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;MOBILE_DYNAMIC;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_aot_full' ">
<OutputPath>./../../class/lib/testing_aot_full</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-testing_aot_full</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_REMOTING;DISABLE_SECURITY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_COM;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'winaot' ">
<OutputPath>./../../class/lib/winaot</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-winaot</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_COM;WIN_PLATFORM;WINAOT;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'testing_winaot_interp' ">
<OutputPath>./../../class/lib/testing_winaot_interp</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-testing_winaot_interp</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;DISABLE_COM;WIN_PLATFORM;WINAOT;FULL_AOT_INTERP;DISABLE_SECURITY;DISABLE_REMOTING;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'xammac' ">
<OutputPath>./../../class/lib/xammac</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-xammac</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_DYNAMIC;XAMMAC;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;XAMARIN_MODERN;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'xammac_net_4_5' ">
<OutputPath>./../../class/lib/xammac_net_4_5</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-xammac_net_4_5</IntermediateOutputPath>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;NO_SYSTEM_DRAWING_DEPENDENCY;NO_WINFORMS_DEPENDENCY;NO_SYSTEM_WEB_DEPENDENCY;XAMMAC_4_5;XAMARIN_MODERN;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'orbis' ">
<OutputPath>./../../class/lib/orbis</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-orbis</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;ORBIS;DISABLE_COM;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'unreal' ">
<OutputPath>./../../class/lib/unreal</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-unreal</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;MOBILE;MOBILE_DYNAMIC;NET_3_5;NET_4_0;NET_4_5;MONO;COREFX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'wasm' ">
<OutputPath>./../../class/lib/wasm</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-wasm</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;WASM;DISABLE_COM;FEATURE_NO_BSD_SOCKETS;DISABLE_REMOTING;DISABLE_SECURITY;COREFX</DefineConstants>
</PropertyGroup>
<!-- @ALL_PROFILE_PROPERTIES@ -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
@@ -69,14 +139,37 @@
</ItemGroup>
<!--End of common files-->
<!-- @ALL_SOURCES@ -->
<!-- @COMMON_PROJECT_REFERENCES@ -->
<ItemGroup Condition=" '$(Platform)' == 'net_4_x' ">
<ItemGroup>
<ProjectReference Include="../System.Core/System.Core.csproj" />
<ProjectReference Include="../System/System.csproj" />
<ProjectReference Include="../System.Data/System.Data.csproj" />
<ProjectReference Include="../System.XML/System.Xml.csproj" />
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'testing_aot_full_interp' ">
<Reference Include="nunitlite">
<HintPath>..\lib\testing_aot_full_interp\nunitlite.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'testing_aot_hybrid' ">
<Reference Include="nunitlite">
<HintPath>..\lib\testing_aot_hybrid\nunitlite.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'testing_aot_full' ">
<Reference Include="nunitlite">
<HintPath>..\lib\testing_aot_full\nunitlite.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'testing_winaot_interp' ">
<Reference Include="nunitlite">
<HintPath>..\lib\testing_winaot_interp\nunitlite.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<!-- @ALL_REFERENCES@ -->
<!-- @ALL_RESOURCES@ -->
<PropertyGroup>
@@ -55,7 +55,7 @@ namespace System.Drawing.Design
public override object EditValue (ITypeDescriptorContext context,
IServiceProvider provider, object value)
{
if (context != null && provider != null) {
if (provider != null) {
editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (editorService != null) {
if (editor_control == null)
@@ -12,6 +12,10 @@ namespace System.Net.Http
return true;
#endif
// Mono URI handling which does not distinguish between file and url absolute paths without scheme
if (uri.Scheme == Uri.UriSchemeFile && uri.OriginalString.StartsWith ("/", StringComparison.Ordinal))
return true;
return HttpUtilities.IsHttpUri (uri);
}
}
@@ -375,8 +375,7 @@ namespace MonoTests.System.Net.Http
Assert.AreEqual (response, client.SendAsync (request).Result, "#1");
}
[Test]
[Category ("NotWorking")]
[Test]
public void Send_BaseAddress ()
{
var mh = new HttpMessageHandlerMock ();
@@ -6215,9 +6215,9 @@ namespace System.Windows.Forms {
XSetWMNormalHints(DisplayHandle, hwnd.whole_window, ref size_hints);
int[] atoms = new int[2];
atoms [0] = 1; // Version 1
atoms [1] = 1; // we want to be mapped
IntPtr[] atoms = new IntPtr[2];
atoms [0] = (IntPtr)1; // Version 1
atoms [1] = (IntPtr)1; // we want to be mapped
// This line cost me 3 days...
XChangeProperty(DisplayHandle, hwnd.whole_window, _XEMBED_INFO, _XEMBED_INFO, 32, PropertyMode.Replace, atoms, 2);
@@ -204,9 +204,11 @@ namespace System.Xml.Serialization
{
if (isNullable && ReadNull()) return null;
if (checkType) {
System.Xml.XmlQualifiedName t = GetXsiType();
if (t != null) {
if (checkType)
{
System.Xml.XmlQualifiedName t = GetXsiType();
if (t != null)
{
XmlTypeMapping realMap = typeMap.GetRealElementMap (t.Name, t.Namespace);
if (realMap == null) {
if (typeMap.TypeData.Type == typeof(object))
@@ -219,12 +221,7 @@ namespace System.Xml.Serialization
}
else if (typeMap.TypeData.Type == typeof(object))
return ReadTypedPrimitive (AnyType);
else {
XmlTypeMapping realMap = typeMap.GetRealElementMap (Reader.LocalName, Reader.NamespaceURI);
if (realMap != null && realMap != typeMap)
return ReadObject(realMap, false, false);
}
}
}
object ob = CreateInstance (typeMap.TypeData.Type, true);
@@ -389,7 +389,7 @@ namespace System.Xml.Serialization
return (XmlTypeMapMemberAttribute)_attributeMembers [BuildKey (name,ns, -1)];
}
public XmlTypeMapElementInfo GetElement (string name, string ns, int minimalOrder)
public XmlTypeMapElementInfo GetElement(string name, string ns, int minimalOrder)
{
if (_elements == null)
return null;
@@ -404,38 +404,22 @@ namespace System.Xml.Serialization
selected = info;
}
}
else if (info.MappedType != null && info.MappedType.DerivedTypes.Count > 0) {
foreach (XmlTypeMapping derrivedInfo in info.MappedType.DerivedTypes) {
if (derrivedInfo.ElementName == name && derrivedInfo.Namespace == ns) {
if (info.ExplicitOrder < minimalOrder)
continue;
if (selected == null || selected.ExplicitOrder > info.ExplicitOrder) {
selected = info;
}
}
}
}
}
return selected;
}
public XmlTypeMapElementInfo GetElement (string name, string ns)
public XmlTypeMapElementInfo GetElement(string name, string ns)
{
if (_elements == null) return null;
foreach (XmlTypeMapElementInfo info in _elements.Values)
if (info.ElementName == name && info.Namespace == ns)
return info;
else if (info.MappedType != null && info.MappedType.DerivedTypes.Count > 0) {
foreach (XmlTypeMapping derrivedInfo in info.MappedType.DerivedTypes)
if (derrivedInfo.ElementName == name && derrivedInfo.Namespace == ns)
return info;
}
return null;
}
public XmlTypeMapElementInfo GetElement (int index)
{
if (_elements == null) return null;
@@ -14,6 +14,7 @@
using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;
@@ -1686,28 +1687,40 @@ namespace MonoTests.System.XmlSerialization
Assert.AreEqual ("b", d.Extra[1]);
}
[Test] // PR #11194
public void TestDerrivedClassProperty ()
// https://github.com/mono/mono/issues/16918
[Test]
public void Bug16918 ()
{
var data = "<layout width=\".25\" height =\".25\" x=\"0\" y=\"0\" id=\"portrait\" class=\"render\"><background color=\"white\"><div x=\".03\" y=\".05\" width=\".94\" height =\".9\" layout=\"proportional_rows\" paddingX=\".01\" paddingY=\".02\"><background color=\"black\"></background><background color=\"gray\" padding=\".1\"><label color=\"white\" font=\"emulogic.ttf\" fontSize=\"15\">Test UI</label></background><br brSize=\"1\" /><background class=\"back,Lab\" color=\"green\"><label class=\"Lab\" color=\"white\" font=\"emulogic.ttf\" fontSize=\"15\">GREEN</label></background><background color=\"red\"><label class=\"Lab\" color=\"white\" font=\"emulogic.ttf\" fontSize=\"15\">RED</label></background><background color=\"blue\"><label class=\"Lab\" color=\"white\" font=\"emulogic.ttf\" fontSize=\"15\">TLUE</label></background><background color=\"blue\"><label class=\"Lab\" color=\"white\" font=\"emulogic.ttf\" fontSize=\"15\">BLUE</label></background></div></background></layout>";
PropertiesWithSameNameAsTheirType testObject = new PropertiesWithSameNameAsTheirType ()
{
E1 = E1.Two,
E2 = E2.Two,
E3 = E3.Two,
E4 = E4.Two,
E5 = E5.Two
};
XmlAttributeOverrides overrides = PR11194.GenerateLayoutOverrides<PR11194ChildLo>();
XmlSerializer serializer = new XmlSerializer (typeof (PropertiesWithSameNameAsTheirType));
var result = Deserialize(typeof(PR11194ChildLo), data, overrides) as PR11194ChildLo;
// serialize
string serializedObject;
using (MemoryStream memoryStream = new MemoryStream ())
{
serializer.Serialize (memoryStream, testObject);
serializedObject = Encoding.UTF8.GetString (memoryStream.ToArray ());
}
PR11194Parent2 child;
Assert.IsNotNull(result, "#11194_1");
Assert.AreEqual(1, result.children.Count, "#11194_2");
child = result.children[0] as PR11194Parent2;
Assert.IsNotNull(child, "#11194_3");
Assert.AreEqual(1, child.children.Count, "#11194_4");
child = child.children[0] as PR11194Parent2;
Assert.IsNotNull(child, "#11194_5");
Assert.AreEqual(7, child.children.Count, "#11194_6");
child = child.children[1] as PR11194Parent2;
Assert.IsNotNull(child, "#11194_7");
Assert.AreEqual(1, child.children.Count, "#11194_8");
Assert.AreEqual("PR11194ChildL", child.children[0].GetType().Name, "#11194_9");
PropertiesWithSameNameAsTheirType deserializedObject;
using (MemoryStream memoryStream = new MemoryStream (Encoding.UTF8.GetBytes (serializedObject)))
{
deserializedObject = (PropertiesWithSameNameAsTheirType)serializer.Deserialize (memoryStream);
}
Assert.AreEqual (testObject.E1, deserializedObject.E1, "#1");
Assert.AreEqual (testObject.E2, deserializedObject.E2, "#2");
Assert.AreEqual (testObject.E3, deserializedObject.E3, "#3");
Assert.AreEqual (testObject.E4, deserializedObject.E4, "#4");
Assert.AreEqual (testObject.E5, deserializedObject.E5, "#5");
}
}
}
@@ -12,8 +12,6 @@
//
using System;
using System.Linq;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
@@ -1207,157 +1205,54 @@ namespace MonoTests.System.Xml.TestClasses
}
}
#region PR_11194
#region PR_11194_GenerateOverrides
public static class PR11194
[Serializable]
public class PropertiesWithSameNameAsTheirType
{
public static XmlAttributeOverrides GenerateLayoutOverrides<T>()
public PropertiesWithSameNameAsTheirType ()
{
Type tType = typeof(T);
TypeInfo tTypeInfo = tType.GetTypeInfo();
IEnumerable<PropertyInfo> props = tType.GetRuntimeProperties();
XmlAttributeOverrides overrides = new XmlAttributeOverrides();
foreach (PropertyInfo prop in props) {
XmlDerrivedAttribute attr = prop.GetCustomAttribute<XmlDerrivedAttribute>();
if (attr == null) {
continue;
}
Type dType = prop.DeclaringType;
Type pType = prop.PropertyType;
TypeInfo pTypeInfo = pType.GetTypeInfo();
Type enumType = typeof(IEnumerable<>);
if (pTypeInfo.IsGenericType
&& pTypeInfo.ImplementedInterfaces.Any(t =>
(t.GetTypeInfo().IsGenericType && t.GetGenericTypeDefinition() == enumType))) {
pType = pType.GenericTypeArguments[0];
}
XmlAttributes overrideAttributes = GenerateOverrideAttributes(dType, pType, attr);
overrides.Add(dType, prop.Name, overrideAttributes);
}
return overrides;
}
private static XmlAttributes GenerateOverrideAttributes (Type declaringType, Type propertyType, XmlDerrivedAttribute attr)
{
XmlAttributes xAttrs = new XmlAttributes();
public object obj1 { get; set; }
public object obj2 { get; set; }
public object obj3 { get; set; }
public object obj4 { get; set; }
public object obj5 { get; set; }
Assembly a = declaringType.GetTypeInfo().Assembly;
TypeInfo interfaceType = propertyType.GetTypeInfo();
IEnumerable<Type> types = a.ExportedTypes.Where(t => interfaceType.IsAssignableFrom(t.GetTypeInfo()) && !t.GetTypeInfo().IsAbstract);
foreach (Type t in types) {
string name = NameBySourceType(t, attr.SrcType);// t.GetTypeInfo().GetCustomAttribute<XmlTypeAttribute>().TypeName;
XmlElementAttribute xAttr = new XmlElementAttribute();
xAttr.ElementName = name;
xAttr.Type = t;
xAttrs.XmlElements.Add(xAttr);
}
return xAttrs;
}
private static string NameBySourceType (Type derrivedType, XmlDerrivedSourceType srcType)
{
string name = null;
switch (srcType)
{
case XmlDerrivedSourceType.ByXmlType:
name = derrivedType.GetTypeInfo().GetCustomAttribute<XmlTypeAttribute>().TypeName;
break;
}
return name;
}
public E1 E1 { get; set; }
public E2 E2 { get; set; }
public E3 E3 { get; set; }
public E4 E4 { get; set; }
public E5 E5 { get; set; }
}
#endregion
#region helperAttribute
public enum XmlDerrivedSourceType
public enum E1
{
ByXmlType
One,
Two,
}
public class XmlDerrivedAttribute : Attribute
public enum E2
{
public XmlDerrivedSourceType SrcType { get; set; }
public XmlDerrivedAttribute(XmlDerrivedSourceType srcType)
{
SrcType = srcType;
}
One,
Two,
}
#endregion
public abstract class PR11194Parent
public enum E5
{
[XmlIgnore]
public PR11194Parent Parent { get; set; }
One,
Two,
}
public abstract class PR11194Parent2 : PR11194Parent
public enum E3
{
[XmlAttribute]
public float width { get; set; }
[XmlAttribute]
public float height { get; set; }
[XmlAttribute]
public float x { get; set; }
[XmlAttribute]
public float y { get; set; }
[XmlAttribute]
public string id { get; set; }
[XmlElement]
[XmlDerrived(XmlDerrivedSourceType.ByXmlType)]
public List<PR11194Parent> children { get; set; }
One,
Two,
}
[XmlType("background")]
public class PR11194ChildB : PR11194Parent2
public enum E4
{
[XmlAttribute]
public string image { get; set; }
One,
Two,
}
[XmlType("br")]
public class PR11194ChildBr : PR11194Parent
{
[XmlAttribute("brSize")]
public int breaks { get; set; }
}
[XmlType("div")]
public class PR11194ChildD : PR11194ChildLo
{
}
[XmlType("label")]
public class PR11194ChildL : PR11194Parent2
{
[XmlAttribute]
public string font { get; set; }
[XmlAttribute]
public int fontSize { get; set; }
[XmlText]
public string Text { get; set; }
}
[XmlType("layout")]
public class PR11194ChildLo : PR11194Parent2
{
}
#endregion
}
@@ -198,7 +198,14 @@ namespace Mono.Btls
set {
if (nativePrivateKey != null)
nativePrivateKey.Dispose ();
nativePrivateKey = null;
try {
// FIXME: there doesn't seem to be a public API to check whether it actually
// contains a private key (apart from RSAManaged.PublicOnly).
if (value != null)
nativePrivateKey = MonoBtlsKey.CreateFromRSAPrivateKey ((RSA)value);
} catch {
nativePrivateKey = null;
}
}
}
@@ -120,25 +120,21 @@ namespace Mono.Net.Security
ServicePointManager.CheckCertificateRevocationList).ConfigureAwait (false);
status = WebExceptionStatus.Success;
request.ServicePoint.UpdateClientCertificate (sslStream.InternalLocalCertificate);
} catch (Exception ex) {
WebConnection.Debug ($"MONO TLS STREAM ERROR: {socket.ID} {socket.CleanedUp} {ex.Message}");
if (socket.CleanedUp)
status = WebExceptionStatus.RequestCanceled;
else if (CertificateValidationFailed)
status = WebExceptionStatus.TrustFailure;
else
status = WebExceptionStatus.SecureChannelFailure;
throw;
} finally {
WebConnection.Debug ($"MONO TLS STREAM CREATE STREAM DONE: {socket.ID} {socket.CleanedUp}");
if (CertificateValidationFailed)
status = WebExceptionStatus.TrustFailure;
if (status == WebExceptionStatus.Success)
request.ServicePoint.UpdateClientCertificate (sslStream.InternalLocalCertificate);
else {
request.ServicePoint.UpdateClientCertificate (null);
sslStream.Dispose ();
sslStream = null;
}
request.ServicePoint.UpdateClientCertificate (null);
sslStream.Dispose ();
sslStream = null;
throw;
}
try {
@@ -146,6 +142,7 @@ namespace Mono.Net.Security
await sslStream.WriteAsync (tunnel.Data, 0, tunnel.Data.Length, cancellationToken).ConfigureAwait (false);
} catch {
status = WebExceptionStatus.SendFailure;
sslStream.Dispose ();
sslStream = null;
throw;
}
@@ -111,7 +111,7 @@ namespace System.IO.Compression
if (disposing)
GC.SuppressFinalize (this);
native.Dispose (disposing);
native?.Dispose (disposing);
if (disposing && !disposed) {
disposed = true;
@@ -140,12 +140,15 @@ namespace System.IO.Compression
internal ValueTask<int> ReadAsyncMemory (Memory<byte> destination, CancellationToken cancellationToken)
{
throw new NotImplementedException ();
return base.ReadAsync(destination, cancellationToken);
}
internal int ReadCore (Span<byte> destination)
{
throw new NotImplementedException ();
var buffer = new byte [destination.Length];
int count = Read(buffer, 0, buffer.Length);
buffer.AsSpan(0, count).CopyTo(destination);
return count;
}
public override int Read (byte[] array, int offset, int count)
@@ -180,12 +183,12 @@ namespace System.IO.Compression
internal ValueTask WriteAsyncMemory (ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
{
throw new NotImplementedException ();
return base.WriteAsync(source, cancellationToken);
}
internal void WriteCore (ReadOnlySpan<byte> source)
{
throw new NotImplementedException ();
Write (source.ToArray (), 0, source.Length);
}
public override void Write (byte[] array, int offset, int count)
@@ -392,11 +395,11 @@ namespace System.IO.Compression
io_buffer = null;
if (z_stream != null) {
if (z_stream != null && !z_stream.IsInvalid) {
z_stream.Dispose();
}
if (data.IsAllocated) {
if (data != null && data.IsAllocated) {
data.Free ();
}
}
@@ -1,75 +0,0 @@
//
// System.IO.FileSystemEventArgs.cs
//
// Author:
// Tim Coleman ([email protected])
//
// Copyright (C) Tim Coleman, 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// 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
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.IO {
public class FileSystemEventArgs : EventArgs {
#region Fields
WatcherChangeTypes changeType;
string directory;
string name;
#endregion // Fields
#region Constructors
public FileSystemEventArgs (WatcherChangeTypes changeType, string directory, string name)
{
this.changeType = changeType;
this.directory = directory;
this.name = name;
}
internal void SetName (string name)
{
this.name = name;
}
#endregion // Constructors
#region Properties
public WatcherChangeTypes ChangeType {
get { return changeType; }
}
public string FullPath {
get { return Path.Combine (directory, name); }
}
public string Name {
get { return name; }
}
#endregion // Properties
}
}
@@ -1,33 +0,0 @@
//
// System.IO.FileSystemEventHandler.cs
//
// Author:
// Tim Coleman ([email protected])
//
// Copyright (C) Tim Coleman, 2002
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// 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
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.IO {
public delegate void FileSystemEventHandler (object sender, FileSystemEventArgs e);
}
@@ -61,7 +61,7 @@ namespace System.IO {
SearchPattern2 pattern;
bool disposed;
string mangledFilter;
static IFileWatcher watcher;
IFileWatcher watcher;
object watcher_handle;
static object lockobj = new object ();
+14 -23
View File
@@ -999,7 +999,7 @@ namespace System.Net.Sockets
}
});
public IAsyncResult BeginConnect (string host, int port, AsyncCallback requestCallback, object state)
public IAsyncResult BeginConnect (string host, int port, AsyncCallback callback, object state)
{
ThrowIfDisposedAndClosed ();
@@ -1012,32 +1012,23 @@ namespace System.Net.Sockets
if (is_listening)
throw new InvalidOperationException ();
var callback = new AsyncCallback ((result) => {
var resultTask = ((Task<IPAddress[]>)result);
BeginConnect (resultTask.Result, port, requestCallback, resultTask.AsyncState);
});
return ConvertToApm<IPAddress[]> (Dns.GetHostAddressesAsync (host), callback, state);
}
var sockares = new SocketAsyncResult (this, callback, state, SocketOperation.Connect) {
Port = port
};
private static IAsyncResult ConvertToApm<T> (Task<T> task, AsyncCallback callback, object state)
{
if (task == null)
throw new ArgumentNullException ("task");
var tcs = new TaskCompletionSource<T> (state);
task.ContinueWith (t =>
{
var dnsRequest = Dns.GetHostAddressesAsync (host);
dnsRequest.ContinueWith (t => {
if (t.IsFaulted)
tcs.TrySetException (t.Exception.InnerExceptions);
sockares.Complete (t.Exception.InnerException);
else if (t.IsCanceled)
tcs.TrySetCanceled ();
else
tcs.TrySetResult (t.Result);
if (callback != null)
callback (tcs.Task);
sockares.Complete (new OperationCanceledException ());
else {
sockares.Addresses = t.Result;
BeginMConnect (sockares);
}
}, TaskScheduler.Default);
return tcs.Task;
return sockares;
}
public IAsyncResult BeginConnect (EndPoint remoteEP, AsyncCallback callback, object state)
+6 -6
View File
@@ -27,12 +27,12 @@
<PropertyGroup Condition=" '$(Platform)' == 'net_4_x' ">
<OutputPath>./../../class/lib/net_4_x-$(HostPlatform)</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-net_4_x-$(HostPlatform)</IntermediateOutputPath>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;COREFX;CONFIGURATION_2_0;SYSTEM_NET_PRIMITIVES_DLL;XML_DEP;SECURITY_DEP;FEATURE_PAL;SYSTEM_NAMESPACE;MONO;PLATFORM_UNIX;MONO_FEATURE_PROCESS_START;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;MONO_SECURITY_ALIAS;CODEDOM;FEATURE_COMPILED;MONO_FEATURE_BTLS;CONFIGURATION_DEP</DefineConstants>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;COREFX;CONFIGURATION_2_0;SYSTEM_NET_PRIMITIVES_DLL;XML_DEP;SECURITY_DEP;FEATURE_PAL;SYSTEM_NAMESPACE;MONO;PLATFORM_UNIX;MONO_FEATURE_PROCESS_START;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;MONO_SECURITY_ALIAS;CODEDOM;FEATURE_COMPILED;MONO_FEATURE_BTLS;ENABLE_GSS;CONFIGURATION_DEP</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monodroid' ">
<OutputPath>./../../class/lib/monodroid</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monodroid</IntermediateOutputPath>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;MONODROID;ANDROID;COREFX;CONFIGURATION_2_0;SYSTEM_NET_PRIMITIVES_DLL;XML_DEP;SECURITY_DEP;FEATURE_PAL;SYSTEM_NAMESPACE;MONO;PLATFORM_UNIX;MONO_FEATURE_PROCESS_START;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;MONO_SECURITY_ALIAS;FEATURE_COMPILED;MONO_FEATURE_BTLS</DefineConstants>
<DefineConstants>NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;MOBILE_DYNAMIC;MONODROID;ANDROID;COREFX;CONFIGURATION_2_0;SYSTEM_NET_PRIMITIVES_DLL;XML_DEP;SECURITY_DEP;FEATURE_PAL;SYSTEM_NAMESPACE;MONO;PLATFORM_UNIX;MONO_FEATURE_PROCESS_START;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_THREAD_SUSPEND_RESUME;MONO_FEATURE_MULTIPLE_APPDOMAINS;MONO_SECURITY_ALIAS;FEATURE_COMPILED;MONO_FEATURE_BTLS;ENABLE_GSS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monotouch' ">
<OutputPath>./../../class/lib/monotouch</OutputPath>
@@ -412,7 +412,11 @@
<Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\CompressionLevel.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\CompressionMode.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.Compression\src\System\IO\Compression\GZipStream.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\FileSystemEventArgs.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\FileSystemEventHandler.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\FileSystemWatcher.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\RenamedEventArgs.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\RenamedEventHandler.cs" />
<Compile Include="..\..\..\external\corefx\src\System.IO.FileSystem.Watcher\src\System\IO\WaitForChangedResult.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Mail\src\System\Net\Base64Stream.cs" />
<Compile Include="..\..\..\external\corefx\src\System.Net.Mail\src\System\Net\BufferBuilder.cs" />
@@ -866,14 +870,10 @@
<Compile Include="System.IO.Compression\DeflateStream.cs" />
<Compile Include="System.IO\ErrorEventArgs.cs" />
<Compile Include="System.IO\ErrorEventHandler.cs" />
<Compile Include="System.IO\FileSystemEventArgs.cs" />
<Compile Include="System.IO\FileSystemEventHandler.cs" />
<Compile Include="System.IO\IODescriptionAttribute.cs" />
<Compile Include="System.IO\InternalBufferOverflowException.cs" />
<Compile Include="System.IO\InvalidDataException.cs" />
<Compile Include="System.IO\NotifyFilters.cs" />
<Compile Include="System.IO\RenamedEventArgs.cs" />
<Compile Include="System.IO\RenamedEventHandler.cs" />
<Compile Include="System.IO\WatcherChangeTypes.cs" />
<Compile Include="System.Net.Mail\AlternateView.cs" />
<Compile Include="System.Net.Mail\AlternateViewCollection.cs" />
@@ -110,6 +110,9 @@ System/RemoteExecutorTests.cs
# System.IO.FileSystemWatcher
../../../external/corefx/src/System.IO.FileSystem.Watcher/tests/Utility/*.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/tests/Args.ErrorEventArgs.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/tests/Args.FileSystemEventArgs.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/tests/Args.RenamedEventArgs.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs
../../../external/corefx/src/Common/tests/System/IO/TempFile.cs
@@ -11,6 +11,7 @@
using NUnit.Framework;
using System;
using System.IO;
using System.Reflection;
using MonoTests.Helpers;
@@ -109,7 +110,72 @@ namespace MonoTests.System.IO
}
}
}
[Test]
public void CreateTwoAndDispose ()
{
// Create two FSW instances and dispose them. Verify
// that the backend IFileWatcher's Dispose
// (watcher_handle) method got called.
// FIXME: This only works for the
// CoreFXFileSystemWatcherProxy not the other backends.
using (var tmp = new TempDirectory ()) {
// have to use reflection to poke at the private fields of FileSystemWatcher.
var watcherField = typeof (FileSystemWatcher).GetField ("watcher", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.IsNotNull (watcherField);
var watcherHandleField = typeof (FileSystemWatcher).GetField ("watcher_handle", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.IsNotNull (watcherHandleField);
var proxyType = typeof (FileSystemWatcher).Assembly.GetType ("System.IO.CoreFXFileSystemWatcherProxy");
Assert.IsNotNull (proxyType);
var fsw1 = new FileSystemWatcher (tmp.Path, "*");
var fsw2 = new FileSystemWatcher (tmp.Path, "*");
object handle1 = null;
object handle2 = null;
// using "using" to ensure that Dispose gets called even if we throw an exception
using (var fsw11 = fsw1)
using (var fsw22 = fsw2) {
// at this point watcher and watcher_handle should be set
var watcher = watcherField.GetValue (fsw1);
Assert.IsNotNull (watcher);
if (!proxyType.IsAssignableFrom (watcher.GetType ()))
Assert.Ignore ("Testing only CoreFXFileSystemWatcherProxy FSW backend");
handle1 = watcherHandleField.GetValue (fsw1);
handle2 = watcherHandleField.GetValue (fsw2);
Assert.IsNotNull (handle1);
Assert.IsNotNull (handle2);
}
// Dispose was called, now watcher_handle should be null
Assert.IsNull (watcherHandleField.GetValue (fsw1));
Assert.IsNull (watcherHandleField.GetValue (fsw2));
// and moreover, the CoreFXFileSystemWatcherProxy shouldn't have entries for either handle1 or handle2
var proxyTypeInternalMapField = proxyType.GetField ("internal_map", BindingFlags.Static | BindingFlags.NonPublic);
Assert.IsNotNull (proxyTypeInternalMapField);
var internal_map = proxyTypeInternalMapField.GetValue (null)
as global::System.Collections.Generic.IDictionary<object, global::System.IO.CoreFX.FileSystemWatcher>;
Assert.IsNotNull (internal_map);
// This pair are the critical checks: after we call Dispose on fsw1 and fsw2, the
// backend's internal map shouldn't have anything keyed on handle1 and handle2.
// Therefore System.IO.CoreFX.FileSystemWatcher instances will be disposed of, too.
Assert.IsFalse (internal_map.ContainsKey (handle1));
Assert.IsFalse (internal_map.ContainsKey (handle2));
}
}
}
}
#endif
#endif
@@ -511,7 +511,7 @@ namespace MonoTests.System.Net.Sockets
sock.BeginConnect (ep, new AsyncCallback(SocketError_callback),
sock);
if (SocketError_event.WaitOne (2000, false) == false) {
if (SocketError_event.WaitOne (5000, false) == false) {
Assert.Fail ("SocketError wait timed out");
}
@@ -1715,6 +1715,68 @@ namespace MonoTests.System.Net.Sockets
listen.Close ();
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BeginConnectHostNamePortWithoutCallback ()
{
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
Socket listen = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
listen.Bind (IPAddress.Loopback, out IPEndPoint ep);
listen.Listen (1);
IAsyncResult result = sock.BeginConnect (IPAddress.Loopback.ToString (), ep.Port, null, null);
if (result.AsyncWaitHandle.WaitOne (2000, false) == false) {
Assert.Fail ("BeginConnectHostNamePortWithoutCallback wait timed out");
}
Assert.AreEqual (true, result.IsCompleted, "BeginConnectHostNamePortWithoutCallback #1");
sock.EndConnect (result);
sock.Close ();
listen.Close ();
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
public void BeginConnectHostNamePortWithCallback ()
{
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
Socket listen = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
listen.Bind (IPAddress.Loopback, out IPEndPoint ep);
listen.Listen (1);
BCCalledBack.Reset ();
BCConnected = false;
IAsyncResult result = sock.BeginConnect (IPAddress.Loopback.ToString (), ep.Port, BCCallback, sock);
if (BCCalledBack.WaitOne (2000, false) == false) {
Assert.Fail ("BeginConnectHostNamePortWithCallback wait timed out");
}
Assert.AreEqual (true, BCConnected, "BeginConnectHostNamePortWithCallback #1");
sock.Close ();
listen.Close ();
}
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
@@ -16,7 +16,7 @@ namespace MonoTests.System.Net.WebSockets
[TestFixture]
public class ClientWebSocketTest
{
const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
const string EchoServerUrl = "ws://corefx-net-http11.azurewebsites.net/WebSocket/EchoWebSocket.ashx";
ClientWebSocket socket;
MethodInfo headerSetMethod;
@@ -1908,6 +1908,7 @@ WYpnKQqsKIzlSqv9wwXs7B1iA7ZdvHk3TAnSnLP1o2H7ME05UnZPKCvraONdezon
}
}
#if !MONOTOUCH_WATCH
private void CheckAuthenticode (X509Certificate2 x)
{
DateTime expectedNotAfter = new DateTime (632118306520000000,
@@ -1975,6 +1976,7 @@ WYpnKQqsKIzlSqv9wwXs7B1iA7ZdvHk3TAnSnLP1o2H7ME05UnZPKCvraONdezon
File.Delete (tempFile);
}
}
#endif
private bool RunningOnWindows ()
{
@@ -2052,7 +2054,9 @@ WYpnKQqsKIzlSqv9wwXs7B1iA7ZdvHk3TAnSnLP1o2H7ME05UnZPKCvraONdezon
Assert.AreEqual (X509ContentType.Pkcs7, X509Certificate2.GetCertContentType (farscape_pkcs7), "1-Pkcs7");
#if !MONOTOUCH_WATCH
Assert.AreEqual (X509ContentType.Authenticode, X509Certificate2.GetCertContentType (helloworld_signed), "Authenticode");
#endif
}
[Test]
+5 -5
View File
@@ -28,14 +28,10 @@ System.IO.Compression/DeflateStream.cs
System.IO/ErrorEventArgs.cs
System.IO/ErrorEventHandler.cs
System.IO/FileSystemEventArgs.cs
System.IO/FileSystemEventHandler.cs
System.IO/InternalBufferOverflowException.cs
System.IO/InvalidDataException.cs
System.IO/IODescriptionAttribute.cs
System.IO/NotifyFilters.cs
System.IO/RenamedEventArgs.cs
System.IO/RenamedEventHandler.cs
System.IO/WatcherChangeTypes.cs
System.Net/BasicClient.cs
@@ -872,13 +868,17 @@ ReferenceSources/Win32Exception.cs
../../../external/corefx/src/System.Private.Uri/src/System/UriBuilder.cs
../../../external/corefx/src/System.Runtime.Extensions/src/System/CodeDom/Compiler/IndentedTextWriter.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemEventArgs.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemEventHandler.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/RenamedEventArgs.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/RenamedEventHandler.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/WaitForChangedResult.cs
../../../external/corefx/src/System.Runtime.InteropServices/src/System/Security/SecureStringMarshal.cs
../../../external/corefx/src/System.Runtime.Extensions/src/System/StringNormalizationExtensions.cs
../../../external/corefx/src/System.Diagnostics.StackTrace/src/System/Diagnostics/StackFrameExtensions.cs
../../../external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs
# Everything except compiled
../../../external/corefx/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Capture.cs
+3 -6
View File
@@ -232,7 +232,7 @@ TEST_RESOURCES = $(TEST_RESX_RESOURCES) $(TEST_RESX_RESOURCES_SATELITE)
satellite_assembly1 = $(test_lib_dir)/es-ES/$(patsubst %.dll,%.resources.dll,$(test_lib))
satellite_assembly2 = $(test_lib_dir)/nn-NO/$(patsubst %.dll,%.resources.dll,$(test_lib))
$(test_lib_output): $(TEST_RESOURCES) $(satellite_assembly1) $(satellite_assembly2) $(test_lib_dir)
$(test_lib_output): $(TEST_RESOURCES) $(satellite_assembly1) $(satellite_assembly2) | $(test_lib_dir)
mscorlib_for_profile = $(topdir)/class/lib/$(PROFILE)/mscorlib.dll
@@ -298,11 +298,8 @@ NO_VTS_TEST = yes
endif
ifndef NO_VTS_TEST
test: test-vts
run-test: run-test-vts
else
test:
run-test:
test-local: test-vts
run-test-local: run-test-vts
endif
EXTRA_DISTFILES += \
+11 -4
View File
@@ -100,7 +100,7 @@ namespace Mono {
static extern void DisableMicrosoftTelemetry ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void EnableMicrosoftTelemetry_internal (IntPtr appBundleID, IntPtr appSignature, IntPtr appVersion, IntPtr merpGUIPath, IntPtr eventType, IntPtr appPath, IntPtr configDir);
static extern void EnableMicrosoftTelemetry_internal (IntPtr appBundleID, IntPtr appSignature, IntPtr appVersion, IntPtr merpGUIPath, IntPtr appPath, IntPtr configDir);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void SendMicrosoftTelemetry_internal (IntPtr payload, ulong portable_hash, ulong unportable_hash);
@@ -148,18 +148,17 @@ namespace Mono {
}
// All must be set except for configDir_str
static void EnableMicrosoftTelemetry (string appBundleID_str, string appSignature_str, string appVersion_str, string merpGUIPath_str, string eventType_str, string appPath_str, string configDir_str)
static void EnableMicrosoftTelemetry (string appBundleID_str, string appSignature_str, string appVersion_str, string merpGUIPath_str, string unused /* eventType_str */, string appPath_str, string configDir_str)
{
if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
using (var appBundleID_chars = RuntimeMarshal.MarshalString (appBundleID_str))
using (var appSignature_chars = RuntimeMarshal.MarshalString (appSignature_str))
using (var appVersion_chars = RuntimeMarshal.MarshalString (appVersion_str))
using (var merpGUIPath_chars = RuntimeMarshal.MarshalString (merpGUIPath_str))
using (var eventType_chars = RuntimeMarshal.MarshalString (eventType_str))
using (var appPath_chars = RuntimeMarshal.MarshalString (appPath_str))
using (var configDir_chars = RuntimeMarshal.MarshalString (configDir_str))
{
EnableMicrosoftTelemetry_internal (appBundleID_chars.Value, appSignature_chars.Value, appVersion_chars.Value, merpGUIPath_chars.Value, eventType_chars.Value, appPath_chars.Value, configDir_chars.Value);
EnableMicrosoftTelemetry_internal (appBundleID_chars.Value, appSignature_chars.Value, appVersion_chars.Value, merpGUIPath_chars.Value, appPath_chars.Value, configDir_chars.Value);
}
} else {
throw new PlatformNotSupportedException("Merp support is currently only supported on OSX.");
@@ -193,6 +192,14 @@ namespace Mono {
return new Tuple<String, ulong, ulong> (payload_str, portable_hash, unportable_hash);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void RegisterReportingForAllNativeLibs_internal ();
static void RegisterReportingForAllNativeLibs ()
{
RegisterReportingForAllNativeLibs_internal ();
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void RegisterReportingForNativeLib_internal (IntPtr modulePathSuffix, IntPtr moduleName);
@@ -34,6 +34,36 @@ namespace System.Globalization
[StructLayout (LayoutKind.Sequential)]
partial class CalendarData
{
private static string[] HEBREW_MONTH_NAMES = new[] {
"\u05EA\u05E9\u05E8\u05D9",
"\u05D7\u05E9\u05D5\u05DF",
"\u05DB\u05E1\u05DC\u05D5",
"\u05D8\u05D1\u05EA",
"\u05E9\u05D1\u05D8",
"\u05D0\u05D3\u05E8",
"\u05D0\u05D3\u05E8\u0020\u05D1",
"\u05E0\u05D9\u05E1\u05DF",
"\u05D0\u05D9\u05D9\u05E8",
"\u05E1\u05D9\u05D5\u05DF",
"\u05EA\u05DE\u05D5\u05D6",
"\u05D0\u05D1",
"\u05D0\u05DC\u05D5\u05DC" };
private static string[] HEBREW_LEAP_MONTH_NAMES = new[] {
"\u05EA\u05E9\u05E8\u05D9",
"\u05D7\u05E9\u05D5\u05DF",
"\u05DB\u05E1\u05DC\u05D5",
"\u05D8\u05D1\u05EA",
"\u05E9\u05D1\u05D8",
"\u05D0\u05D3\u05E8\u0020\u05D0",
"\u05D0\u05D3\u05E8\u0020\u05D1",
"\u05E0\u05D9\u05E1\u05DF",
"\u05D0\u05D9\u05D9\u05E8",
"\u05E1\u05D9\u05D5\u05DF",
"\u05EA\u05DE\u05D5\u05D6",
"\u05D0\u05D1",
"\u05D0\u05DC\u05D5\u05DC" };
public static int nativeGetTwoDigitYearMax (int calID)
{
// -1 mean OS does not override default BCL max year
@@ -43,7 +73,17 @@ namespace System.Globalization
static bool nativeGetCalendarData (CalendarData data, string localeName, int calendarId)
{
// TODO: Convert calendar-id to mono runtime calendar-id when it's used
return data.fill_calendar_data (localeName.ToLowerInvariant (), calendarId);
if (data.fill_calendar_data (localeName.ToLowerInvariant (), calendarId)) {
if ((CalendarId)calendarId == CalendarId.HEBREW) {
// HACK: Generate leap month names because the native code does not do it
// and tests would fail to round-trip dates on leap years.
// https://github.com/mono/mono/issues/16623
data.saMonthNames = HEBREW_MONTH_NAMES;
data.saLeapYearMonthNames = HEBREW_LEAP_MONTH_NAMES;
}
return true;
}
return false;
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
+15
View File
@@ -433,6 +433,21 @@ namespace System.IO
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static bool Cancel_internal (IntPtr handle, out MonoIOError error);
internal static bool Cancel (SafeHandle safeHandle, out MonoIOError error)
{
bool release = false;
try {
safeHandle.DangerousAddRef (ref release);
return Cancel_internal (safeHandle.DangerousGetHandle (), out error);
} finally {
if (release)
safeHandle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool Close (IntPtr handle,
out MonoIOError error);
+2 -2
View File
@@ -75,8 +75,8 @@ namespace System.IO
ERROR_SHARING_BUFFER_EXCEEDED = 36,
ERROR_HANDLE_EOF = 38,
*/ ERROR_HANDLE_DISK_FULL = 39,
/* ERROR_NOT_SUPPORTED = 50,
ERROR_REM_NOT_LIST = 51,
ERROR_NOT_SUPPORTED = 50,
/* ERROR_REM_NOT_LIST = 51,
ERROR_DUP_NAME = 52,
ERROR_BAD_NETPATH = 53,
ERROR_NETWORK_BUSY = 54,
@@ -211,12 +211,12 @@ namespace System.Runtime.InteropServices
else
perform_release = true;
/* Attempt the update to the new state, fail and retry if the initial
* state has been modified in the meantime. Decrement the ref count by
* substracting SH_RefCountOne from the state then OR in the bits for
* Dispose (if that's the reason for the Release) and closed (if the
* initial ref count was 1). */
new_state = (old_state & RefCount_Mask) - RefCount_One;
// Not closed, let's propose an update (to the ref count, just add
// StateBits.RefCountOne to the state to effectively add 1 to the ref count).
// Continue doing this until the update succeeds (because nobody
// modifies the state field between the read and write operations) or
// the state moves to closed.
new_state = old_state - RefCount_One;
if ((old_state & RefCount_Mask) == RefCount_One)
new_state |= (int) State.Closed;
if (dispose)
+5 -2
View File
@@ -1216,10 +1216,13 @@ namespace System
return false;
}
var isUtc = false;
if (dateTime.Kind != DateTimeKind.Utc) {
if (!TryAddTicks (date, -BaseUtcOffset.Ticks, out date, DateTimeKind.Utc))
return false;
}
} else
isUtc = true;
AdjustmentRule current = GetApplicableRule (date);
if (current != null) {
@@ -1231,7 +1234,7 @@ namespace System
if (forOffset)
isDst = true;
offset = baseUtcOffset;
if (date >= new DateTime (tStart.Ticks + current.DaylightDelta.Ticks, DateTimeKind.Utc))
if (isUtc || (date >= new DateTime (tStart.Ticks + current.DaylightDelta.Ticks, DateTimeKind.Utc)))
{
offset += current.DaylightDelta;
isDst = true;
@@ -1650,6 +1650,29 @@ namespace MonoTests.System.IO
}
// See https://github.com/mono/mono/issues/16032
[Test]
public void DeleteOnCloseWithFileCopy ()
{
string source = TempFolder + DSC + "source.txt";
string target = TempFolder + DSC + "target.txt";
File.WriteAllText (source, "text");
FileStream fs = new FileStream (source, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 2048,
FileOptions.DeleteOnClose);
Assert.AreEqual (true, File.Exists (source), "DCFC#1");
try {
File.Copy (fs.Name, target, true);
} finally {
fs.Dispose();
}
Assert.AreEqual (false, File.Exists (source), "DCFC#2");
Assert.AreEqual (true, File.Exists (target), "DCFC#3");
}
[Test]
public void OpenCharDeviceRepeatedly ()
{
@@ -899,6 +899,40 @@ namespace MonoTests.System.Reflection.Emit
}
[Test]
public void MethodInfoGetParametersCrash () {
// Regression test for https://github.com/mono/mono/issues/16570
//
// MethodInfo.GetParameters() called on a dynamic assembly would attempt to copy the custom_name and cookie, which could be junk depending
// on how the union is being used.
var aName = new AssemblyName("TestAssembly");
var testAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(aName, AssemblyBuilderAccess.RunAndSave);
var testModule = testAssembly.DefineDynamicModule(aName.Name, aName.Name + ".dll");
var typeBuilder = testModule.DefineType("TestType");
var ctorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
var ctorIl = ctorBuilder.GetILGenerator();
ctorIl.Emit(OpCodes.Ret);
var methodBuilder = typeBuilder.DefineMethod("TestMethod", MethodAttributes.Public, typeof(void), new[] { typeof(int[]) });
methodBuilder.DefineParameter(0, ParameterAttributes.Retval, null);
var paramBuilder = methodBuilder.DefineParameter(1, ParameterAttributes.None, null);
var attrCtor = typeof(MarshalAsAttribute).GetConstructor(new[] { typeof(UnmanagedType) });
object[] ctorArgs = { UnmanagedType.LPArray };
var attr = new CustomAttributeBuilder(attrCtor, ctorArgs);
paramBuilder.SetCustomAttribute(attr);
var methodIl = methodBuilder.GetILGenerator();
methodIl.Emit(OpCodes.Ret);
var createdType = typeBuilder.CreateType();
var methodInfo = createdType.GetMethod("TestMethod", BindingFlags.Instance | BindingFlags.Public);
methodInfo.GetParameters();
}
}
}
@@ -29,9 +29,11 @@
using System;
using System.Threading;
using NUnit.Framework;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace MonoTests.System.Threading
{
@@ -496,33 +498,102 @@ namespace MonoTests.System.Threading
}
}
[Test] // https://github.com/mono/mono/issues/12421
public void EnsurePostIsNotCalled ()
[Test] // https://github.com/mono/mono/issues/16759
[Category("NotWasm")]
public void EnsureCanceledContinuationsAreOnSameThread ()
{
SynchronizationContext mainContext = SynchronizationContext.Current;
var asc = new AssertSyncContext ();
SynchronizationContext.SetSynchronizationContext (asc);
var ct = new CancellationTokenSource ();
var tcs = new TaskCompletionSource<bool> ();
ct.Token.Register (() => tcs.TrySetCanceled ());
AsyncPump.Run(async delegate {
var _tcs = new TaskCompletionSource<bool>();
var _cts = new CancellationTokenSource();
bool taskIsCancelled = false;
Action awaitAction = async () => {
try { await tcs.Task; }
catch (OperationCanceledException) {
taskIsCancelled = true;
}
};
awaitAction ();
ct.Cancel (); // should not trigger SynchronizationContext.Post
Assert.IsTrue (taskIsCancelled);
SynchronizationContext.SetSynchronizationContext (mainContext);
var curThreadId = Thread.CurrentThread.ManagedThreadId;
var taskThreadId = 0;
var taskIsCancelled = false;
var task = Task.Run(() =>
{
taskThreadId = Thread.CurrentThread.ManagedThreadId;
_cts.Cancel();
});
_cts.Token.Register(() => _tcs.TrySetCanceled());
try
{
await _tcs.Task;
}
catch (OperationCanceledException)
{
// Continuation should run on the same thread before the task started.
Assert.AreEqual(curThreadId, Thread.CurrentThread.ManagedThreadId, "#1");
taskIsCancelled = true;
}
Assert.IsTrue (taskIsCancelled, "#2");
Assert.AreNotEqual(taskThreadId, curThreadId, "#3");
});
}
class AssertSyncContext : SynchronizationContext
public static class AsyncPump
{
public override void Post (SendOrPostCallback d, object state) =>
throw new InvalidOperationException ("SynchronizationContext.Post was not expected.");
/// <summary>Runs the specified asynchronous function.</summary>
/// <param name="func">The asynchronous function to execute.</param>
public static void Run(Func<Task> func)
{
if (func == null) throw new ArgumentNullException("func");
var prevCtx = SynchronizationContext.Current;
try
{
// Establish the new context
var syncCtx = new SingleThreadSynchronizationContext();
SynchronizationContext.SetSynchronizationContext(syncCtx);
// Invoke the function and alert the context to when it completes
var t = func();
if (t == null) throw new InvalidOperationException("No task provided.");
t.ContinueWith(delegate { syncCtx.Complete(); }, TaskScheduler.Default);
// Pump continuations and propagate any exceptions
syncCtx.RunOnCurrentThread();
t.GetAwaiter().GetResult();
}
finally { SynchronizationContext.SetSynchronizationContext(prevCtx); }
}
/// <summary>Provides a SynchronizationContext that's single-threaded.</summary>
private sealed class SingleThreadSynchronizationContext : SynchronizationContext
{
/// <summary>The queue of work items.</summary>
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> m_queue =
new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();
/// <summary>The processing thread.</summary>
private readonly Thread m_thread = Thread.CurrentThread;
/// <summary>Dispatches an asynchronous message to the synchronization context.</summary>
/// <param name="d">The System.Threading.SendOrPostCallback delegate to call.</param>
/// <param name="state">The object passed to the delegate.</param>
public override void Post(SendOrPostCallback d, object state)
{
if (d == null) throw new ArgumentNullException("d");
m_queue.Add(new KeyValuePair<SendOrPostCallback, object>(d, state));
}
/// <summary>Not supported.</summary>
public override void Send(SendOrPostCallback d, object state)
{
throw new NotSupportedException("Synchronously sending is not supported.");
}
/// <summary>Runs an loop to process all queued work items.</summary>
public void RunOnCurrentThread()
{
foreach (var workItem in m_queue.GetConsumingEnumerable())
workItem.Key(workItem.Value);
}
/// <summary>Notifies the context that no more work will arrive.</summary>
public void Complete() { m_queue.CompleteAdding(); }
}
}
}
}
@@ -54,8 +54,11 @@ namespace MonoTests.System
return "New Zealand Standard Time";
case "Europe/Athens":
return "GTB Standard Time";
case "Europe/Chisinau":
return "E. Europe Standard Time";
case "US/Eastern":
return "Eastern Standard Time";
case "America/Chicago":
case "US/Central":
return "Central Standard Time";
case "US/Pacific":
@@ -64,18 +67,57 @@ namespace MonoTests.System
case "Australia/Melbourne":
return "AUS Eastern Standard Time";
case "Europe/Brussels":
case "Europe/Copenhagen":
case "Europe/Paris":
case "Europe/Madrid":
return "Romance Standard Time";
case "Africa/Kinshasa":
return "W. Central Africa Standard Time";
case "Europe/Rome":
case "Europe/Vatican":
case "Europe/Vienna":
case "Europe/Berlin":
case "Europe/Luxembourg":
case "Europe/Malta":
case "Europe/Monaco":
case "Europe/Amsterdam":
case "Europe/Oslo":
case "Europe/San_Marino":
return "W. Europe Standard Time";
case "Canada/Eastern":
return "Eastern Standard Time";
case "Asia/Tehran":
return "Iran Standard Time";
case "Europe/Guernsey":
case "Europe/Dublin":
case "Europe/Isle_of_Man":
case "Europe/Jersey":
case "Europe/Lisbon":
case "Europe/London":
return "GMT Standard Time";
case "America/Havana":
return "Cuba Standard Time";
case "America/Anchorage":
return "Alaskan Standard Time";
case "Atlantic/Azores":
return "Azores Standard Time";
case "Asia/Jerusalem":
return "Israel Standard Time";
case "Asia/Amman":
return "Jordan Standard Time";
case "Europe/Tirane":
case "Europe/Warsaw":
return "Central European Standard Time";
case "Europe/Sofia":
case "Europe/Tallinn":
case "Europe/Riga":
case "Europe/Vilnius":
case "Europe/Kiev":
return "FLE Standard Time";
case "Europe/Prague":
case "Europe/Budapest":
case "Europe/Bratislava":
return "Central Europe Standard Time";
default:
Assert.Fail ($"No mapping defined for zone id '{id}'");
return null;
@@ -482,6 +524,218 @@ namespace MonoTests.System
Assert.AreEqual (new TimeSpan (0, 0, 0), tzi.GetUtcOffset (date));
#endif
}
[Test]
public void Bug_16395 ()
{
// Cuba, Havana (Cuba Standard Time): Jumps ahead at 12:00 AM on 3/8/2020 to 1:00 AM
CheckJumpingIntoDST ("America/Havana",
new DateTime (2020, 3, 8, 0, 0, 0), new DateTime (2020, 3, 8, 0, 30, 0), new DateTime (2020, 3, 8, 1, 0, 0),
new TimeSpan (-5, 0, 0), new TimeSpan (-4, 0, 0));
// US, Kansas City, MO (US Central Time): Jumps ahead at 2:00 AM on 3/8/2020 to 3:00 AM
CheckJumpingIntoDST ("America/Chicago",
new DateTime (2020, 3, 8, 2, 0, 0), new DateTime (2020, 3, 8, 2, 30, 0), new DateTime (2020, 3, 8, 3, 0, 0),
new TimeSpan (-6, 0, 0), new TimeSpan (-5, 0, 0));
// Anchorage, AK (Alaska Time): Jumps ahead at 2:00 AM on 3/8/2020 to 3:00 AM
CheckJumpingIntoDST ("America/Anchorage",
new DateTime (2020, 3, 8, 2, 0, 0), new DateTime (2020, 3, 8, 2, 30, 0), new DateTime (2020, 3, 8, 3, 0, 0),
new TimeSpan (-9, 0, 0), new TimeSpan (-8, 0, 0));
// Azores ST (Ponta Delgada, Portugal): Jumps ahead at 12:00 AM on 3/29/2020 to 1:00 AM
CheckJumpingIntoDST ("Atlantic/Azores",
new DateTime (2020, 3, 29, 0, 0, 0), new DateTime (2020, 3, 29, 0, 30, 0), new DateTime (2020, 3, 29, 1, 0, 0),
new TimeSpan (-1, 0, 0), new TimeSpan (0, 0, 0));
// Iran, Tehran (Iran ST): Jumps ahead at 12:00 AM on 3/21/2020 to 1:00 AM
CheckJumpingIntoDST ("Asia/Tehran",
new DateTime (2020, 3, 21, 0, 0, 0), new DateTime (2020, 3, 21, 0, 30, 0), new DateTime (2020, 3, 21, 1, 0, 0),
new TimeSpan (3, 30, 0), new TimeSpan (4, 30, 0));
// Israel, Jerusalem (Israel ST): Jumps ahead at 2:00 AM on 3/27/2020 to 3:00 AM
CheckJumpingIntoDST ("Asia/Jerusalem",
new DateTime (2020, 3, 27, 2, 0, 0), new DateTime (2020, 3, 27, 2, 30, 0), new DateTime (2020, 3, 27, 3, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// Jordan, Amman (Eastern European ST): Jumps ahead at 12:00 AM on 3/27/2020 to 1:00 AM
CheckJumpingIntoDST ("Asia/Amman",
new DateTime (2020, 3, 27, 0, 0, 0), new DateTime (2020, 3, 27, 0, 30, 0), new DateTime (2020, 3, 27, 1, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// Albania, Tirana (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Tirane",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Austria, Vienna (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Vienna",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Belgium, Brussels (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Brussels",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Bulgaria, Sofia (Eastern European ST): Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
CheckJumpingIntoDST ("Europe/Sofia",
new DateTime (2020, 3, 29, 3, 0, 0), new DateTime (2020, 3, 29, 3, 30, 0), new DateTime (2020, 3, 29, 4, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// Czechia, Prague (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Prague",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Denmark, Copenhagen (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Copenhagen",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Estonia, Tallinn (Eastern European ST): Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
CheckJumpingIntoDST ("Europe/Tallinn",
new DateTime (2020, 3, 29, 3, 0, 0), new DateTime (2020, 3, 29, 3, 30, 0), new DateTime (2020, 3, 29, 4, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// France, Paris (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Paris",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Germany, Berlin (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Berlin",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Greece, Athens (Eastern European ST): Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
CheckJumpingIntoDST ("Europe/Athens",
new DateTime (2020, 3, 29, 3, 0, 0), new DateTime (2020, 3, 29, 3, 30, 0), new DateTime (2020, 3, 29, 4, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// Guernsey (UK) Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
CheckJumpingIntoDST ("Europe/Guernsey",
new DateTime (2020, 3, 29, 1, 0, 0), new DateTime (2020, 3, 29, 1, 30, 0), new DateTime (2020, 3, 29, 2, 0, 0),
new TimeSpan (0, 0, 0), new TimeSpan (1, 0, 0));
// Holy See, Vatican City (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Vatican",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Hungary, Budapest (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Budapest",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// // Ireland, Dublin (Greenwich Mean Time -> Irish Standard Time): Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
// CheckJumpingIntoDST ("Europe/Dublin",
// new DateTime (2020, 3, 29, 1, 0, 0), new DateTime (2020, 3, 29, 1, 30, 0), new DateTime (2020, 3, 29, 2, 0, 0),
// new TimeSpan (0, 0, 0), new TimeSpan (1, 0, 0));
// UK, Douglas, Isle of Man (GMT+1:00): Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
CheckJumpingIntoDST ("Europe/Isle_of_Man",
new DateTime (2020, 3, 29, 1, 0, 0), new DateTime (2020, 3, 29, 1, 30, 0), new DateTime (2020, 3, 29, 2, 0, 0),
new TimeSpan (0, 0, 0), new TimeSpan (1, 0, 0));
// Italy, Rome (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Rome",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Jersey (UK): Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
CheckJumpingIntoDST ("Europe/Jersey",
new DateTime (2020, 3, 29, 1, 0, 0), new DateTime (2020, 3, 29, 1, 30, 0), new DateTime (2020, 3, 29, 2, 0, 0),
new TimeSpan (0, 0, 0), new TimeSpan (1, 0, 0));
// Latvia, Riga (Eastern European ST): Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
CheckJumpingIntoDST ("Europe/Riga",
new DateTime (2020, 3, 29, 3, 0, 0), new DateTime (2020, 3, 29, 3, 30, 0), new DateTime (2020, 3, 29, 4, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// Lithuania, Vilnius (Eastern European ST): Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
CheckJumpingIntoDST ("Europe/Vilnius",
new DateTime (2020, 3, 29, 3, 0, 0), new DateTime (2020, 3, 29, 3, 30, 0), new DateTime (2020, 3, 29, 4, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// Luxembourg, Luxembourg (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Luxembourg",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Malta, Valletta (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Malta",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Moldova, Chişinău (Eastern European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Chisinau",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// Monaco, Monaco (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Monaco",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Netherlands, Amsterdam (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Amsterdam",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Norway, Oslo (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Oslo",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Poland, Warsaw (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Warsaw",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Portugal, Lisbon (Western European ST): Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
CheckJumpingIntoDST ("Europe/Lisbon",
new DateTime (2020, 3, 29, 1, 0, 0), new DateTime (2020, 3, 29, 1, 30, 0), new DateTime (2020, 3, 29, 2, 0, 0),
new TimeSpan (0, 0, 0), new TimeSpan (1, 0, 0));
// San Marino, San Marino (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/San_Marino",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Slovakia, Bratislava (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Bratislava",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Spain, Madrid (Central European ST): Jumps ahead at 2:00 AM on 3/29/2020 to 3:00 AM
CheckJumpingIntoDST ("Europe/Madrid",
new DateTime (2020, 3, 29, 2, 0, 0), new DateTime (2020, 3, 29, 2, 30, 0), new DateTime (2020, 3, 29, 3, 0, 0),
new TimeSpan (1, 0, 0), new TimeSpan (2, 0, 0));
// Ukraine, Kiev (Eastern European ST): Jumps ahead at 3:00 AM on 3/29/2020 to 4:00 AM
CheckJumpingIntoDST ("Europe/Kiev",
new DateTime (2020, 3, 29, 3, 0, 0), new DateTime (2020, 3, 29, 3, 30, 0), new DateTime (2020, 3, 29, 4, 0, 0),
new TimeSpan (2, 0, 0), new TimeSpan (3, 0, 0));
// United Kingdom, London (British ST): Jumps ahead at 1:00 AM on 3/29/2020 to 2:00 AM
CheckJumpingIntoDST ("Europe/London",
new DateTime (2020, 3, 29, 1, 0, 0), new DateTime (2020, 3, 29, 1, 30, 0), new DateTime (2020, 3, 29, 2, 0, 0),
new TimeSpan (0, 0, 0), new TimeSpan (1, 0, 0));
}
void CheckJumpingIntoDST (string tzId, DateTime dstDeltaStart, DateTime inDstDelta, DateTime dstDeltaEnd, TimeSpan baseOffset, TimeSpan dstOffset)
{
var tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId (tzId));
Assert.IsFalse (tzi.IsDaylightSavingTime (dstDeltaStart), $"{tzId}: #1");
Assert.AreEqual (baseOffset, tzi.GetUtcOffset (dstDeltaStart), $"{tzId}: #2");
Assert.IsFalse (tzi.IsDaylightSavingTime (inDstDelta), $"{tzId}: #3");
Assert.AreEqual (baseOffset, tzi.GetUtcOffset (inDstDelta), $"{tzId}: #4");
Assert.IsTrue (tzi.IsDaylightSavingTime (dstDeltaEnd), $"{tzId}: #5");
Assert.AreEqual (dstOffset, tzi.GetUtcOffset (dstDeltaEnd), $"{tzId}: #6");
}
}
[TestFixture]
@@ -0,0 +1,185 @@
// 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.Diagnostics;
namespace System.Buffers
{
/// <summary>
/// Represents a heap-based, array-backed output sink into which <typeparam name="T"/> data can be written.
/// </summary>
public sealed class ArrayBufferWriter<T> : IBufferWriter<T>
{
private T[] _buffer;
private int _index;
private const int DefaultInitialBufferSize = 256;
/// <summary>
/// Creates an instance of an <see cref="ArrayBufferWriter{T}"/>, in which data can be written to,
/// with the default initial capacity.
/// </summary>
public ArrayBufferWriter()
{
_buffer = Array.Empty<T>();
_index = 0;
}
/// <summary>
/// Creates an instance of an <see cref="ArrayBufferWriter{T}"/>, in which data can be written to,
/// with an initial capacity specified.
/// </summary>
/// <param name="initialCapacity">The minimum capacity with which to initialize the underlying buffer.</param>
/// <exception cref="ArgumentException">
/// Thrown when <paramref name="initialCapacity"/> is not positive (i.e. less than or equal to 0).
/// </exception>
public ArrayBufferWriter(int initialCapacity)
{
if (initialCapacity <= 0)
throw new ArgumentException(nameof(initialCapacity));
_buffer = new T[initialCapacity];
_index = 0;
}
/// <summary>
/// Returns the data written to the underlying buffer so far, as a <see cref="ReadOnlyMemory{T}"/>.
/// </summary>
public ReadOnlyMemory<T> WrittenMemory => _buffer.AsMemory(0, _index);
/// <summary>
/// Returns the data written to the underlying buffer so far, as a <see cref="ReadOnlySpan{T}"/>.
/// </summary>
public ReadOnlySpan<T> WrittenSpan => _buffer.AsSpan(0, _index);
/// <summary>
/// Returns the amount of data written to the underlying buffer so far.
/// </summary>
public int WrittenCount => _index;
/// <summary>
/// Returns the total amount of space within the underlying buffer.
/// </summary>
public int Capacity => _buffer.Length;
/// <summary>
/// Returns the amount of space available that can still be written into without forcing the underlying buffer to grow.
/// </summary>
public int FreeCapacity => _buffer.Length - _index;
/// <summary>
/// Clears the data written to the underlying buffer.
/// </summary>
/// <remarks>
/// You must clear the <see cref="ArrayBufferWriter{T}"/> before trying to re-use it.
/// </remarks>
public void Clear()
{
Debug.Assert(_buffer.Length >= _index);
_buffer.AsSpan(0, _index).Clear();
_index = 0;
}
/// <summary>
/// Notifies <see cref="IBufferWriter{T}"/> that <paramref name="count"/> amount of data was written to the output <see cref="Span{T}"/>/<see cref="Memory{T}"/>
/// </summary>
/// <exception cref="ArgumentException">
/// Thrown when <paramref name="count"/> is negative.
/// </exception>
/// <exception cref="InvalidOperationException">
/// Thrown when attempting to advance past the end of the underlying buffer.
/// </exception>
/// <remarks>
/// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer.
/// </remarks>
public void Advance(int count)
{
if (count < 0)
throw new ArgumentException(nameof(count));
if (_index > _buffer.Length - count)
ThrowInvalidOperationException_AdvancedTooFar(_buffer.Length);
_index += count;
}
/// <summary>
/// Returns a <see cref="Memory{T}"/> to write to that is at least the requested length (specified by <paramref name="sizeHint"/>).
/// If no <paramref name="sizeHint"/> is provided (or it's equal to <code>0</code>), some non-empty buffer is returned.
/// </summary>
/// <exception cref="ArgumentException">
/// Thrown when <paramref name="sizeHint"/> is negative.
/// </exception>
/// <remarks>
/// This will never return an empty <see cref="Memory{T}"/>.
/// </remarks>
/// <remarks>
/// There is no guarantee that successive calls will return the same buffer or the same-sized buffer.
/// </remarks>
/// <remarks>
/// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer.
/// </remarks>
public Memory<T> GetMemory(int sizeHint = 0)
{
CheckAndResizeBuffer(sizeHint);
Debug.Assert(_buffer.Length > _index);
return _buffer.AsMemory(_index);
}
/// <summary>
/// Returns a <see cref="Span{T}"/> to write to that is at least the requested length (specified by <paramref name="sizeHint"/>).
/// If no <paramref name="sizeHint"/> is provided (or it's equal to <code>0</code>), some non-empty buffer is returned.
/// </summary>
/// <exception cref="ArgumentException">
/// Thrown when <paramref name="sizeHint"/> is negative.
/// </exception>
/// <remarks>
/// This will never return an empty <see cref="Span{T}"/>.
/// </remarks>
/// <remarks>
/// There is no guarantee that successive calls will return the same buffer or the same-sized buffer.
/// </remarks>
/// <remarks>
/// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer.
/// </remarks>
public Span<T> GetSpan(int sizeHint = 0)
{
CheckAndResizeBuffer(sizeHint);
Debug.Assert(_buffer.Length > _index);
return _buffer.AsSpan(_index);
}
private void CheckAndResizeBuffer(int sizeHint)
{
if (sizeHint < 0)
throw new ArgumentException(nameof(sizeHint));
if (sizeHint == 0)
{
sizeHint = 1;
}
if (sizeHint > FreeCapacity)
{
int growBy = Math.Max(sizeHint, _buffer.Length);
if (_buffer.Length == 0)
{
growBy = Math.Max(growBy, DefaultInitialBufferSize);
}
int newSize = checked(_buffer.Length + growBy);
Array.Resize(ref _buffer, newSize);
}
Debug.Assert(FreeCapacity > 0 && FreeCapacity >= sizeHint);
}
private static void ThrowInvalidOperationException_AdvancedTooFar(int capacity)
{
throw new InvalidOperationException(SR.Format(SR.BufferWriterAdvancedTooFar, capacity));
}
}
}
@@ -0,0 +1,128 @@
// 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.
namespace System.Diagnostics.CodeAnalysis
{
/// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class AllowNullAttribute : Attribute { }
/// <summary>Specifies that null is disallowed as an input even if the corresponding type allows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class DisallowNullAttribute : Attribute { }
/// <summary>Specifies that an output may be null even if the corresponding type disallows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class MaybeNullAttribute : Attribute { }
/// <summary>Specifies that an output will not be null even if the corresponding type allows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class NotNullAttribute : Attribute { }
/// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter may be null even if the corresponding type disallows it.</summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class MaybeNullWhenAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified return value condition.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter may be null.
/// </param>
public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
/// <summary>Gets the return value condition.</summary>
public bool ReturnValue { get; }
}
/// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter will not be null even if the corresponding type allows it.</summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class NotNullWhenAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified return value condition.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter will not be null.
/// </param>
public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
/// <summary>Gets the return value condition.</summary>
public bool ReturnValue { get; }
}
/// <summary>Specifies that the output will be non-null if the named parameter is non-null.</summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class NotNullIfNotNullAttribute : Attribute
{
/// <summary>Initializes the attribute with the associated parameter name.</summary>
/// <param name="parameterName">
/// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null.
/// </param>
public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName;
/// <summary>Gets the associated parameter name.</summary>
public string ParameterName { get; }
}
/// <summary>Applied to a method that will never return under any circumstance.</summary>
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class DoesNotReturnAttribute : Attribute { }
/// <summary>Specifies that the method will not return if the associated Boolean parameter is passed the specified value.</summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class DoesNotReturnIfAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified parameter value.</summary>
/// <param name="parameterValue">
/// The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to
/// the associated parameter matches this value.
/// </param>
public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue;
/// <summary>Gets the condition parameter value.</summary>
public bool ParameterValue { get; }
}
}
+3
View File
@@ -26,4 +26,7 @@ partial class SR
public const string Arg_SwitchExpressionException = "Non-exhaustive switch expression failed to match its input.";
public const string SwitchExpressionException_UnmatchedValue = "Unmatched value was {0}.";
public const string Argument_InvalidRandomRange = "Range of random number does not contain at least one possibility.";
public const string BufferWriterAdvancedTooFar = "Cannot advance past the end of the buffer, which has a size of {0}.";
public const string net_gssapi_operation_failed_detailed_majoronly = "GSSAPI operation failed with error - {0}.";
public const string net_gssapi_operation_failed_majoronly = "SSAPI operation failed with status: {0}.";
}
@@ -0,0 +1,778 @@
// 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.Diagnostics;
using System.Runtime.CompilerServices;
namespace System.Buffers
{
#if __MonoCS__
public ref partial struct SequenceReader<T> where T : IEquatable<T>
#else
public ref partial struct SequenceReader<T> where T : unmanaged, IEquatable<T>
#endif
{
/// <summary>
/// Try to read everything up to the given <paramref name="delimiter"/>.
/// </summary>
/// <param name="span">The read data, if any.</param>
/// <param name="delimiter">The delimiter to look for.</param>
/// <param name="advancePastDelimiter">True to move past the <paramref name="delimiter"/> if found.</param>
/// <returns>True if the <paramref name="delimiter"/> was found.</returns>
public bool TryReadTo(out ReadOnlySpan<T> span, T delimiter, bool advancePastDelimiter = true)
{
ReadOnlySpan<T> remaining = UnreadSpan;
int index = remaining.IndexOf(delimiter);
if (index != -1)
{
span = index == 0 ? default : remaining.Slice(0, index);
AdvanceCurrentSpan(index + (advancePastDelimiter ? 1 : 0));
return true;
}
return TryReadToSlow(out span, delimiter, advancePastDelimiter);
}
private bool TryReadToSlow(out ReadOnlySpan<T> span, T delimiter, bool advancePastDelimiter)
{
if (!TryReadToInternal(out ReadOnlySequence<T> sequence, delimiter, advancePastDelimiter, CurrentSpan.Length - CurrentSpanIndex))
{
span = default;
return false;
}
span = sequence.IsSingleSegment ? sequence.First.Span : sequence.ToArray();
return true;
}
/// <summary>
/// Try to read everything up to the given <paramref name="delimiter"/>, ignoring delimiters that are
/// preceded by <paramref name="delimiterEscape"/>.
/// </summary>
/// <param name="span">The read data, if any.</param>
/// <param name="delimiter">The delimiter to look for.</param>
/// <param name="delimiterEscape">If found prior to <paramref name="delimiter"/> it will skip that occurrence.</param>
/// <param name="advancePastDelimiter">True to move past the <paramref name="delimiter"/> if found.</param>
/// <returns>True if the <paramref name="delimiter"/> was found.</returns>
public bool TryReadTo(out ReadOnlySpan<T> span, T delimiter, T delimiterEscape, bool advancePastDelimiter = true)
{
ReadOnlySpan<T> remaining = UnreadSpan;
int index = remaining.IndexOf(delimiter);
if ((index > 0 && !remaining[index - 1].Equals(delimiterEscape)) || index == 0)
{
span = remaining.Slice(0, index);
AdvanceCurrentSpan(index + (advancePastDelimiter ? 1 : 0));
return true;
}
// This delimiter might be skipped, go down the slow path
return TryReadToSlow(out span, delimiter, delimiterEscape, index, advancePastDelimiter);
}
private bool TryReadToSlow(out ReadOnlySpan<T> span, T delimiter, T delimiterEscape, int index, bool advancePastDelimiter)
{
if (!TryReadToSlow(out ReadOnlySequence<T> sequence, delimiter, delimiterEscape, index, advancePastDelimiter))
{
span = default;
return false;
}
Debug.Assert(sequence.Length > 0);
span = sequence.IsSingleSegment ? sequence.First.Span : sequence.ToArray();
return true;
}
private bool TryReadToSlow(out ReadOnlySequence<T> sequence, T delimiter, T delimiterEscape, int index, bool advancePastDelimiter)
{
SequenceReader<T> copy = this;
ReadOnlySpan<T> remaining = UnreadSpan;
bool priorEscape = false;
do
{
if (index >= 0)
{
if (index == 0 && priorEscape)
{
// We were in the escaped state, so skip this delimiter
priorEscape = false;
Advance(index + 1);
remaining = UnreadSpan;
goto Continue;
}
else if (index > 0 && remaining[index - 1].Equals(delimiterEscape))
{
// This delimiter might be skipped
// Count our escapes
int escapeCount = 1;
int i = index - 2;
for (; i >= 0; i--)
{
if (!remaining[i].Equals(delimiterEscape))
break;
}
if (i < 0 && priorEscape)
{
// Started and ended with escape, increment once more
escapeCount++;
}
escapeCount += index - 2 - i;
if ((escapeCount & 1) != 0)
{
// An odd escape count means we're currently escaped,
// skip the delimiter and reset escaped state.
Advance(index + 1);
priorEscape = false;
remaining = UnreadSpan;
goto Continue;
}
}
// Found the delimiter. Move to it, slice, then move past it.
AdvanceCurrentSpan(index);
sequence = Sequence.Slice(copy.Position, Position);
if (advancePastDelimiter)
{
Advance(1);
}
return true;
}
else
{
// No delimiter, need to check the end of the span for odd number of escapes then advance
if (remaining.Length > 0 && remaining[remaining.Length - 1].Equals(delimiterEscape))
{
int escapeCount = 1;
int i = remaining.Length - 2;
for (; i >= 0; i--)
{
if (!remaining[i].Equals(delimiterEscape))
break;
}
escapeCount += remaining.Length - 2 - i;
if (i < 0 && priorEscape)
priorEscape = (escapeCount & 1) == 0; // equivalent to incrementing escapeCount before setting priorEscape
else
priorEscape = (escapeCount & 1) != 0;
}
else
{
priorEscape = false;
}
}
// Nothing in the current span, move to the end, checking for the skip delimiter
AdvanceCurrentSpan(remaining.Length);
remaining = CurrentSpan;
Continue:
index = remaining.IndexOf(delimiter);
} while (!End);
// Didn't find anything, reset our original state.
this = copy;
sequence = default;
return false;
}
/// <summary>
/// Try to read everything up to the given <paramref name="delimiter"/>.
/// </summary>
/// <param name="sequence">The read data, if any.</param>
/// <param name="delimiter">The delimiter to look for.</param>
/// <param name="advancePastDelimiter">True to move past the <paramref name="delimiter"/> if found.</param>
/// <returns>True if the <paramref name="delimiter"/> was found.</returns>
public bool TryReadTo(out ReadOnlySequence<T> sequence, T delimiter, bool advancePastDelimiter = true)
{
return TryReadToInternal(out sequence, delimiter, advancePastDelimiter);
}
private bool TryReadToInternal(out ReadOnlySequence<T> sequence, T delimiter, bool advancePastDelimiter, int skip = 0)
{
Debug.Assert(skip >= 0);
SequenceReader<T> copy = this;
if (skip > 0)
Advance(skip);
ReadOnlySpan<T> remaining = UnreadSpan;
while (_moreData)
{
int index = remaining.IndexOf(delimiter);
if (index != -1)
{
// Found the delimiter. Move to it, slice, then move past it.
if (index > 0)
{
AdvanceCurrentSpan(index);
}
sequence = Sequence.Slice(copy.Position, Position);
if (advancePastDelimiter)
{
Advance(1);
}
return true;
}
AdvanceCurrentSpan(remaining.Length);
remaining = CurrentSpan;
}
// Didn't find anything, reset our original state.
this = copy;
sequence = default;
return false;
}
/// <summary>
/// Try to read everything up to the given <paramref name="delimiter"/>, ignoring delimiters that are
/// preceded by <paramref name="delimiterEscape"/>.
/// </summary>
/// <param name="sequence">The read data, if any.</param>
/// <param name="delimiter">The delimiter to look for.</param>
/// <param name="delimiterEscape">If found prior to <paramref name="delimiter"/> it will skip that occurrence.</param>
/// <param name="advancePastDelimiter">True to move past the <paramref name="delimiter"/> if found.</param>
/// <returns>True if the <paramref name="delimiter"/> was found.</returns>
public bool TryReadTo(out ReadOnlySequence<T> sequence, T delimiter, T delimiterEscape, bool advancePastDelimiter = true)
{
SequenceReader<T> copy = this;
ReadOnlySpan<T> remaining = UnreadSpan;
bool priorEscape = false;
while (_moreData)
{
int index = remaining.IndexOf(delimiter);
if (index != -1)
{
if (index == 0 && priorEscape)
{
// We were in the escaped state, so skip this delimiter
priorEscape = false;
Advance(index + 1);
remaining = UnreadSpan;
continue;
}
else if (index > 0 && remaining[index - 1].Equals(delimiterEscape))
{
// This delimiter might be skipped
// Count our escapes
int escapeCount = 0;
for (int i = index; i > 0 && remaining[i - 1].Equals(delimiterEscape); i--, escapeCount++)
;
if (escapeCount == index && priorEscape)
{
// Started and ended with escape, increment once more
escapeCount++;
}
priorEscape = false;
if ((escapeCount & 1) != 0)
{
// Odd escape count means we're in the escaped state, so skip this delimiter
Advance(index + 1);
remaining = UnreadSpan;
continue;
}
}
// Found the delimiter. Move to it, slice, then move past it.
if (index > 0)
{
Advance(index);
}
sequence = Sequence.Slice(copy.Position, Position);
if (advancePastDelimiter)
{
Advance(1);
}
return true;
}
// No delimiter, need to check the end of the span for odd number of escapes then advance
{
int escapeCount = 0;
for (int i = remaining.Length; i > 0 && remaining[i - 1].Equals(delimiterEscape); i--, escapeCount++)
;
if (priorEscape && escapeCount == remaining.Length)
{
escapeCount++;
}
priorEscape = escapeCount % 2 != 0;
}
// Nothing in the current span, move to the end, checking for the skip delimiter
Advance(remaining.Length);
remaining = CurrentSpan;
}
// Didn't find anything, reset our original state.
this = copy;
sequence = default;
return false;
}
/// <summary>
/// Try to read everything up to the given <paramref name="delimiters"/>.
/// </summary>
/// <param name="span">The read data, if any.</param>
/// <param name="delimiters">The delimiters to look for.</param>
/// <param name="advancePastDelimiter">True to move past the first found instance of any of the given <paramref name="delimiters"/>.</param>
/// <returns>True if any of the <paramref name="delimiters"/> were found.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryReadToAny(out ReadOnlySpan<T> span, ReadOnlySpan<T> delimiters, bool advancePastDelimiter = true)
{
ReadOnlySpan<T> remaining = UnreadSpan;
int index = delimiters.Length == 2
? remaining.IndexOfAny(delimiters[0], delimiters[1])
: remaining.IndexOfAny(delimiters);
if (index != -1)
{
span = remaining.Slice(0, index);
Advance(index + (advancePastDelimiter ? 1 : 0));
return true;
}
return TryReadToAnySlow(out span, delimiters, advancePastDelimiter);
}
private bool TryReadToAnySlow(out ReadOnlySpan<T> span, ReadOnlySpan<T> delimiters, bool advancePastDelimiter)
{
if (!TryReadToAnyInternal(out ReadOnlySequence<T> sequence, delimiters, advancePastDelimiter, CurrentSpan.Length - CurrentSpanIndex))
{
span = default;
return false;
}
span = sequence.IsSingleSegment ? sequence.First.Span : sequence.ToArray();
return true;
}
/// <summary>
/// Try to read everything up to the given <paramref name="delimiters"/>.
/// </summary>
/// <param name="sequence">The read data, if any.</param>
/// <param name="delimiters">The delimiters to look for.</param>
/// <param name="advancePastDelimiter">True to move past the first found instance of any of the given <paramref name="delimiters"/>.</param>
/// <returns>True if any of the <paramref name="delimiters"/> were found.</returns>
public bool TryReadToAny(out ReadOnlySequence<T> sequence, ReadOnlySpan<T> delimiters, bool advancePastDelimiter = true)
{
return TryReadToAnyInternal(out sequence, delimiters, advancePastDelimiter);
}
private bool TryReadToAnyInternal(out ReadOnlySequence<T> sequence, ReadOnlySpan<T> delimiters, bool advancePastDelimiter, int skip = 0)
{
SequenceReader<T> copy = this;
if (skip > 0)
Advance(skip);
ReadOnlySpan<T> remaining = UnreadSpan;
while (!End)
{
int index = delimiters.Length == 2
? remaining.IndexOfAny(delimiters[0], delimiters[1])
: remaining.IndexOfAny(delimiters);
if (index != -1)
{
// Found one of the delimiters. Move to it, slice, then move past it.
if (index > 0)
{
AdvanceCurrentSpan(index);
}
sequence = Sequence.Slice(copy.Position, Position);
if (advancePastDelimiter)
{
Advance(1);
}
return true;
}
Advance(remaining.Length);
remaining = CurrentSpan;
}
// Didn't find anything, reset our original state.
this = copy;
sequence = default;
return false;
}
/// <summary>
/// Try to read data until the entire given <paramref name="delimiter"/> matches.
/// </summary>
/// <param name="sequence">The read data, if any.</param>
/// <param name="delimiter">The multi (T) delimiter.</param>
/// <param name="advancePastDelimiter">True to move past the <paramref name="delimiter"/> if found.</param>
/// <returns>True if the <paramref name="delimiter"/> was found.</returns>
public bool TryReadTo(out ReadOnlySequence<T> sequence, ReadOnlySpan<T> delimiter, bool advancePastDelimiter = true)
{
if (delimiter.Length == 0)
{
sequence = default;
return true;
}
SequenceReader<T> copy = this;
bool advanced = false;
while (!End)
{
if (!TryReadTo(out sequence, delimiter[0], advancePastDelimiter: false))
{
this = copy;
return false;
}
if (delimiter.Length == 1)
{
if (advancePastDelimiter)
{
Advance(1);
}
return true;
}
if (IsNext(delimiter))
{
// Probably a faster way to do this, potentially by avoiding the Advance in the previous TryReadTo call
if (advanced)
{
sequence = copy.Sequence.Slice(copy.Consumed, Consumed - copy.Consumed);
}
if (advancePastDelimiter)
{
Advance(delimiter.Length);
}
return true;
}
else
{
Advance(1);
advanced = true;
}
}
this = copy;
sequence = default;
return false;
}
/// <summary>
/// Advance until the given <paramref name="delimiter"/>, if found.
/// </summary>
/// <param name="delimiter">The delimiter to search for.</param>
/// <param name="advancePastDelimiter">True to move past the <paramref name="delimiter"/> if found.</param>
/// <returns>True if the given <paramref name="delimiter"/> was found.</returns>
public bool TryAdvanceTo(T delimiter, bool advancePastDelimiter = true)
{
ReadOnlySpan<T> remaining = UnreadSpan;
int index = remaining.IndexOf(delimiter);
if (index != -1)
{
Advance(advancePastDelimiter ? index + 1 : index);
return true;
}
return TryReadToInternal(out _, delimiter, advancePastDelimiter);
}
/// <summary>
/// Advance until any of the given <paramref name="delimiters"/>, if found.
/// </summary>
/// <param name="delimiters">The delimiters to search for.</param>
/// <param name="advancePastDelimiter">True to move past the first found instance of any of the given <paramref name="delimiters"/>.</param>
/// <returns>True if any of the given <paramref name="delimiters"/> were found.</returns>
public bool TryAdvanceToAny(ReadOnlySpan<T> delimiters, bool advancePastDelimiter = true)
{
ReadOnlySpan<T> remaining = UnreadSpan;
int index = remaining.IndexOfAny(delimiters);
if (index != -1)
{
AdvanceCurrentSpan(index + (advancePastDelimiter ? 1 : 0));
return true;
}
return TryReadToAnyInternal(out _, delimiters, advancePastDelimiter);
}
/// <summary>
/// Advance past consecutive instances of the given <paramref name="value"/>.
/// </summary>
/// <returns>How many positions the reader has been advanced.</returns>
public long AdvancePast(T value)
{
long start = Consumed;
do
{
// Advance past all matches in the current span
int i;
for (i = CurrentSpanIndex; i < CurrentSpan.Length && CurrentSpan[i].Equals(value); i++)
{
}
int advanced = i - CurrentSpanIndex;
if (advanced == 0)
{
// Didn't advance at all in this span, exit.
break;
}
AdvanceCurrentSpan(advanced);
// If we're at postion 0 after advancing and not at the End,
// we're in a new span and should continue the loop.
} while (CurrentSpanIndex == 0 && !End);
return Consumed - start;
}
/// <summary>
/// Skip consecutive instances of any of the given <paramref name="values"/>.
/// </summary>
/// <returns>How many positions the reader has been advanced.</returns>
public long AdvancePastAny(ReadOnlySpan<T> values)
{
long start = Consumed;
do
{
// Advance past all matches in the current span
int i;
for (i = CurrentSpanIndex; i < CurrentSpan.Length && values.IndexOf(CurrentSpan[i]) != -1; i++)
{
}
int advanced = i - CurrentSpanIndex;
if (advanced == 0)
{
// Didn't advance at all in this span, exit.
break;
}
AdvanceCurrentSpan(advanced);
// If we're at postion 0 after advancing and not at the End,
// we're in a new span and should continue the loop.
} while (CurrentSpanIndex == 0 && !End);
return Consumed - start;
}
/// <summary>
/// Advance past consecutive instances of any of the given values.
/// </summary>
/// <returns>How many positions the reader has been advanced.</returns>
public long AdvancePastAny(T value0, T value1, T value2, T value3)
{
long start = Consumed;
do
{
// Advance past all matches in the current span
int i;
for (i = CurrentSpanIndex; i < CurrentSpan.Length; i++)
{
T value = CurrentSpan[i];
if (!value.Equals(value0) && !value.Equals(value1) && !value.Equals(value2) && !value.Equals(value3))
{
break;
}
}
int advanced = i - CurrentSpanIndex;
if (advanced == 0)
{
// Didn't advance at all in this span, exit.
break;
}
AdvanceCurrentSpan(advanced);
// If we're at postion 0 after advancing and not at the End,
// we're in a new span and should continue the loop.
} while (CurrentSpanIndex == 0 && !End);
return Consumed - start;
}
/// <summary>
/// Advance past consecutive instances of any of the given values.
/// </summary>
/// <returns>How many positions the reader has been advanced.</returns>
public long AdvancePastAny(T value0, T value1, T value2)
{
long start = Consumed;
do
{
// Advance past all matches in the current span
int i;
for (i = CurrentSpanIndex; i < CurrentSpan.Length; i++)
{
T value = CurrentSpan[i];
if (!value.Equals(value0) && !value.Equals(value1) && !value.Equals(value2))
{
break;
}
}
int advanced = i - CurrentSpanIndex;
if (advanced == 0)
{
// Didn't advance at all in this span, exit.
break;
}
AdvanceCurrentSpan(advanced);
// If we're at postion 0 after advancing and not at the End,
// we're in a new span and should continue the loop.
} while (CurrentSpanIndex == 0 && !End);
return Consumed - start;
}
/// <summary>
/// Advance past consecutive instances of any of the given values.
/// </summary>
/// <returns>How many positions the reader has been advanced.</returns>
public long AdvancePastAny(T value0, T value1)
{
long start = Consumed;
do
{
// Advance past all matches in the current span
int i;
for (i = CurrentSpanIndex; i < CurrentSpan.Length; i++)
{
T value = CurrentSpan[i];
if (!value.Equals(value0) && !value.Equals(value1))
{
break;
}
}
int advanced = i - CurrentSpanIndex;
if (advanced == 0)
{
// Didn't advance at all in this span, exit.
break;
}
AdvanceCurrentSpan(advanced);
// If we're at postion 0 after advancing and not at the End,
// we're in a new span and should continue the loop.
} while (CurrentSpanIndex == 0 && !End);
return Consumed - start;
}
/// <summary>
/// Check to see if the given <paramref name="next"/> value is next.
/// </summary>
/// <param name="next">The value to compare the next items to.</param>
/// <param name="advancePast">Move past the <paramref name="next"/> value if found.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IsNext(T next, bool advancePast = false)
{
if (End)
return false;
if (CurrentSpan[CurrentSpanIndex].Equals(next))
{
if (advancePast)
{
AdvanceCurrentSpan(1);
}
return true;
}
return false;
}
/// <summary>
/// Check to see if the given <paramref name="next"/> values are next.
/// </summary>
/// <param name="next">The span to compare the next items to.</param>
/// <param name="advancePast">Move past the <paramref name="next"/> values if found.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IsNext(ReadOnlySpan<T> next, bool advancePast = false)
{
ReadOnlySpan<T> unread = UnreadSpan;
if (unread.StartsWith(next))
{
if (advancePast)
{
AdvanceCurrentSpan(next.Length);
}
return true;
}
// Only check the slow path if there wasn't enough to satisfy next
return unread.Length < next.Length && IsNextSlow(next, advancePast);
}
private unsafe bool IsNextSlow(ReadOnlySpan<T> next, bool advancePast)
{
ReadOnlySpan<T> currentSpan = UnreadSpan;
// We should only come in here if we need more data than we have in our current span
Debug.Assert(currentSpan.Length < next.Length);
int fullLength = next.Length;
SequencePosition nextPosition = _nextPosition;
while (next.StartsWith(currentSpan))
{
if (next.Length == currentSpan.Length)
{
// Fully matched
if (advancePast)
{
Advance(fullLength);
}
return true;
}
// Need to check the next segment
while (true)
{
if (!Sequence.TryGet(ref nextPosition, out ReadOnlyMemory<T> nextSegment, advance: true))
{
// Nothing left
return false;
}
if (nextSegment.Length > 0)
{
next = next.Slice(currentSpan.Length);
currentSpan = nextSegment.Span;
if (currentSpan.Length > next.Length)
{
currentSpan = currentSpan.Slice(0, next.Length);
}
break;
}
}
}
return false;
}
}
}
+449
View File
@@ -0,0 +1,449 @@
// 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.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using Internal.Runtime.CompilerServices;
namespace System.Buffers
{
#if __MonoCS__
public ref partial struct SequenceReader<T> where T : IEquatable<T>
#else
public ref partial struct SequenceReader<T> where T : unmanaged, IEquatable<T>
#endif
{
private SequencePosition _currentPosition;
private SequencePosition _nextPosition;
private bool _moreData;
#if __MonoCS__
private long _length;
#else
private readonly long _length;
#endif
/// <summary>
/// Create a <see cref="SequenceReader{T}"/> over the given <see cref="ReadOnlySequence{T}"/>.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public SequenceReader(ReadOnlySequence<T> sequence)
{
CurrentSpanIndex = 0;
Consumed = 0;
Sequence = sequence;
_currentPosition = sequence.Start;
_length = -1;
sequence.GetFirstSpan(out ReadOnlySpan<T> first, out _nextPosition);
CurrentSpan = first;
_moreData = first.Length > 0;
if (!_moreData && !sequence.IsSingleSegment)
{
_moreData = true;
GetNextSpan();
}
}
/// <summary>
/// True when there is no more data in the <see cref="Sequence"/>.
/// </summary>
#if __MonoCS__
public bool End => !_moreData;
#else
public readonly bool End => !_moreData;
#endif
/// <summary>
/// The underlying <see cref="ReadOnlySequence{T}"/> for the reader.
/// </summary>
#if __MonoCS__
public ReadOnlySequence<T> Sequence { get; }
#else
public readonly ReadOnlySequence<T> Sequence { get; }
#endif
/// <summary>
/// The current position in the <see cref="Sequence"/>.
/// </summary>
#if __MonoCS__
public SequencePosition Position
=> Sequence.GetPosition(CurrentSpanIndex, _currentPosition);
#else
public readonly SequencePosition Position
=> Sequence.GetPosition(CurrentSpanIndex, _currentPosition);
#endif
/// <summary>
/// The current segment in the <see cref="Sequence"/> as a span.
/// </summary>
#if __MonoCS__
public ReadOnlySpan<T> CurrentSpan { get; private set; }
#else
public ReadOnlySpan<T> CurrentSpan { readonly get; private set; }
#endif
/// <summary>
/// The index in the <see cref="CurrentSpan"/>.
/// </summary>
#if __MonoCS__
public int CurrentSpanIndex { get; private set; }
#else
public int CurrentSpanIndex { readonly get; private set; }
#endif
/// <summary>
/// The unread portion of the <see cref="CurrentSpan"/>.
/// </summary>
#if __MonoCS__
public ReadOnlySpan<T> UnreadSpan
#else
public readonly ReadOnlySpan<T> UnreadSpan
#endif
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => CurrentSpan.Slice(CurrentSpanIndex);
}
/// <summary>
/// The total number of <typeparamref name="T"/>'s processed by the reader.
/// </summary>
#if __MonoCS__
public long Consumed { get; private set; }
#else
public long Consumed { readonly get; private set; }
#endif
/// <summary>
/// Remaining <typeparamref name="T"/>'s in the reader's <see cref="Sequence"/>.
/// </summary>
#if __MonoCS__
public long Remaining => Length - Consumed;
#else
public readonly long Remaining => Length - Consumed;
#endif
/// <summary>
/// Count of <typeparamref name="T"/> in the reader's <see cref="Sequence"/>.
/// </summary>
#if __MonoCS__
public long Length
#else
public readonly long Length
#endif
{
get
{
if (_length < 0)
{
unsafe {
fixed (long* lenPtr = &_length)
// Cast-away readonly to initialize lazy field
Volatile.Write(ref Unsafe.AsRef<long>(lenPtr), Sequence.Length);
}
}
return _length;
}
}
/// <summary>
/// Peeks at the next value without advancing the reader.
/// </summary>
/// <param name="value">The next value or default if at the end.</param>
/// <returns>False if at the end of the reader.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#if __MonoCS__
public bool TryPeek(out T value)
#else
public readonly bool TryPeek(out T value)
#endif
{
if (_moreData)
{
value = CurrentSpan[CurrentSpanIndex];
return true;
}
else
{
value = default;
return false;
}
}
/// <summary>
/// Read the next value and advance the reader.
/// </summary>
/// <param name="value">The next value or default if at the end.</param>
/// <returns>False if at the end of the reader.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryRead(out T value)
{
if (End)
{
value = default;
return false;
}
value = CurrentSpan[CurrentSpanIndex];
CurrentSpanIndex++;
Consumed++;
if (CurrentSpanIndex >= CurrentSpan.Length)
{
GetNextSpan();
}
return true;
}
/// <summary>
/// Move the reader back the specified number of items.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if trying to rewind a negative amount or more than <see cref="Consumed"/>.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Rewind(long count)
{
if ((ulong)count > (ulong)Consumed)
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count);
}
Consumed -= count;
if (CurrentSpanIndex >= count)
{
CurrentSpanIndex -= (int)count;
_moreData = true;
}
else
{
// Current segment doesn't have enough data, scan backward through segments
RetreatToPreviousSpan(Consumed);
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void RetreatToPreviousSpan(long consumed)
{
ResetReader();
Advance(consumed);
}
private void ResetReader()
{
CurrentSpanIndex = 0;
Consumed = 0;
_currentPosition = Sequence.Start;
_nextPosition = _currentPosition;
if (Sequence.TryGet(ref _nextPosition, out ReadOnlyMemory<T> memory, advance: true))
{
_moreData = true;
if (memory.Length == 0)
{
CurrentSpan = default;
// No data in the first span, move to one with data
GetNextSpan();
}
else
{
CurrentSpan = memory.Span;
}
}
else
{
// No data in any spans and at end of sequence
_moreData = false;
CurrentSpan = default;
}
}
/// <summary>
/// Get the next segment with available data, if any.
/// </summary>
private void GetNextSpan()
{
if (!Sequence.IsSingleSegment)
{
SequencePosition previousNextPosition = _nextPosition;
while (Sequence.TryGet(ref _nextPosition, out ReadOnlyMemory<T> memory, advance: true))
{
_currentPosition = previousNextPosition;
if (memory.Length > 0)
{
CurrentSpan = memory.Span;
CurrentSpanIndex = 0;
return;
}
else
{
CurrentSpan = default;
CurrentSpanIndex = 0;
previousNextPosition = _nextPosition;
}
}
}
_moreData = false;
}
/// <summary>
/// Move the reader ahead the specified number of items.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Advance(long count)
{
const long TooBigOrNegative = unchecked((long)0xFFFFFFFF80000000);
if ((count & TooBigOrNegative) == 0 && CurrentSpan.Length - CurrentSpanIndex > (int)count)
{
CurrentSpanIndex += (int)count;
Consumed += count;
}
else
{
// Can't satisfy from the current span
AdvanceToNextSpan(count);
}
}
/// <summary>
/// Unchecked helper to avoid unnecessary checks where you know count is valid.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void AdvanceCurrentSpan(long count)
{
Debug.Assert(count >= 0);
Consumed += count;
CurrentSpanIndex += (int)count;
if (CurrentSpanIndex >= CurrentSpan.Length)
GetNextSpan();
}
/// <summary>
/// Only call this helper if you know that you are advancing in the current span
/// with valid count and there is no need to fetch the next one.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void AdvanceWithinSpan(long count)
{
Debug.Assert(count >= 0);
Consumed += count;
CurrentSpanIndex += (int)count;
Debug.Assert(CurrentSpanIndex < CurrentSpan.Length);
}
private void AdvanceToNextSpan(long count)
{
if (count < 0)
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count);
}
Consumed += count;
while (_moreData)
{
int remaining = CurrentSpan.Length - CurrentSpanIndex;
if (remaining > count)
{
CurrentSpanIndex += (int)count;
count = 0;
break;
}
// As there may not be any further segments we need to
// push the current index to the end of the span.
CurrentSpanIndex += remaining;
count -= remaining;
Debug.Assert(count >= 0);
GetNextSpan();
if (count == 0)
{
break;
}
}
if (count != 0)
{
// Not enough data left- adjust for where we actually ended and throw
Consumed -= count;
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count);
}
}
/// <summary>
/// Copies data from the current <see cref="Position"/> to the given <paramref name="destination"/> span if there
/// is enough data to fill it.
/// </summary>
/// <remarks>
/// This API is used to copy a fixed amount of data out of the sequence if possible. It does not advance
/// the reader. To look ahead for a specific stream of data <see cref="IsNext(ReadOnlySpan{T}, bool)"/> can be used.
/// </remarks>
/// <param name="destination">Destination span to copy to.</param>
/// <returns>True if there is enough data to completely fill the <paramref name="destination"/> span.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#if __MonoCS__
public bool TryCopyTo(Span<T> destination)
#else
public readonly bool TryCopyTo(Span<T> destination)
#endif
{
// This API doesn't advance to facilitate conditional advancement based on the data returned.
// We don't provide an advance option to allow easier utilizing of stack allocated destination spans.
// (Because we can make this method readonly we can guarantee that we won't capture the span.)
ReadOnlySpan<T> firstSpan = UnreadSpan;
if (firstSpan.Length >= destination.Length)
{
firstSpan.Slice(0, destination.Length).CopyTo(destination);
return true;
}
// Not enough in the current span to satisfy the request, fall through to the slow path
return TryCopyMultisegment(destination);
}
#if __MonoCS__
internal bool TryCopyMultisegment(Span<T> destination)
#else
internal readonly bool TryCopyMultisegment(Span<T> destination)
#endif
{
// If we don't have enough to fill the requested buffer, return false
if (Remaining < destination.Length)
return false;
ReadOnlySpan<T> firstSpan = UnreadSpan;
Debug.Assert(firstSpan.Length < destination.Length);
firstSpan.CopyTo(destination);
int copied = firstSpan.Length;
SequencePosition next = _nextPosition;
while (Sequence.TryGet(ref next, out ReadOnlyMemory<T> nextSegment, true))
{
if (nextSegment.Length > 0)
{
ReadOnlySpan<T> nextSpan = nextSegment.Span;
int toCopy = Math.Min(nextSpan.Length, destination.Length - copied);
nextSpan.Slice(0, toCopy).CopyTo(destination.Slice(copied));
copied += toCopy;
if (copied >= destination.Length)
{
break;
}
}
}
return true;
}
}
}
@@ -0,0 +1,187 @@
// 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.Buffers.Binary;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Internal.Runtime.CompilerServices;
namespace System.Buffers
{
#if !__MonoCS__
public static partial class SequenceReaderExtensions
{
/// <summary>
/// Try to read the given type out of the buffer if possible. Warning: this is dangerous to use with arbitrary
/// structs- see remarks for full details.
/// </summary>
/// <remarks>
/// IMPORTANT: The read is a straight copy of bits. If a struct depends on specific state of it's members to
/// behave correctly this can lead to exceptions, etc. If reading endian specific integers, use the explicit
/// overloads such as <see cref="TryReadLittleEndian(ref SequenceReader{byte}, out short)"/>
/// </remarks>
/// <returns>
/// True if successful. <paramref name="value"/> will be default if failed (due to lack of space).
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe bool TryRead<T>(ref this SequenceReader<byte> reader, out T value) where T : unmanaged
{
ReadOnlySpan<byte> span = reader.UnreadSpan;
if (span.Length < sizeof(T))
return TryReadMultisegment(ref reader, out value);
value = Unsafe.ReadUnaligned<T>(ref MemoryMarshal.GetReference(span));
reader.Advance(sizeof(T));
return true;
}
private static unsafe bool TryReadMultisegment<T>(ref SequenceReader<byte> reader, out T value) where T : unmanaged
{
Debug.Assert(reader.UnreadSpan.Length < sizeof(T));
// Not enough data in the current segment, try to peek for the data we need.
T buffer = default;
Span<byte> tempSpan = new Span<byte>(&buffer, sizeof(T));
if (!reader.TryCopyTo(tempSpan))
{
value = default;
return false;
}
value = Unsafe.ReadUnaligned<T>(ref MemoryMarshal.GetReference(tempSpan));
reader.Advance(sizeof(T));
return true;
}
/// <summary>
/// Reads an <see cref="short"/> as little endian.
/// </summary>
/// <returns>False if there wasn't enough data for an <see cref="short"/>.</returns>
public static bool TryReadLittleEndian(ref this SequenceReader<byte> reader, out short value)
{
if (BitConverter.IsLittleEndian)
{
return reader.TryRead(out value);
}
return TryReadReverseEndianness(ref reader, out value);
}
/// <summary>
/// Reads an <see cref="short"/> as big endian.
/// </summary>
/// <returns>False if there wasn't enough data for an <see cref="short"/>.</returns>
public static bool TryReadBigEndian(ref this SequenceReader<byte> reader, out short value)
{
if (!BitConverter.IsLittleEndian)
{
return reader.TryRead(out value);
}
return TryReadReverseEndianness(ref reader, out value);
}
private static bool TryReadReverseEndianness(ref SequenceReader<byte> reader, out short value)
{
if (reader.TryRead(out value))
{
value = BinaryPrimitives.ReverseEndianness(value);
return true;
}
return false;
}
/// <summary>
/// Reads an <see cref="int"/> as little endian.
/// </summary>
/// <returns>False if there wasn't enough data for an <see cref="int"/>.</returns>
public static bool TryReadLittleEndian(ref this SequenceReader<byte> reader, out int value)
{
if (BitConverter.IsLittleEndian)
{
return reader.TryRead(out value);
}
return TryReadReverseEndianness(ref reader, out value);
}
/// <summary>
/// Reads an <see cref="int"/> as big endian.
/// </summary>
/// <returns>False if there wasn't enough data for an <see cref="int"/>.</returns>
public static bool TryReadBigEndian(ref this SequenceReader<byte> reader, out int value)
{
if (!BitConverter.IsLittleEndian)
{
return reader.TryRead(out value);
}
return TryReadReverseEndianness(ref reader, out value);
}
private static bool TryReadReverseEndianness(ref SequenceReader<byte> reader, out int value)
{
if (reader.TryRead(out value))
{
value = BinaryPrimitives.ReverseEndianness(value);
return true;
}
return false;
}
/// <summary>
/// Reads an <see cref="long"/> as little endian.
/// </summary>
/// <returns>False if there wasn't enough data for an <see cref="long"/>.</returns>
public static bool TryReadLittleEndian(ref this SequenceReader<byte> reader, out long value)
{
if (BitConverter.IsLittleEndian)
{
return reader.TryRead(out value);
}
return TryReadReverseEndianness(ref reader, out value);
}
/// <summary>
/// Reads an <see cref="long"/> as big endian.
/// </summary>
/// <returns>False if there wasn't enough data for an <see cref="long"/>.</returns>
public static bool TryReadBigEndian(ref this SequenceReader<byte> reader, out long value)
{
if (!BitConverter.IsLittleEndian)
{
return reader.TryRead(out value);
}
return TryReadReverseEndianness(ref reader, out value);
}
private static bool TryReadReverseEndianness(ref SequenceReader<byte> reader, out long value)
{
if (reader.TryRead(out value))
{
value = BinaryPrimitives.ReverseEndianness(value);
return true;
}
return false;
}
}
#else
public static partial class SequenceReaderExtensions
{
public static bool TryReadBigEndian(this System.Buffers.SequenceReader<byte> reader, out short value) => throw new PlatformNotSupportedException();
public static bool TryReadBigEndian(this System.Buffers.SequenceReader<byte> reader, out int value) => throw new PlatformNotSupportedException();
public static bool TryReadBigEndian(this System.Buffers.SequenceReader<byte> reader, out long value) => throw new PlatformNotSupportedException();
public static bool TryReadLittleEndian(this System.Buffers.SequenceReader<byte> reader, out short value) => throw new PlatformNotSupportedException();
public static bool TryReadLittleEndian(this System.Buffers.SequenceReader<byte> reader, out int value) => throw new PlatformNotSupportedException();
public static bool TryReadLittleEndian(this System.Buffers.SequenceReader<byte> reader, out long value) => throw new PlatformNotSupportedException();
}
#endif
}
+6 -1
View File
@@ -336,6 +336,7 @@
<Compile Include="..\..\..\external\corefx\src\Common\src\CoreLib\System\Globalization\DaylightTime.cs" />
<Compile Include="..\..\..\external\corefx\src\Common\src\CoreLib\System\Globalization\DigitShapes.cs" />
<Compile Include="..\..\..\external\corefx\src\Common\src\CoreLib\System\Globalization\GlobalizationExtensions.cs" />
<Compile Include="..\..\..\external\corefx\src\Common\src\CoreLib\System\Globalization\HebrewNumber.cs" />
<Compile Include="..\..\..\external\corefx\src\Common\src\CoreLib\System\Globalization\InternalGlobalizationHelper.cs" />
<Compile Include="..\..\..\external\corefx\src\Common\src\CoreLib\System\Globalization\NumberStyles.cs" />
<Compile Include="..\..\..\external\corefx\src\Common\src\CoreLib\System\Globalization\SortVersion.cs" />
@@ -1072,7 +1073,6 @@
<Compile Include="..\referencesource\mscorlib\system\globalization\gregoriancalendarhelper.cs" />
<Compile Include="..\referencesource\mscorlib\system\globalization\gregoriancalendartypes.cs" />
<Compile Include="..\referencesource\mscorlib\system\globalization\hebrewcalendar.cs" />
<Compile Include="..\referencesource\mscorlib\system\globalization\hebrewnumber.cs" />
<Compile Include="..\referencesource\mscorlib\system\globalization\hijricalendar.cs" />
<Compile Include="..\referencesource\mscorlib\system\globalization\japanesecalendar.cs" />
<Compile Include="..\referencesource\mscorlib\system\globalization\japaneselunisolarcalendar.cs" />
@@ -1861,6 +1861,7 @@
<Compile Include="coreclr\SorterArray.cs" />
<Compile Include="corefx\AesCcm.cs" />
<Compile Include="corefx\AesGcm.cs" />
<Compile Include="corefx\ArrayBufferWriter.cs" />
<Compile Include="corefx\AwaitTaskContinuation.cs" />
<Compile Include="corefx\BinaryEnums.cs" />
<Compile Include="corefx\CompareInfo.cs" />
@@ -1879,6 +1880,7 @@
<Compile Include="corefx\IncrementingPollingCounter.cs" />
<Compile Include="corefx\MethodInfo.cs" />
<Compile Include="corefx\MonoLinqHelper.cs" />
<Compile Include="corefx\NullableAttributes.cs" />
<Compile Include="corefx\PbeEncryptionAlgorithm.cs" />
<Compile Include="corefx\PbeParameters.cs" />
<Compile Include="corefx\PollingCounter.cs" />
@@ -1887,6 +1889,9 @@
<Compile Include="corefx\RuntimeImports.cs" />
<Compile Include="corefx\SR.cs" />
<Compile Include="corefx\SR.missing.cs" />
<Compile Include="corefx\SequenceReader.Search.cs" />
<Compile Include="corefx\SequenceReader.cs" />
<Compile Include="corefx\SequenceReaderExtensions.Binary.cs" />
<Compile Include="corefx\Stream.cs" />
<Compile Include="corefx\SwitchExpressionException.cs" />
<Compile Include="corefx\SynchronizationContext.cs" />
+6 -1
View File
@@ -1105,7 +1105,7 @@ ReferenceSources/AppContextDefaultValues.cs
../referencesource/mscorlib/system/globalization/gregoriancalendarhelper.cs
../referencesource/mscorlib/system/globalization/gregoriancalendartypes.cs
../referencesource/mscorlib/system/globalization/hebrewcalendar.cs
../referencesource/mscorlib/system/globalization/hebrewnumber.cs
../../../external/corefx/src/Common/src/CoreLib/System/Globalization/HebrewNumber.cs
../referencesource/mscorlib/system/globalization/hijricalendar.cs
../referencesource/mscorlib/system/globalization/japanesecalendar.cs
../referencesource/mscorlib/system/globalization/japaneselunisolarcalendar.cs
@@ -1631,6 +1631,11 @@ corefx/AesGcm.cs
corefx/IncrementingEventCounter.cs
corefx/IncrementingPollingCounter.cs
corefx/PollingCounter.cs
corefx/NullableAttributes.cs
corefx/ArrayBufferWriter.cs
corefx/SequenceReader.cs
corefx/SequenceReader.Search.cs
corefx/SequenceReaderExtensions.Binary.cs
corert/DependencyReductionRootAttribute.cs
corert/AddrofIntrinsics.cs
+12 -12
View File
@@ -547,34 +547,34 @@
<ProjectReference Include="../corlib/corlib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Core.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Core.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Core.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Xml.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Xml.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Xml.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Xml.Linq.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Xml.Linq.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Xml.Linq.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Xml.Linq.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/System.Configuration.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/System.Configuration.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/System.Configuration.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/System.Configuration.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll">
<Reference Include="./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>./../../../external/binary-reference-assemblies/v4.6/mscorlib.dll</HintPath>
<HintPath>./../../../external/binary-reference-assemblies/v4.7/mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
+12 -1
View File
@@ -22,6 +22,7 @@ install-local:
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.7-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.7.1-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.7.2-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.8-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.5-api/Facades
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.5.1-api/Facades
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.5.2-api/Facades
@@ -31,6 +32,7 @@ install-local:
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.7-api/Facades
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.7.1-api/Facades
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.7.2-api/Facades
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.8-api/Facades
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v2.0/*.dll $(PROFILE_DIR)/2.0-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v3.5/*.dll $(PROFILE_DIR)/3.5-api
@@ -44,6 +46,7 @@ install-local:
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7/*.dll $(PROFILE_DIR)/4.7-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7.1/*.dll $(PROFILE_DIR)/4.7.1-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7.2/*.dll $(PROFILE_DIR)/4.7.2-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.8/*.dll $(PROFILE_DIR)/4.8-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5/Facades/*.dll $(PROFILE_DIR)/4.5-api/Facades
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5.1/Facades/*.dll $(PROFILE_DIR)/4.5.1-api/Facades
@@ -54,6 +57,7 @@ install-local:
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7/Facades/*.dll $(PROFILE_DIR)/4.7-api/Facades
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7.1/Facades/*.dll $(PROFILE_DIR)/4.7.1-api/Facades
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7.2/Facades/*.dll $(PROFILE_DIR)/4.7.2-api/Facades
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.8/Facades/*.dll $(PROFILE_DIR)/4.8-api/Facades
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/2.0-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.0-api
@@ -65,9 +69,11 @@ install-local:
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.2-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7.1-api
rm -f $(PROFILE_DIR)/4.7.1-api/ICSharpCode.SharpZipLib.dll
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7.2-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.8-api
rm -f $(PROFILE_DIR)/4.7.1-api/ICSharpCode.SharpZipLib.dll
rm -f $(PROFILE_DIR)/4.7.2-api/ICSharpCode.SharpZipLib.dll
rm -f $(PROFILE_DIR)/4.8-api/ICSharpCode.SharpZipLib.dll
# Unfortunately, a few programs (most notably NUnit and FSharp) have hardcoded checks for <prefix>/lib/mono/4.0/mscorlib.dll or Mono.Posix.dll,
# so we need to place something there or those tools break. We decided to symlink to the reference assembly for now.
@@ -77,6 +83,7 @@ install-local:
ln -sf ../4.0-api/Mono.Posix.dll $(PROFILE_DIR)/4.0/Mono.Posix.dll
DISTFILES = \
$(wildcard ../../../external/binary-reference-assemblies/v4.8/Facades/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.7.2/Facades/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.7.1/Facades/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.7/Facades/*.dll) \
@@ -86,6 +93,7 @@ DISTFILES = \
$(wildcard ../../../external/binary-reference-assemblies/v4.5.2/Facades/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.5.1/Facades/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.5/Facades/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.8/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.7.2/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.7.1/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v4.7/*.dll) \
@@ -99,6 +107,7 @@ DISTFILES = \
$(wildcard ../../../external/binary-reference-assemblies/v3.5/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/v2.0/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/mono/*.dll) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.8/Facades/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.7.2/Facades/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.7.1/Facades/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.7/Facades/*.cs) \
@@ -108,6 +117,7 @@ DISTFILES = \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.5.2/Facades/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.5.1/Facades/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.5/Facades/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.8/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.7.2/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.7.1/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v4.7/*.cs) \
@@ -121,6 +131,7 @@ DISTFILES = \
$(wildcard ../../../external/binary-reference-assemblies/src/v3.5/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/v2.0/*.cs) \
$(wildcard ../../../external/binary-reference-assemblies/src/mono/*.cs) \
../../../external/binary-reference-assemblies/v4.8/Makefile \
../../../external/binary-reference-assemblies/v4.7.2/Makefile \
../../../external/binary-reference-assemblies/v4.7.1/Makefile \
../../../external/binary-reference-assemblies/v4.7/Makefile \
@@ -19,8 +19,9 @@ namespace System.Diagnostics {
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Collections;
using System.Threading;
using System.Collections;
using Microsoft.Win32.SafeHandles;
internal delegate void UserCallBack(String data);
@@ -58,10 +59,10 @@ namespace System.Diagnostics {
// Cache the last position scanned in sb when searching for lines.
private int currentLinePos;
#if MONO
//users to coordinate between Dispose and BeginReadLine
private object syncObject = new Object ();
//users to coordinate between Dispose and ReadBuffer
private object syncObject = new Object ();
private IAsyncResult asyncReadResult = null;
#endif
internal AsyncStreamReader(Process process, Stream stream, UserCallBack callback, Encoding encoding)
@@ -115,8 +116,31 @@ namespace System.Diagnostics {
lock (syncObject) {
#endif
if (disposing) {
if (stream != null)
if (stream != null) {
#if MONO
if (asyncReadResult != null && !asyncReadResult.IsCompleted) {
// Closing underlying stream when having pending async read request in progress is
// not portable and racy by design. Try to cancel pending async read before closing stream.
// We are still holding lock that will prevent new async read requests to queue up
// before we have closed and invalidated the stream.
if (stream is FileStream) {
SafeHandle tmpStreamHandle = ((FileStream)stream).SafeFileHandle;
while (!asyncReadResult.IsCompleted) {
MonoIOError error;
if (!MonoIO.Cancel (tmpStreamHandle, out error) && error == MonoIOError.ERROR_NOT_SUPPORTED) {
// Platform don't support canceling pending IO requests on stream. If an async pending read
// is still in flight when closing stream, it could trigger a race condition.
break;
}
// Wait for a short time for pending async read to cancel/complete/fail.
asyncReadResult.AsyncWaitHandle.WaitOne (200);
}
}
}
#endif
stream.Close();
}
}
if (stream != null) {
stream = null;
@@ -151,7 +175,11 @@ namespace System.Diagnostics {
if( sb == null ) {
sb = new StringBuilder(DefaultBufferSize);
#if MONO
asyncReadResult = stream.BeginRead (byteBuffer, 0 , byteBuffer.Length, new AsyncCallback (ReadBuffer), null);
#else
stream.BeginRead(byteBuffer, 0 , byteBuffer.Length, new AsyncCallback(ReadBuffer), null);
#endif
}
else {
FlushMessageQueue();
@@ -169,12 +197,17 @@ namespace System.Diagnostics {
try {
#if MONO
var stream = this.stream;
if (stream == null)
byteLen = 0;
else
#endif
lock (syncObject) {
Debug.Assert (ar.IsCompleted);
asyncReadResult = null;
if (this.stream == null)
byteLen = 0;
else
byteLen = stream.EndRead (ar);
}
#else
byteLen = stream.EndRead(ar);
#endif
}
catch (IOException ) {
// We should ideally consume errors from operations getting cancelled
@@ -242,10 +275,10 @@ retry_dispose:
byteLen = 0;
goto retry_dispose;
}
#endif
stream.BeginRead(byteBuffer, 0 , byteBuffer.Length, new AsyncCallback(ReadBuffer), null);
#if MONO
asyncReadResult = stream.BeginRead (byteBuffer, 0 , byteBuffer.Length, new AsyncCallback(ReadBuffer), null);
}
#else
stream.BeginRead(byteBuffer, 0 , byteBuffer.Length, new AsyncCallback(ReadBuffer), null);
#endif
}
}
@@ -2858,17 +2858,24 @@ namespace System
return candidates;
}
// Note the following assumptions on name:
// 1. Callers assume that null == "*"
// 2. FilterHelper chops off "*"
//
private ListBuilder<ConstructorInfo> GetConstructorCandidates(
string name, BindingFlags bindingAttr, CallingConventions callConv,
Type[] types, bool allowPrefixLookup)
{
bool prefixLookup, ignoreCase;
MemberListType listType;
RuntimeType.FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
#if MONO
if (!string.IsNullOrEmpty (name) && name != ConstructorInfo.ConstructorName && name != ConstructorInfo.TypeConstructorName)
#if MONO
if ((!prefixLookup && name?.Length == 0) ||
(!string.IsNullOrEmpty (name) && name != ConstructorInfo.ConstructorName && name != ConstructorInfo.TypeConstructorName)) {
return new ListBuilder<ConstructorInfo> (0);
}
RuntimeConstructorInfo[] cache = GetConstructors_internal (bindingAttr, this);
#else
RuntimeConstructorInfo[] cache = Cache.GetConstructorList(listType, name);
@@ -1316,11 +1316,7 @@ namespace System.Threading
{
// capture the sync context
if (0 == (options & CaptureOptions.IgnoreSyncCtx))
#if MONO
syncCtxNew = ecCurrent.SynchronizationContext;
#else
syncCtxNew = (ecCurrent.SynchronizationContext == null) ? null : ecCurrent.SynchronizationContext.CreateCopy();
#endif
#if FEATURE_REMOTING
// copy over the Logical Call Context
+4
View File
@@ -38,6 +38,10 @@ DISABLE_MCS_DOCS = yes
endif
endif
ifdef MCS_MODE
DISABLE_MCS_DOCS = yes
endif
csproj-local test-local run-test-local run-test-ondotnet-local doc-update:
clean-local:
+1
View File
@@ -257,6 +257,7 @@ namespace Mono.CSharp
sdk_directory.Add ("4.7", new string [] { "4.7-api", "v4.0.30319" });
sdk_directory.Add ("4.7.1", new string [] { "4.7.1-api", "v4.0.30319" });
sdk_directory.Add ("4.7.2", new string [] { "4.7.2-api", "v4.0.30319" });
sdk_directory.Add ("4.8", new string [] { "4.8-api", "v4.0.30319" });
sdk_directory.Add ("4.x", new string [] { "4.5", "net_4_x", "v4.0.30319" });
}
+1
View File
@@ -30,6 +30,7 @@ ROSLYN_FILES_TO_COPY_FOR_MSBUILD = \
$(ROSLYN_CSC_DIR)/Microsoft.Build.Tasks.CodeAnalysis.dll \
$(ROSLYN_CSC_DIR)/Microsoft.CSharp.Core.targets \
$(ROSLYN_CSC_DIR)/Microsoft.Managed.Core.targets \
$(ROSLYN_CSC_DIR)/Microsoft.Managed.EditorConfig.targets \
$(ROSLYN_CSC_DIR)/Microsoft.VisualBasic.Core.targets
DISTFILES = $(ROSLYN_FILES_FOR_MONO) $(ROSLYN_FILES_TO_COPY_FOR_MSBUILD) csi-test.csx
+4 -1
View File
@@ -2,6 +2,7 @@ thisdir = tools
net_4_5_dirs := \
al \
aprofutil \
linker \
culevel \
genxs \
@@ -53,13 +54,15 @@ net_4_5_dirs := \
build_SUBDIRS =
build_PARALLEL_SUBDIRS := resgen gacutil security culevel upload-to-sentry mono-helix-client commoncryptogenerator resx2sr linker cil-strip corcompare mono-api-diff mono-api-html
monodroid_tools_SUBDIRS =
monodroid_tools_PARALLEL_SUBDIRS = cil-strip linker-analyzer mkbundle mdoc mono-symbolicate corcompare mono-api-diff mono-api-html pdb2mdb nunit-lite
monodroid_tools_PARALLEL_SUBDIRS = aprofutil cil-strip linker-analyzer mkbundle mdoc mono-symbolicate corcompare mono-api-diff mono-api-html pdb2mdb nunit-lite
monodroid_SUBDIRS = nunit-lite
monotouch_SUBDIRS = nunit-lite
monotouch_tv_SUBDIRS = nunit-lite
monotouch_watch_SUBDIRS = nunit-lite
monotouch_tools_SUBDIRS =
monotouch_tools_PARALLEL_SUBDIRS = corcompare mono-api-html
xammac_SUBDIRS = nunit-lite
xammac_net_4_5_SUBDIRS = nunit-lite
net_4_x_SUBDIRS =
net_4_x_PARALLEL_SUBDIRS = $(net_4_5_dirs)
wasm_tools_SUBDIRS =
+8
View File
@@ -0,0 +1,8 @@
thisdir = tools/aprofutil
include ../../build/rules.make
PROGRAM = aprofutil.exe
LIB_REFS = System System.Core Mono.Profiler.Log
include ../../build/executable.make
+299
View File
@@ -0,0 +1,299 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Text.RegularExpressions;
using Mono.Options;
using Mono.Profiler.Aot;
using static System.Console;
namespace aotprofiletool {
class MainClass {
static readonly string Name = "aotprofile-tool";
static bool AdbForward;
static bool Methods;
static bool Modules;
static bool Summary;
static bool Types;
static bool Verbose;
static Regex FilterMethod;
static Regex FilterModule;
static Regex FilterType;
static string Output;
static int Port = -1;
static string ProcessArguments (string [] args)
{
var help = false;
var options = new OptionSet {
$"Usage: {Name}.exe OPTIONS* <aotprofile-file>",
"",
"Processes AOTPROFILE files created by Mono's AOT Profiler",
"",
"Copyright 2019 Microsoft Corporation",
"",
"Options:",
{ "h|help|?",
"Show this message and exit",
v => help = v != null },
{ "a|all",
"Show modules, types and methods in the profile",
v => Modules = Types = Methods = true },
{ "d|modules",
"Show modules in the profile",
v => Modules = true },
{ "f|adb-forward",
"Set adb socket forwarding for Android",
v => AdbForward = true },
{ "filter-method=",
"Filter by method with regex {VALUE}",
v => FilterMethod = new Regex (v) },
{ "filter-module=",
"Filter by module with regex {VALUE}",
v => FilterModule = new Regex (v) },
{ "filter-type=",
"Filter by type with regex {VALUE}",
v => FilterType = new Regex (v) },
{ "m|methods",
"Show methods in the profile",
v => Methods = true },
{ "o|output=",
"Write profile to {OUTPUT} file",
v => Output = v },
{ "p|port=",
"Read profile from aot profiler using local connection on {PORT}",
v => int.TryParse (v, out Port) },
{ "s|summary",
"Show summary of the profile",
v => Summary = true },
{ "t|types",
"Show types in the profile",
v => Types = true },
{ "v|verbose",
"Output information about progress during the run of the tool",
v => Verbose = true },
"",
"If no other option than -v is used then --all is used by default"
};
var remaining = options.Parse (args);
if (help || args.Length < 1) {
options.WriteOptionDescriptions (Out);
Environment.Exit (0);
}
if (remaining.Count != 1 && Port < 0) {
Error ("Please specify one <aotprofile-file> to process or network PORT with -p.");
Environment.Exit (2);
}
return remaining.Count > 0 ? remaining [0] : null;
}
static ProfileData ReadProfileFromPort (ProfileReader reader)
{
ProfileData pd;
if (AdbForward) {
var cmdArgs = $"forward tcp:{Port} tcp:{Port}";
if (Verbose)
ColorWriteLine ($"Calling 'adb {cmdArgs}'...", ConsoleColor.Yellow);
System.Diagnostics.Process.Start ("adb", cmdArgs);
}
using (var client = new TcpClient ("127.0.0.1", Port)) {
using (var stream = client.GetStream ()) {
var msgData = System.Text.Encoding.ASCII.GetBytes ("save\n");
stream.Write (msgData, 0, msgData.Length);
if (Verbose)
ColorWriteLine ($"Reading from '127.0.0.1:{Port}'...", ConsoleColor.Yellow);
using (var memoryStream = new MemoryStream (128 * 1024)) {
var data = new byte [4 * 1024];
int len;
while ((len = stream.Read (data, 0, data.Length)) > 0) {
memoryStream.Write (data, 0, len);
if (Verbose)
ColorWrite ($"Read {len} bytes...\r", ConsoleColor.Yellow);
}
if (Verbose)
ColorWriteLine ($"Read total {memoryStream.Length} bytes...", ConsoleColor.Yellow);
memoryStream.Seek (0, SeekOrigin.Begin);
pd = reader.ReadAllData (memoryStream);
}
}
}
return pd;
}
public static void Main (string [] args)
{
var path = ProcessArguments (args);
if (args.Length == 1) {
Modules = Types = Methods = true;
}
var reader = new ProfileReader ();
ProfileData pd = null;
if (path == null) {
if (Port < 0) {
Error ($"You should specify path or -p PORT to read the profile.");
Environment.Exit (4);
} else {
try {
pd = ReadProfileFromPort (reader);
} catch (Exception e) {
Error ($"Unable to read profile through local port: {Port}.\n{e}");
Environment.Exit (5);
}
}
} else if (!File.Exists (path)) {
Error ($"'{path}' doesn't exist.");
Environment.Exit (3);
} else {
using (var stream = new FileStream (path, FileMode.Open)) {
if (Verbose)
ColorWriteLine ($"Reading '{path}'...", ConsoleColor.Yellow);
pd = reader.ReadAllData (stream);
}
}
List<MethodRecord> methods = new List<MethodRecord> (pd.Methods);
ICollection<TypeRecord> types = new List<TypeRecord> (pd.Types);
ICollection<ModuleRecord> modules = new List<ModuleRecord> (pd.Modules);
if (FilterMethod != null || FilterType != null || FilterModule != null) {
methods = new List<MethodRecord> ();
types = new HashSet<TypeRecord> ();
modules = new HashSet<ModuleRecord> ();
foreach (var method in pd.Methods) {
var type = method.Type;
var module = type.Module;
if (FilterModule != null) {
var match = FilterModule.Match (module.ToString ());
if (!match.Success)
continue;
}
if (FilterType != null) {
var match = FilterType.Match (method.Type.ToString ());
if (!match.Success)
continue;
}
if (FilterMethod != null) {
var match = FilterMethod.Match (method.ToString ());
if (!match.Success)
continue;
}
methods.Add (method);
types.Add (type);
modules.Add (module);
}
}
if (FilterMethod == null && FilterType != null) {
foreach (var type in pd.Types) {
if (types.Contains (type))
continue;
var match = FilterType.Match (type.ToString ());
if (!match.Success)
continue;
types.Add (type);
}
}
if (Modules) {
ColorWriteLine ($"Modules:", ConsoleColor.Green);
foreach (var module in modules)
WriteLine ($"\t{module.Mvid} {module.ToString ()}");
}
if (Types) {
ColorWriteLine ($"Types:", ConsoleColor.Green);
foreach (var type in types)
WriteLine ($"\t{type}");
}
if (Methods) {
ColorWriteLine ($"Methods:", ConsoleColor.Green);
foreach (var method in methods)
WriteLine ($"\t{method}");
}
if (Summary) {
ColorWriteLine ($"Summary:", ConsoleColor.Green);
WriteLine ($"\tModules: {modules.Count.ToString ("N0"),10}{(modules.Count != pd.Modules.Length ? $" (of {pd.Modules.Length})" : "" )}");
WriteLine ($"\tTypes: {types.Count.ToString ("N0"),10}{(types.Count != pd.Types.Length ? $" (of {pd.Types.Length})" : "")}");
WriteLine ($"\tMethods: {methods.Count.ToString ("N0"),10}{(methods.Count != pd.Methods.Length ? $" (of {pd.Methods.Length})" : "")}");
}
if (!string.IsNullOrEmpty (Output)) {
if (Verbose)
ColorWriteLine ($"Going to write the profile to '{Output}'", ConsoleColor.Yellow);
var modulesArray = new ModuleRecord [modules.Count];
modules.CopyTo (modulesArray, 0);
var typesArray = new TypeRecord [types.Count];
types.CopyTo (typesArray, 0);
var updatedPD = new ProfileData (modulesArray, typesArray, methods.ToArray ());
using (var stream = new FileStream (Output, FileMode.Create)) {
var writer = new ProfileWriter ();
writer.WriteAllData (stream, updatedPD);
}
}
}
static void ColorMessage (string message, ConsoleColor color, TextWriter writer, bool writeLine = true)
{
ForegroundColor = color;
if (writeLine)
writer.WriteLine (message);
else
writer.Write (message);
ResetColor ();
}
public static void ColorWriteLine (string message, ConsoleColor color) => ColorMessage (message, color, Out);
public static void ColorWrite (string message, ConsoleColor color) => ColorMessage (message, color, Out, false);
public static void Error (string message) => ColorMessage ($"Error: {Name}: {message}", ConsoleColor.Red, Console.Error);
public static void Warning (string message) => ColorMessage ($"Warning: {Name}: {message}", ConsoleColor.Yellow, Console.Error);
}
}
+70
View File
@@ -0,0 +1,70 @@
**aprofutil** is a tool to inspect AOT profiler files
```
Usage: aprofutil.exe OPTIONS* <aotprofile-file>
Processes AOTPROFILE files created by Mono's AOT Profiler
Copyright 2019 Microsoft Corporation
Options:
-h, --help, -? Show this message and exit
-a, --all Show modules, types and methods in the profile
-d, --modules Show modules in the profile
--filter-method=VALUE Filter by method with regex VALUE
--filter-module=VALUE Filter by module with regex VALUE
--filter-type=VALUE Filter by type with regex VALUE
-m, --methods Show methods in the profile
-s, --summary Show summary of the profile
-t, --types Show types in the profile
-v, --verbose Output information about progress during the run
of the tool
If no other option than -v is used then --all is used by default
```
It can be use to show and filter the profiler file content in readable text form.
### Example usage
Display modules and summary of XA startup profile
```
mono aprofutil.exe -sd startup.aotprofile
Modules:
41C38B0A-2032-45CE-8638-0299CED65330 mscorlib
0326DF03-2158-4F7A-9A2B-B7A9419F021D Mono.Android
8FB63BB4-1195-4173-A9ED-0EC341B07C32 System
74C06E06-C1C7-4A4C-B64E-EAC7DBB08BBC Java.Interop
11E2319F-6A26-461C-9C46-C972248BEE4B System.Core
7999CC4B-D566-4ECA-8A72-469344172CA3 Xamarin.Forms.Platform.Android
C5089213-328B-451D-BA87-D6585C120780 Xamarin.Forms.Performance.Integration.Droid
D754F8AE-503C-41C8-B16F-647FC662507A Xamarin.Android.Support.v7.AppCompat
929ECB6D-1171-4C66-8470-DD32AC608969 Xamarin.Android.Support.Fragment
F841E23B-59A8-4AE2-9A84-D2FC1D891B4A Xamarin.Forms.Core
945CCBF8-C2DB-468B-B3BD-D7ACA37B69AD Xamarin.Forms.Performance.Integration
AF20FA19-F07E-4BD4-B5ED-104706EA660E Xamarin.Forms.Xaml
629C84F8-0988-42EF-8BC5-872173A0A71F FormsViewGroup
60398815-8E62-487E-A553-781F56A0849D Xamarin.Android.Support.Design
F0C550D7-665A-40B5-A307-8E9B49976D87 Xamarin.Android.Support.Core.UI
23A34485-DE75-440E-BA9D-E235F664E990 Xamarin.Android.Support.Compat
Summary:
Modules: 16
Types: 907
Methods: 4,230
```
Filter Java.Interop.Runtime type in XA startup profile:
```
mono aprofutil.exe --filter-type Java.Interop.Runtime -sa startup.aotprofile
Modules:
0326DF03-2158-4F7A-9A2B-B7A9419F021D Mono.Android
Types:
Java.Interop.Runtime
Methods:
bool Java.Interop.Runtime:IsGCUserPeer (Android.Runtime.IJavaObject)
bool Java.Interop.Runtime:IsGCUserPeer (intptr)
Summary:
Modules: 1 (of 16)
Types: 1 (of 907)
Methods: 2 (of 4230)
```
+70
View File
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- WARNING: this file is autogenerated, don't modify it. Edit the .sources file of the corresponding assembly instead if you want to add/remove C# source files. -->
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">net_4_x</Platform>
<ProjectGuid>{658B566B-CED1-4C42-9926-C1AA930BA368}</ProjectGuid>
<OutputType>Exe</OutputType>
<NoWarn>1699</NoWarn>
<LangVersion>latest</LangVersion>
<HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Windows_NT'">win32</HostPlatform>
<HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix' and $([System.IO.File]::Exists('/usr/lib/libc.dylib'))">macos</HostPlatform>
<HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix'">linux</HostPlatform>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<NoStdLib>False</NoStdLib>
<NoConfig>True</NoConfig>
<AssemblyName>aprofutil</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0,
Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This
is a problem to compile the Mono mscorlib.dll -->
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'net_4_x' ">
<OutputPath>./../../class/lib/net_4_x-$(HostPlatform)</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-net_4_x-$(HostPlatform)</IntermediateOutputPath>
<DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'monodroid_tools' ">
<OutputPath>./../../class/lib/monodroid_tools</OutputPath>
<IntermediateOutputPath>./../../class/obj/$(AssemblyName)-monodroid_tools</IntermediateOutputPath>
<DefineConstants>NET_4_6;MONO;MONODROID_TOOLS;WIN_PLATFORM</DefineConstants>
</PropertyGroup>
<!-- @ALL_PROFILE_PROPERTIES@ -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<!-- TRACE is set only for Debug configuration, so inherit from platform-specific value -->
<DefineConstants>TRACE;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- @BUILT_SOURCES@ -->
<!--Common files-->
<ItemGroup>
<Compile Include="..\..\class\Mono.Options\Mono.Options\Options.cs" />
<Compile Include="Program.cs" />
</ItemGroup>
<!--End of common files-->
<!-- @ALL_SOURCES@ -->
<ItemGroup>
<ProjectReference Include="../../class/System/System.csproj" />
<ProjectReference Include="../../class/System.Core/System.Core.csproj" />
<ProjectReference Include="../../class/Mono.Profiler.Log/Mono.Profiler.Log.csproj" />
</ItemGroup>
<!-- @ALL_REFERENCES@ -->
<!-- @ALL_RESOURCES@ -->
<PropertyGroup>
<!-- Force the pre-build event to run after references have been resolved. The default
behavior is to run them before resolving references, which can cause things like
culevel.exe to be used before they have been built. -->
<PreBuildEventDependsOn>ResolveReferences</PreBuildEventDependsOn>
</PropertyGroup>
</Project>
@@ -0,0 +1,2 @@
Program.cs
../../class/Mono.Options/Mono.Options/Options.cs
+2 -2
View File
@@ -586,9 +586,9 @@ namespace Mono.ApiTools {
writer.WriteStartElement ("generic-parameter-constraints");
foreach (TypeReference constraint in constraints) {
foreach (GenericParameterConstraint constraint in constraints) {
writer.WriteStartElement ("generic-parameter-constraint");
writer.WriteAttributeString ("name", Utils.CleanupTypeName (constraint));
writer.WriteAttributeString ("name", Utils.CleanupTypeName (constraint.ConstraintType));
writer.WriteEndElement (); // generic-parameter-constraint
}
+1
View File
@@ -54,6 +54,7 @@
<Compile Include="..\..\..\external\linker\src\linker\Linker.Steps\BaseStep.cs" />
<Compile Include="..\..\..\external\linker\src\linker\Linker.Steps\BlacklistStep.cs" />
<Compile Include="..\..\..\external\linker\src\linker\Linker.Steps\CleanStep.cs" />
<Compile Include="..\..\..\external\linker\src\linker\Linker.Steps\ClearInitLocals.cs" />
<Compile Include="..\..\..\external\linker\src\linker\Linker.Steps\CodeRewriterStep.cs" />
<Compile Include="..\..\..\external\linker\src\linker\Linker.Steps\IStep.cs" />
<Compile Include="..\..\..\external\linker\src\linker\Linker.Steps\LoadI18nAssemblies.cs" />
+1
View File
@@ -29,6 +29,7 @@
../../../external/linker/src/linker/Linker/TypeReferenceExtensions.cs
../../../external/linker/src/linker/Linker/XApiReader.cs
../../../external/linker/src/linker/Linker.Steps/BaseStep.cs
../../../external/linker/src/linker/Linker.Steps/ClearInitLocals.cs
../../../external/linker/src/linker/Linker.Steps/LoadReferencesStep.cs
../../../external/linker/src/linker/Linker.Steps/LoadI18nAssemblies.cs
../../../external/linker/src/linker/Linker.Steps/ResolveFromXmlStep.cs
+1
View File
@@ -1,5 +1,6 @@
/Test/en.*/
/Test/html.*/
/Test/DocTest.*
/Test/DocTest-DropNS-classic.xml
/.v2.txt
/.v0.txt
Loaded 100 of 332 files, more files were not shown because too many files have changed in this diff. Show more