Compare commits

...
Author SHA1 Message Date
Aleksey Kliger (λgeek) 18ef7d9a0b Merge pull request #2601 from lambdageek/dev-4.3.2/bug-38222
[4.3.2][reflection] Set pending loader exception in mono_reflection_get_custom_attrs_data
2016-02-12 14:53:41 -05:00
monojenkins 619f48b58b Merge pull request #2607 from lambdageek/dev-4.3.2/bug-38408
[4.3.2][io] Release Pipe and Console shared handles

(Backport #2605 to mono-4.3.2-branch)

Fixes [Bugzilla #38408](https://bugzilla.xamarin.com/show_bug.cgi?id=38408)

Allows opening a character device or named fifo more than once with code like:

```csharp
    using (var f = new FileStream ("/dev/zero", FileMode.Open))
    {
       ...
    }
    using (var f = new FileStream ("/dev/zero", FileMode.Open))
    {
       ...
    }
```
2016-02-12 19:36:05 +00:00
Martin Baulig 65afb9f640 [System]: Clone the X509Certificate instance that's stored in ServicePoint. 2016-02-12 14:30:43 -05:00
Aleksey Kliger 35043d00e4 [io] Don't leak Pipe filename
Named FIFOs do indeed have names, but pipe_close doesn't free
it.  (Because CreatePipe doesn't set a filename).
2016-02-12 10:15:15 -05:00
Aleksey Kliger f4d981cf03 [io] Release Pipe and Console shared handles
Allows opening a character device or named fifo more than once with code like:

  using (var f = new FileStream ("/dev/zero", FileMode.Open))
  {
    ...
  }
  using (var f = new FileStream ("/dev/zero", FileMode.Open))
  {
    ...
  }
2016-02-12 10:15:09 -05:00
Aleksey Kliger fcdc920ddc [io] Test repeatedly opening a character device
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=38408
2016-02-12 10:14:57 -05:00
Zoltan Varga 78ca023824 [jit] Fix the bblock linking in c5512c0d3e. 2016-02-11 23:06:03 -05:00
Martin Baulig 2026a0b408 [Mono.Security]: Make 'Mono.Security.Protocol.Ntlm' public and include in System.dll on mobile. 2016-02-11 17:51:07 -05:00
Aleksey Kliger ed2eeebef1 [reflection] Set pending loader exception in mono_reflection_get_custom_attrs_data
Fixes [Bugzilla 38222](https://bugzilla.xamarin.com/show_bug.cgi?id=38222)

While we're at it, convert mono_reflection_get_custom_attrs_data to use
MonoError, runtime should use
mono_reflection_get_custom_attrs_data_checked
2016-02-11 11:08:31 -05:00
Dean Ellis 17fda960fe [msbuild] Registered the XmlPeek Build Task in the Microsoft.Common.tasks
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=36183
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=38638

The previous commit () was incomplete, while it added the source
file for XmlPeek it did not register them in the appropriate
MSBuild tasks files. As a result the XmlPeek task cannot be used.
2016-02-11 15:27:33 +00:00
Zoltan Varga b473fbf965 [aot] Fix the check in mono_aot_get_plt_entry () for thumb code, use 'code-4' instead of 'code', since the latter points to after a call, so it could point outside the range of llvm code. Fixes #36723. 2016-02-11 01:14:38 -05:00
Zoltan Varga 9f44a62acf [jit] Add a fastpath to Monitor.Enter () which doesn't have a wrapper, and add a slowpath which has a wrapper, so async stack traces work for threads blocked on monitors. Fixes #38525. 2016-02-10 21:28:19 -05:00
Zoltan Varga 19f5183be3 [jit] Fix the peephole optimization added by 9fc7c1de3a, compare_imm+cond_exc_imm can only be eliminated if the comparison is false. 2016-02-10 20:09:36 -05:00
Martin Baulig 7f965e8220 [Mono.Security]: MonoTlsProviderFactory.GetProvider(string) now returns null on error. 2016-02-10 18:14:07 -05:00
Alexander Köplinger e34fe7182c [metadata] Fix Facades lookup in assembly.c when MONO_PATH is set
When MONO_PATH is set, the corlib lookup returns early on in mono_assembly_load_corlib (),
without adding the Facades dir to default_path.

This causes any app/library that relies on the facades to fail at runtime.

Fixing this by always doing the Facades lookup when returning the found corlib image.

(cherry picked from commit 6e81edfa24)
2016-02-10 23:55:50 +01:00
Alex Rønne Petersen 21cd9994e7 [profiler] Remove perf_event.h from EXTRA_DIST, too. 2016-02-10 23:09:02 +01:00
Alex Rønne Petersen d220cbd99b [profiler] Only include perf_event.h when actually needed, and use the system header. 2016-02-10 22:34:36 +01:00
Alex Rønne Petersen 8c6f3ca593 [profiler] Remove the bundled perf_event.h header.
Bundling this in Mono is technically a GPL violation. We need to switch to the
system <linux/perf_event.h> header.
2016-02-10 22:27:16 +01:00
Marek Safar 664c608478 [swf] Flow SynchronizationContext through ExecutionContext. Fixes #38599 2016-02-10 20:28:42 +01:00
Marek Safar ba95f00ec5 [corlib] Use correct max/min value for DateTime overflows. Fixes #35876 2016-02-10 03:24:15 -06:00
Zoltan Varga 3cde89c4da [jit] Add a peephole optimization to remove the ldaddr+compare_imm 0+cond_exc checks inserted when using explicit null checks. 2016-02-10 01:59:41 -05:00
Zoltan Varga 5905ff2618 [llvmonly] Disable the 'overriding the module target triple with' clang warning when compiling the bitcode files. 2016-02-10 01:11:02 -05:00
Alex Rønne Petersen 90e2692d69 [runtime] Add SA_RESTART to SIG{CONT,INT,PROF,QUIT,USR2,WINCH}.
We need this as these signals can be delivered at any point and can interrupt
system calls that external (non-Mono) code is executing, which such code may
not be written to handle gracefully.
2016-02-10 06:57:51 +01:00
Alex Rønne Petersen 1fb554d7ed [profiler] Fix a rare crash when sending SIGPROF to a starting thread.
When sample profiling is enabled and we send a SIGPROF signal to a thread that
hasn't yet transitioned to a running state (e.g. STATE_RUNNING), the signal can
sometimes be delivered at such an early point that libc has not even finished
initializing TLS for that thread yet. This is problematic because we then go
right on to crash in the SIGPROF signal handler when we try to save errno. We
then further crash in the SIGSEGV handler because we can't access the jit_tls
variable either.

The fix is fairly simple: Only send SIGPROF to threads that have transitioned
to a running state. Technically, TLS is initialized 'much' earlier than when
this state transition happens, but since the worst thing that can happen is
that we miss one sampling event (i.e. ~1sec by default) right at the beginning
of the thread's lifetime, this simple fix is good enough.

This crash seemingly only happened on OS X.
2016-02-10 06:57:46 +01:00
Zoltan Varga a02ad3af61 [llvm] When storing valuetypes received in registers to the stack, store only the value parts of the register, the upper bits might container garbage. 2016-02-09 22:41:46 -05:00
Zoltan Varga 8205e22ba8 [llvmonly] Fix the locking in the gsharedvt wrapper creation functions. 2016-02-09 21:56:01 -05:00
monojenkins 198028586b Merge pull request #2581 from ludovic-henry/4.3.2-fix-asyncresult-unhandledexception
[4.3.2][AsyncResult] Fix unhandled exception behaviour in AsyncCallback

The AsyncCallback is called after the BeginInvoke has completed. In all cases, this AsyncCallback is called on the ThreadPool, meaning that an unhandled exception would lead to a process crash.

The correct behaviour, after verification on .NET, is to not swallow the exception, and to properly crash the process.

@monojenkins merge
2016-02-10 01:00:32 +00:00
Martin Baulig 024241f424 [Mono.Security]: Add 'MonoTlsProviderFactory.GetProvider(string)'.
Similar to 'SetDefaultProvider(string)', but return the provider instead
of installing it.
2016-02-09 19:38:09 -05:00
monojenkins d979cff046 Merge pull request #2583 from ludovic-henry/4.3.2-fix-threadpool-starvation
[4.3.2][threadpool] Improve the monitor thread heuristic

Because the ThreadPool heuristic is optimized for short lived work item, it has more difficulty when executing long lived work item. That case can lead to a starvation of the worker threads: they are all doing work, while there is outstanding request, and these requests are not satisfied because we reached the max number of working thread.

To fix that issue, we have the monitor thread, whose sole job is to unstuck this kind of starvation cases. Unfortunately, it only works when all the worker threads are in the ThreadState.WaitSleepJoin state, which excludes the case of calling an IO operation in a Task. That includes the case of FileStream.BeginRead/Write/... which implementation can be simplified as follows: FileStream.BeginRead(...) -> Task.Run(() => FileStream.Read(...)).

The way we implement it in this commit is: every MONITOR_INTERVAL (500ms here), we check if there is any outstanding request, and if so, we assume that we are in the starvation case, and we simply increase the max number of working thread. Also to reduce the number of false positives, we do that only if there has been no completed work item for more than at least MONITOR_INTERVAL (in case of low CPU usage, more otherwise, see monitor_sufficient_delay_since_last_dequeue). This case is typically the case where we have all working thread stuck in long running work items.

Finally we increase the monitor interval from 100ms to 500ms so we guarantee we do not create more than 2 threads per second in the monitor thread. That is the value used by the old threadpool.
2016-02-09 23:00:27 +00:00
Ludovic Henry f1cfd85041 [threadpool] Improve the monitor thread heuristic
Because the ThreadPool heuristic is optimized for short lived work item, it has more difficulty when executing long lived work item. That case can lead to a starvation of the worker threads: they are all doing work, while there is outstanding request, and these requests are not satisfied because we reached the max number of working thread.

To fix that issue, we have the monitor thread, whose sole job is to unstuck this kind of starvation cases. Unfortunately, it only works when all the worker threads are in the ThreadState.WaitSleepJoin state, which excludes the case of calling an IO operation in a Task. That includes the case of FileStream.BeginRead/Write/... which implementation can be simplified as follows: FileStream.BeginRead(...) -> Task.Run(() => FileStream.Read(...)).

The way we implement it in this commit is: every MONITOR_INTERVAL (500ms here), we check if there is any outstanding request, and if so, we assume that we are in the starvation case, and we simply increase the max number of working thread. Also to reduce the number of false positives, we do that only if there has been no completed work item for more than at least MONITOR_INTERVAL (in case of low CPU usage, more otherwise, see monitor_sufficient_delay_since_last_dequeue). This case is typically the case where we have all working thread stuck in long running work items.

Finally we increase the monitor interval from 100ms to 500ms so we guarantee we do not create more than 2 threads per second in the monitor thread. That is the value used by the old threadpool.
2016-02-09 19:56:12 +00:00
Ludovic Henry f774f96e05 [AsyncResult] Fix unhandled exception behaviour in AsyncCallback
The AsyncCallback is called after the BeginInvoke has completed. In all cases, this AsyncCallback is called on the ThreadPool, meaning that an unhandled exception would lead to a process crash.

The correct behaviour, after verification on .NET, is to not swallow the exception, and to properly crash the process.
2016-02-09 11:04:53 +00:00
Alexander Köplinger c4a03267f4 [metadata] Fix hardcoded mono/2.0 path in assembly.c
The performance team discovered this on their bots using the Jenkins snapshot packages. Mono would fail to start with a message like:

```
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/opt/mono-2016.02.08+15.25.39/lib/mono/4.5/mscorlib.dll' directory.
```

The one odd thing is that they are using Mono installed in a path which is different from the prefix used during compilation.

It turns out that the runtime has a hardcoded check for lib/mono/2.0 in https://github.com/mono/mono/blob/7d5a7ea7ac324bb4ee63094ddcf8e20ae9ba4322/mono/metadata/assembly.c#L633-L637.
Since we recently stopped shipping 2.0 in the packages (we moved to 2.0-api for the reference assemblies) this directory wasn't there,
so the code in fallback() called into mono_config_get_assemblies_dir() which just returns the MONO_ASSEMBLIES preprocessor symbol.

That preprocessor symbol is defined to the value of --prefix during compilation, so Mono couldn't find corlib there as well since it's installed in another path which ultimately results in the above error message.

The fix is to change the hardcoded value to 4.5, which is what we established as the directory with the "latest" assemblies now.
Ideally we should find a way to stop hardcoding those paths in the runtime.

PS: I grepped through the runtime source to make sure we don't hardcode 2.0/3.5/4.0 elsewhere and only found one instance in a test.
I fixed it there as well, though the test looks suspicious since it hardcodes /usr ...

(cherry picked from commit 769037d8b1)
2016-02-09 02:33:40 +01:00
Zoltan Varga f48bb4bfb5 [llvmonly] Compile the bitcode files using -O2. 2016-02-08 20:02:26 -05:00
Zoltan Varga b564c16226 [llvmonly] Add unbox wrappers when invoking vtype instance methods through a delegate. 2016-02-08 20:02:19 -05:00
Rolf Bjarne Kvinge 9b0491d2b3 [System] Fix test build on tvOS/watchOS. 2016-02-08 10:24:47 +01:00
Zoltan Varga b5a3a169df [llvmonly] Disable tail calls as they break stack traces. 2016-02-08 03:08:26 -05:00
Zoltan Varga c0a692eb5c [llvm] Make the stack walk code return. 2016-02-08 03:08:19 -05:00
Zoltan Varga fbb984af9b [llvmonly] Compile the bitcode files using -O2 (only in desktop llvmonly mode). 2016-02-08 03:08:11 -05:00
Zoltan Varga bf3cd4557d [llvmonly] Remove the mono_llvmonly_get_calling_assembly () workaround since stack walks work in llvmonly mode now. 2016-02-06 02:01:04 -05:00
João Matos f0298e5a2c [aot] Fixed compiler to wrap paths with embedded spaces when calling external tools.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=34498.
2016-02-05 17:13:41 +00:00
Rolf Bjarne Kvinge 6f89034001 [corlib] Disable ThreadLocalTests.DisposeOnThreadExit on MonoTouch, it's randomly failing. 2016-02-05 15:34:34 +01:00
Zoltan Varga 82822106d8 [llvmonly] Various small fixes. Make mono_llvm_throw_exception etc. directly callable in static mode. Add support for directly calling pinvoke methods. Fix an assertion during EH. 2016-02-05 02:08:11 -05:00
Zoltan Varga 2612ccb64d [llvmonly] Do a stack walk from mono_llvmonly_get_calling_assembly (), the runtime might support stack walks on some platforms. 2016-02-04 22:45:59 -05:00
Zoltan Varga 40dffe542e [llvmonly] Don't set the invariant.load flag on loads from the GOT, they are initialized by a call to init_method () so they are not completely invariant. 2016-02-04 22:41:02 -05:00
Marek Safar bf6cd183cc [System] Remove explicit sdk target from CSharpCodeCompiler 2016-02-04 16:03:59 +01:00
Ludovic Henry b248963021 [Process] Fix possible double call to Begin(Output|Error)ReadLine
This is not allowed in .NET, as it could lead to unexpected results.
2016-02-04 14:33:17 +00:00
Ludovic Henry 2b81318351 [io-layer] Print from which pipe we just read 2016-02-04 14:33:17 +00:00
Marek Safar 730b4c7fde [mcs] Update sdk profile paths after 88b287f065 2016-02-04 14:10:44 +01:00
Zoltan Varga 162dd58515 [llvm] Zero extend unsigned enum arguments. Fixes #38379. 2016-02-03 18:16:32 -05:00
Ludovic Henry 44b9eff431 [SocketResponder] Use Task instead of Thread
This allow us catching and rethrowing the exception on the main thread, as well as making sure we wait for the Listen thread to finish in a timely manner.
2016-02-03 20:18:30 +00:00
Ludovic Henry 01603cf37b [SocketResponder] Start in constructor and Stop on Dispose
In conjuction with `using` we ensure that we Start and Stop the SocketResponder correctly, and everytime
2016-02-03 20:18:30 +00:00
Ludovic Henry 627772db1c [Tests] Use explicit delegate so it appears in stacktraces
In case of exception in this callback, the name of the test method will appear in the stacktrace, making debugging way easier.
2016-02-03 20:18:30 +00:00
Alexander Köplinger 736c747fdf [binary-reference-assemblies] Add a symlink from 4.0/mscorlib.dll to 4.0-api/mscorlib.dll
Some programs like NUnit check if a file exists there and break otherwise.

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

(cherry picked from commit a44d3c650c)
2016-02-03 20:17:38 +01:00
Ludovic Henry 7a150f7c84 [test] Use using for TimerTest 2016-02-03 13:54:24 +00:00
Ludovic Henry a900ef987b [tests] Use explicit delegates to get more information from stacktrace 2016-02-03 13:22:28 +00:00
Ludovic Henry cc10f1a009 [coop] Add support for entering/exiting GC safe/unsafe region for products 2016-02-03 12:44:42 +00:00
Ludovic Henry 9dd8285992 [coop] Ensure we exit blocking mode when invoking managed code
mono_runtime_invoke might be called by P/Invoked code, which is in blocking mode. Not switching back to running can lead to a crash when hitting a safepoint.
2016-02-03 12:44:28 +00:00
Zoltan Varga 0df254ddae [llvmonly] Implement support for stack walks if _Unwind_Backtrace () is available. 2016-02-02 19:35:59 -05:00
Zoltan Varga 272336b6a3 [llvmonly] Implement limited support for stack walks so new StackTrace () works. 2016-02-02 19:35:46 -05:00
Marek Safar 20d7b6a558 [corlib] Fixes Environment version for .net 4.6 2016-02-02 22:31:02 +01:00
Alexander Köplinger 02f59bac0c [binary-reference-assemblies] Make sure only .dll files are included in the wildcard
The wildcard `$(wildcard ../../../external/binary-reference-assemblies/v4.5/*)` would include the directory entry `../../../external/binary-reference-assemblies/v4.5/Facades/` which returns an error during "make dist".

Fixing this by including only the .dll files in the wildcards.

(cherry picked from commit f1dad87178)
2016-02-02 14:33:31 +01:00
Alexander Köplinger b11dfd2aff [binary-reference-assemblies] Include 4.5 Facades in tarball
(cherry picked from commit c896d003e5)
2016-02-02 13:59:34 +01:00
Martin Baulig f379b7df51 [Mono.Security.Providers.OldTls]: Don't build on mobile. 2016-02-02 00:45:13 +01:00
Martin Baulig 3e9f79184b Revert "[System]: Include 'OldTlsProvider' on mobile."
This reverts commit eb89783365.
2016-02-02 00:45:13 +01:00
Zoltan Varga 84c32c0c67 [jit] Avoid merging some bblocks which are not after each other when inlining since it can cause the bblock between them to be ignored later. Fixes #38250. 2016-02-01 17:45:39 -05:00
Martin Baulig eb89783365 [System]: Include 'OldTlsProvider' on mobile. 2016-02-01 22:10:00 +01:00
Zoltan Varga b25f5d16ce [arm] Fix a code generation problem when a virtual call is made with a large offset, the offset generation code would overwrite a source register. Fixes #27303. 2016-02-01 14:51:56 -05:00
Zoltan Varga 053f1415ba [aot] Emit gsharedvt wrappers only in llvmonly mode. 2016-02-01 14:28:58 -05:00
monojenkins fd213a6d19 Merge pull request #2539 from ludovic-henry/4.3.2-fix-sgen-38012
[4.3.2][sgen] Fix register scanning on ARM

This bug would trigger a use after sweep in System.Threading.Tasks.Task.FinishContinuations:3621.

The issue would arise on ARM, as `MonoContext` and `ARCH_NUM_REGS` are defined as followed :

```
typedef struct {
  mgreg_t pc;
  mgreg_t regs [16];
  double fregs [16];
  mgreg_t cpsr;
} MonoContext;

\#define ARCH_NUM_REGS 14
```

As you can see, the MonoContext structure is bigger than 14 words, and it does not even covers the last 3 values of `regs`. By using pointer arithmetic, we ensure that we do not miss some parts of the `MonoContext` structure.

The observed behaviour in System.Threading.Tasks.Task.FinishContinuations would be that `continuationObject` would not be marked, and thus freed; `continuationObject` would still contains the pointer to the old location, meaning it wouldn't be null. We would then try to check its type via a call to the `as` operator. This would call the `isinst` IL opcode which would load `continuationObject->vtable->klass->supertypes [...]`, which would trigger a segfault, as `supertypes` would be null.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=38012
2016-02-01 17:37:30 +00:00
Marek Safar 6e927b4ce3 [binary-reference-assemblies] Install 4.5 api facades 2016-02-01 12:57:24 +01:00
Martin Baulig 77fa9812f0 [System]: Fix X509Certificate2.Export().
We need to add a 'PKCS9.localKeyId' attribute to both the
certificate and the private key or else SecImportExport.ImportPkcs12()
won't work on iOS.
2016-02-01 01:32:08 +01:00
Zoltan Varga db654d24db [llvmonly] Fix stack trace calculation. 2016-01-29 17:15:25 -05:00
Zoltan Varga db847470a0 [llvmonly] Catch all exceptions in mono_jit_exec () to avoid terminating the runtime with an unhelpful libc++ assertion. 2016-01-29 17:15:18 -05:00
Ludovic Henry 1f3421e78d [sgen] Fix register scanning on ARM
This bug would trigger a use after sweep in System.Threading.Tasks.Task.FinishContinuations:3621.

The issue would arise on ARM, as `MonoContext` and `ARCH_NUM_REGS` are defined as followed :

```
typedef struct {
  mgreg_t pc;
  mgreg_t regs [16];
  double fregs [16];
  mgreg_t cpsr;
} MonoContext;

\#define ARCH_NUM_REGS 14
```

As you can see, the MonoContext structure is bigger than 14 words, and it does not even covers the last 3 values of `regs`. By using pointer arithmetic, we ensure that we do not miss some parts of the `MonoContext` structure.

The observed behaviour in System.Threading.Tasks.Task.FinishContinuations would be that `continuationObject` would not be marked, and thus freed; `continuationObject` would still contains the pointer to the old location, meaning it wouldn't be null. We would then try to check its type via a call to the `as` operator. This would call the `isinst` IL opcode which would load `continuationObject->vtable->klass->supertypes [...]`, which would trigger a segfault, as `supertypes` would be null.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=38012
2016-01-29 18:39:04 +00:00
Rolf Bjarne Kvinge 04ac046007 [System.ServiceModel.Internals] Add a missing .sources file for watchOS. Fixes #38145.
https://bugzilla.xamarin.com/show_bug.cgi?id=38145
2016-01-29 12:22:41 +01:00
Marcos Henrich 98f0a7b39a [System.Web] HeadersCollection read only exception
In reference source HttpHeaderCollection [1] when Add, Set or Remove is
called and the collection is readonly a PlatformNotSupportedException is
thrown.

Mono HeadersCollection was throwing NotSupportedException and
Microsoft.Owin.Host.SystemWeb.OwinCallContext.RemoveAcceptEncoding was
not catching the exception because it was expecting
PlatformNotSupportedException.

Fixes #33809

[1] http://referencesource.microsoft.com/#System.Web/HttpHeaderCollection.cs,73
2016-01-29 09:41:09 +00:00
Marcos Henrich 6723b79e3c [System.Web] Test HttpRequest.Headers Add/Set/Remove
In .NET while calling Add, Set or Remove of a HttpRequest read only
collection a PlatformNotSupportedException is thrown.

Covers #33809
2016-01-29 09:41:08 +00:00
Marcos Henrich 03f2ff096a [System.Xml] Fix sub class serialization on lists
Fixes failure, where XmlSerializer would crash while serializing
a list with multiple XmlElement when a sub class of the XmlElement is
used.

Fixes #36829.
2016-01-28 18:02:00 +00:00
Marcos Henrich 6e819dea67 [System.Xml] Test sub class serialization on lists
Covers #36829
2016-01-28 18:02:00 +00:00
Alexander Köplinger cec0f68cb8 [xbuild] Use -api folder for 2.0/3.5/4.0 profiles as well
Similar to e2a79ed888. Those profiles are only contract/reference assemblies since Mono 4.0.
2016-01-28 16:34:20 +01:00
Rolf Bjarne Kvinge b6a4dad872 [mono-api-html] New interface members are only breaking if the interface existed. 2016-01-28 15:55:33 +01:00
Rolf Bjarne Kvinge 373031252e [mono-api-html] Fix compiler warning. 2016-01-28 15:33:32 +01:00
Rolf Bjarne Kvinge 5defe6f35c [mono-api-html] Make it possible to hide/show non-breaking changes in the html output.
We now add data-is-[non-]breaking attributes to the generated
html elements, and then use some javascript logic to show/hide
non-breaking elements (and the javascript also looks in the
container elements show/hide containers that have only
non-breaking descendants).

Also use css classes/styles to colorize.
2016-01-28 15:31:23 +01:00
Rolf Bjarne Kvinge ef9543e288 [mono-api-info] Add an is-override attribute to determine if a method is overriding another method. 2016-01-28 15:31:22 +01:00
Rolf Bjarne Kvinge 5260e942a3 Merge branch 'mono-api-info-improvements-4-3-2' into mono-4.3.2-branch 2016-01-28 14:46:12 +01:00
Rolf Bjarne Kvinge 8d19114895 [mono-api-info] CreateAttributeMapping: don't create dictionaries unless there is something to put in them. 2016-01-28 14:45:57 +01:00
Rolf Bjarne Kvinge dc60579386 [mono-api-info] Rework AttributeData to use a static method instead of creating an instance every time. 2016-01-28 14:45:57 +01:00
Rolf Bjarne Kvinge dc89b23ded [mono-api-info] Improve CleanupTypeName to not create 3 strings every time somethings needs to change. 2016-01-28 14:45:57 +01:00
Rolf Bjarne Kvinge dc3a252a52 [mono-api-info] First filter, then order, and use ordinal comparison. 2016-01-28 14:45:57 +01:00
Rolf Bjarne Kvinge 0fce7d666b [mono-api-info] Rework SkipAttribute to use ordinal string comparison, and no string comparison unless needed. 2016-01-28 14:45:57 +01:00
Rolf Bjarne Kvinge 0884bca59e [mono-api-info] Use ordinal string comparison. It's much faster. 2016-01-28 14:45:57 +01:00
Rolf Bjarne Kvinge a201572042 [mono-api-info] Remove unused method. 2016-01-28 14:45:57 +01:00
Rolf Bjarne Kvinge fad223adb8 [mono-api-info] Use XmlWriter instead of XmlDocument to make this faster.
Generating all the API references (in parallel) for Xamarin.iOS goes from
5.5s to 4.5s.
2016-01-28 14:45:39 +01:00
Marek Safar 382dd87b48 [xbuild] Set .net 4.5 target to 4.5 restricted api 2016-01-28 14:21:01 +01:00
Rolf Bjarne Kvinge b700aeb026 [mono-api-info] Add support for writing output to a file specified using a command line argument. 2016-01-28 13:15:50 +01:00
Marek Safar 3aa52dca53 [mcs] Implements null operator for dynamic expressions. Fixes #37801, #37824 2016-01-28 13:10:23 +01:00
Sebastien Pouliot f9eae9f4bc [System] Move HttpListenerResponse.GetStatusDescription to ease linking
The use of HttpResponseMessage.ReasonPhrase means:

* marking the HttpListenerResponse.GetStatusDescription method;
* marking the HttpListenerResponse type;
* which implements IDisposable, so it's Dispose method is marked
* marking the Close method...

from there a metric ton of code gets recursively marked to the point
where the whole SSL/TLS server code gets inside the app.

To avoid this we move the GetStatusDescription to a different
type that won't bring the end of the civilized world so fast.
2016-01-27 22:13:13 -05:00
Marek Safar 50343d3d2e [mcs] Reset null operator barrier in parenthesis expression 2016-01-27 17:01:04 +01:00
Alex Rønne Petersen 2d707b5dc1 [TPL] Add support for the <ThrowUnobservedTaskExceptions /> config element.
Improves the situation wrt: https://bugzilla.xamarin.com/show_bug.cgi?id=36560
2016-01-27 15:57:49 +01:00
Alex Rønne Petersen 216b11bd8d [runtime] Make VolatileRead/VolatileWrite semantics compatible with MS.NET.
We previously followed the spec semantics for these which meant weaker memory
barriers than MS.NET. However, since we've been importing large amounts of
code from the reference sources, it makes sense to switch these methods to
the MS.NET semantics as we don't generally audit the reference source code for
compatibility with our (spec-compliant) memory model. It's safe to assume that
most MS.NET code is written with the assumption of strong memory barriers in
these methods.
2016-01-27 15:57:49 +01:00
Alex Rønne Petersen 091f2cade1 [bcl] Deduplicate the SocketResponder test helper class.
A number of fixes were made to the version in System but these fixes were never
applied to the System.Web.Services version. Merge the two and place the class
in the test-helpers directory to avoid this sort of maintenance problem.
2016-01-27 15:57:48 +01:00
Alex Rønne Petersen edf70859d7 Revert "[System] Tweak tests to work with Thread.Interrupt as well."
This reverts commit bb50c3f3c9.
2016-01-27 15:57:48 +01:00
Alex Rønne Petersen 35a840a78c Revert "[bcl] Fix System.Net.HttpWebRequestTest.GetRequestStream hang"
This reverts commit b3fa096e5e.

The Abort () call is problematic on many platforms and is no longer necessary
as we properly close the listening socket since 1103abf383.

Conflicts:

	mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/SocketResponder.cs
	mcs/class/System/Test/System.Net/SocketResponder.cs
2016-01-27 15:57:48 +01:00
Chris Hamons 2a3ec28bff Fix serialization under XM 4.5 Target Framework
- System.Configuration.ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer
- Fixes #36401 #38064
2016-01-27 08:51:24 -06:00
Zoltan Varga f87e37159d [runtime] Fix the computation of StackFrame.native_offset for managed-to-native wrappers. 2016-01-26 15:08:58 -05:00
Zoltan Varga 822ee730f3 Remove libgc/depcomp and libgc/missing, newer automake versions seem to overwrite them. 2016-01-26 15:08:47 -05:00
Sebastien Pouliot 1585459e2e [System] Make SmtpClient fallback to it's old behaviour if the hostname cannot be resolved. Fix #37246
Warning: System.Net.Mail is broken by design and sends incorrect emails.

This is not to fix SmtpClient itself but to ensure it remains compatible
(even if incorrect/broken) with older Mono releases.

The commit associated with bug# 33551 [1] can cause issues on computer
and devices that cannot resolve their hostname using the Dns API (which
have their own issues).

This commit catch the exception that occurs when resolution fails and
continue to send an email without a fully qualified domain name - just
like earlier Mono versions did in the past.

This solve bug #32746 [2] where some, but not all, AppleTV devices fails
to execute some of the System.dll unit tests.

Note: Whenever possible stay clear of SmtpClient (and friends) and use
something else like MimeKit/MailKit for your email needs

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=33551
[2] https://bugzilla.xamarin.com/show_bug.cgi?id=37246
2016-01-26 13:13:50 -05:00
Jonathan Pryor 89baf6d449 [runtime] Allow getting thread name, managed id from embedding API
When tracing multi-threaded program execution, it is useful to have a
way of separating which events happen on which thread. The
System.Threading.Thread.Name and Thread.ManagedThreadId properties are
useful proxies for tracking program execution.

However, if program execution spans both managed and embedded mono
native code, there is no existing mechanism to read the Thread.Name or
Thread.ManagedThreadId properties from native code without using
delegates, and delegates may not be usable in all circumstances (e.g.
within a mono_gc_register_bridge_callbacks() callback).

Add the following APIs to the embedding API to permit reading the
Thread.Name and Thread.ManagedThreadId properties:

	char   *mono_thread_get_name_utf8 (MonoThread *thread);
	gint32  mono_thread_get_managed_id (MonoThread *thread);

mono_thread_get_name_utf8() returns the Thread.Name value as a UTF-8
string in newly allocated memory; the caller must g_free() this value.

mono_thread_get_managed_id() returns the Thread.ManagedThreadId value.
2016-01-26 12:31:23 -05:00
monojenkins 37bae7f34a Merge pull request #2515 from ludovic-henry/mono-4.3.2-branch
[Process] Fix NullReferenceException in AsyncStreamReader.ReadBuffer after disposing the Process

The following exception would arise if we dispose the Process before making sure the AsyncStreamReader finished its work:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Diagnostics.AsyncStreamReader.ReadBuffer (IAsyncResult ar) [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs:158
  at System.IO.Stream+ReadWriteTask.InvokeAsyncCallback (System.Object completedTask) [0x00015] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/io/stream.cs:670
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, Boolean preserveSyncCtx) [0x0008d] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/executioncontext.cs:957
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, Boolean preserveSyncCtx) [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/executioncontext.cs:904
  at System.IO.Stream+ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke (System.Threading.Tasks.Task completingTask) [0x0005e] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/io/stream.cs:696
  at System.Threading.Tasks.Task.FinishContinuations () [0x0009a] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:3633
  at System.Threading.Tasks.Task.FinishStageThree () [0x00045] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2366
  at System.Threading.Tasks.Task.FinishStageTwo () [0x000f8] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2339
  at System.Threading.Tasks.Task.Finish (Boolean bUserDelegateExecuted) [0x00049] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2239
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00079] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2834
  at System.Threading.Tasks.Task.ExecuteEntry (Boolean bPreventDoubleExecution) [0x0006f] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2760
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2707
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/threadpool.cs:857
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/threadpool.cs:1212

This would arise in test-runner.cs when one of the test would timeout, leading to the Process being disposed. This would then dispose the AsyncStreamReader, setting its `stream` value to null. The callback to ReadBuffer would then try to access `stream`, but would throw a NullReferenceException. By not disposing the AsyncStreamReader explicitely, we close the stream first, which will trigger a call to ReadBuffer, thus not triggering the NullReferenceException.
2016-01-26 16:50:18 +00:00
Ludovic Henry 47cc449895 [Process] Fix NullReferenceException in AsyncStreamReader.ReadBuffer after disposing the Process
The following exception would arise if we dispose the Process before making sure the AsyncStreamReader finished its work:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Diagnostics.AsyncStreamReader.ReadBuffer (IAsyncResult ar) [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs:158
  at System.IO.Stream+ReadWriteTask.InvokeAsyncCallback (System.Object completedTask) [0x00015] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/io/stream.cs:670
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, Boolean preserveSyncCtx) [0x0008d] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/executioncontext.cs:957
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, Boolean preserveSyncCtx) [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/executioncontext.cs:904
  at System.IO.Stream+ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke (System.Threading.Tasks.Task completingTask) [0x0005e] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/io/stream.cs:696
  at System.Threading.Tasks.Task.FinishContinuations () [0x0009a] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:3633
  at System.Threading.Tasks.Task.FinishStageThree () [0x00045] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2366
  at System.Threading.Tasks.Task.FinishStageTwo () [0x000f8] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2339
  at System.Threading.Tasks.Task.Finish (Boolean bUserDelegateExecuted) [0x00049] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2239
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00079] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2834
  at System.Threading.Tasks.Task.ExecuteEntry (Boolean bPreventDoubleExecution) [0x0006f] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2760
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2707
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/threadpool.cs:857
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in /media/ssd/jenkins/workspace/test-mono-mainline/label/debian-armhf/external/referencesource/mscorlib/system/threading/threadpool.cs:1212

This would arise in test-runner.cs when one of the test would timeout, leading to the Process being disposed. This would then dispose the AsyncStreamReader, setting its `stream` value to null. The callback to ReadBuffer would then try to access `stream`, but would throw a NullReferenceException. By not disposing the AsyncStreamReader explicitely, we close the stream first, which will trigger a call to ReadBuffer, thus not triggering the NullReferenceException.
2016-01-26 15:16:01 +00:00
Zoltan Varga ae0dad98ae [llvmonly] Call 'opt' when running with --aot=asmonly too. No optimizations enabled yet. 2016-01-25 19:38:13 -05:00
Zoltan Varga 87e93a0d58 [llvmonly] Reenable running 'opt', it was disabled by mistake. 2016-01-25 18:53:43 -05:00
Zoltan Varga b44b21ccf9 [llvmonly] Avoid inlining the original method into unbox trampolines. 2016-01-25 18:53:38 -05:00
Zoltan Varga a727206659 [llvmonly] Rename MonoDelegate.rgctx to 'extra_arg' to better reflect its purpose. 2016-01-25 14:22:06 -05:00
Sebastien Pouliot c90e3b760f [tests][System][ios] Avoid reflection usage when testing for Xamarin.iOS. Fixes #34133
When the linker is enabled (default for device builds) unused methods
are removed and cannot be reflected.

In this case we do not need reflection as the answer to port reuse is
always true.

https://bugzilla.xamarin.com/show_bug.cgi?id=34133
2016-01-25 13:46:09 -05:00
Zoltan Varga 19ef659344 [llvmonly] Optimize delegate invocation. 2016-01-24 18:41:39 -05:00
Zoltan Varga 2ea7decb7b [llvmonly] Fix the invocation of generic array helpers, they need an rgctx arg. 2016-01-23 22:15:11 -05:00
Rolf Bjarne Kvinge 08198a547b [linker] Add API to notify subclasses of removed attributes. 2016-01-23 03:09:58 +01:00
Zoltan Varga 76078f9670 [arm] Emit more complete unwind info for generic trampolines. 2016-01-22 18:21:05 -05:00
Sebastien Pouliot bf134e25ff [system] Avoid reflection use to create NtlmSession. Fixes #37732
commit d2325f1483 (only since 4.3.2, not
4.3.1) caused the failure when an application is linked.

The use of `GetOrCreateValue` uses reflection to create an `NtlmSession`
instance so the linker won't see it as used anymore (and removes it).

Fixed by avoiding reflection (which will also perform better).

https://bugzilla.xamarin.com/show_bug.cgi?id=37732
2016-01-22 14:21:40 -05:00
Marek Safar af3310bbd3 [mcs] String interpolating of dynamic arguments does not behave like normal dynamic operation but assumes all arguments are object only (not dynamic). Fixes #37886 2016-01-22 18:24:07 +01:00
Zoltan Varga ccbe5f6a68 [bcl] Fix a System.Core test failure caused by a method linked away. 2016-01-21 17:24:41 -05:00
Zoltan Varga ad8807f137 [llvmonly] Make sure the signature of unbox trampolines matches the method they are calling. 2016-01-21 16:47:20 -05:00
Zoltan Varga d80a218532 [llvmonly] Fix the addition of gsharedvt out wrappers on calls from gsharedvt to normal code. 2016-01-21 16:30:11 -05:00
Martin Baulig adef97107b [Mono.Security]: Add 'MonoTlsSettings.EnabledCiphers'.
(cherry picked from commit 79c7c38cc6)
2016-01-21 21:48:14 +01:00
Zoltan Varga 6ed62014fd [jit] Fix the reference type detection for Volatile:Read/Write (). Fixes part of #37846. 2016-01-21 14:32:28 -05:00
Zoltan Varga 79e6db69e0 [llvmonly] Fix runtime invoke calls to gsharedvt methods without variable signatures. Add gsharedvt out wrappers and in wrappers for delegate invoke wrappers. 2016-01-20 15:52:22 -05:00
Zoltan Varga 80efb7ab7a [runtime] Add a new helper function mono_method_get_full_name (), which is similar to mono_method_full_name (), but the result includes the return type as well. 2016-01-20 15:52:16 -05:00
Zoltan Varga 3e2a9e30af [llvmonly] Fix the type of the vret_addr argument. 2016-01-19 21:41:12 -05:00
Martin Baulig d1d6b05324 [System]: Change namespace for some internal classes.
(cherry picked from commit 997513da02)
(cherry picked from commit 8a38b0f7fa)
2016-01-20 01:53:00 +01:00
Martin Baulig 292ee11f1f [System]: Remove unpredictable pluggable setup and cleanup APIs.
(cherry picked from commit 2d945d75bb)
2016-01-20 01:47:29 +01:00
Zoltan Varga 027c82b32c [llvmonly] Set the del->rgctx field for delegates created using reflection as well. 2016-01-19 15:57:57 -05:00
Alexander Köplinger a356639122 [io-layer] Fix tarball broken by 39393f118d
A new file io-trace.h was added but not listed in any Makefile sources anywhere so it didn't end up in the tarball.
2016-01-19 18:01:49 +01:00
Marek Habersack f06366e31d Replace DEBUG messages with calls to mono_trace
The messages contain useful debugging information which is unavailable
unless the mono runtime is recompiled. The debugging information is
particularly useful on mobile platforms and in test runs on bots.

The I/O layer trace messages can be disabled on compile time by
defining the DISABLE_IO_LAYER_TRACE preprocessor symbol.
2016-01-19 17:59:21 +01:00
Marek Habersack 18668a1fa4 Move mono_trace to header file
This commit moves mono_trace to a header file so that all the
calls are inlined, avoiding one function call at the small expense
of binary size.
2016-01-19 17:59:06 +01:00
Zoltan Varga c3145582fc [llvmonly] Avoid inlining methods which call MethodBase:GetCurrentMethod (). 2016-01-18 19:15:43 -05:00
Zoltan Varga ec5ef1e9c2 [llvmonly] Fix the passing of byref arguments in runtime invoke. 2016-01-18 18:41:34 -05:00
Zoltan Varga 14f32d68f1 [llvmonly] Fix the MethodBase.GetCurrentMethod () intrinsic so it works with generic methods. 2016-01-18 18:26:05 -05:00
Zoltan Varga 1cd2c3fa5a [llvm] Fix some type imcompatibility problems which happen when a vreg holding an objref is made global and stored into its location which has a different type (IntPtrType () vs ObjRefType ()). 2016-01-18 16:29:22 -05:00
Zoltan Varga 20482680ae [llvmonly] Fix the catching of exceptions of open types in shared methods by passing mrgctx/this to the mono_llvm_match_exception () function. 2016-01-18 14:03:10 -05:00
Zoltan Varga 09c26bf8c7 [llvm] Add some missing opcodes. 2016-01-18 12:02:37 -05:00
Zoltan Varga ebc5130e31 [runtime] Fix native-to-managed calls to delegates which wrap a virtual method. Fixes #37695. 2016-01-18 11:47:38 -05:00
Zoltan Varga ed3e121299 [llvmonly] Add an instrinsics for MethodBase.GetCurrentMethod () so it works on platforms without stack walks. 2016-01-17 18:25:41 -05:00
Marek Safar 46f7140123 [corlib] Improve CancellationTokenSource test 2016-01-16 08:00:24 +01:00
Zoltan Varga a49236e879 [llvmonly] Share more wrapper types. Avoid adding out wrappers for calls from gsharedvt code to gsharedvt code with a normal signature. Fix the handling of pointer types in runtime invoke. Fix the passing of the same fixed gsharedvt argument in multiple calls. 2016-01-15 18:03:15 -05:00
Zoltan Varga e4426cbcdb [llvmonly] Avoid a crash in ves_icall_GetCurrentMethod () if the stack walk fails. 2016-01-15 18:03:10 -05:00
Zoltan Varga 59b84d7a76 [llvm] Split long bblocks instead of disabling llvm for methods with them. 2016-01-15 10:18:19 -05:00
Zoltan Varga 572ab4dcbb [llvm] Fix a type conversion problem when calling the same method with two different signatures. 2016-01-15 10:18:17 -05:00
Marek Safar bd5b3ca14b Bump reference source for recent fixes 2016-01-15 15:35:33 +01:00
Rolf Bjarne Kvinge 74de7595ac [System] Fix the mobile build after 4e0ae8c. 2016-01-15 11:23:44 +01:00
Zoltan Varga bd4c8b9074 [llvmonly] Fix mono_patch_info_equal () for MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER. 2016-01-14 19:55:16 -05:00
Zoltan Varga 9186521479 [llvmonly] Fix the addition of gsharedvt in wrappers around unbox wrappers. 2016-01-14 18:44:20 -05:00
Zoltan Varga fded4957dd [llvmonly] Fix the gsharedvt parameter passing code so it emits valid llvm il. 2016-01-14 18:01:03 -05:00
Zoltan Varga e0b65ae93d [llvmonly] Add unwind info for unbox wrappers, not the get_unbox_tramp () generated function. 2016-01-14 17:05:10 -05:00
Zoltan Varga f85fd107c7 [llvmonly] Fix initialization of static gshared methods, they receive a vtable as the rgctx argument, not a MonoMethodRuntimeGenericContext. Emit unwind info for unbox wrappers. Fix calls to gsharedvt methods from non-shared delegate invoke wrappers. 2016-01-14 16:48:14 -05:00
monojenkins 61c088a932 Merge pull request #2437 from ludovic-henry/4.3.2-fix-process-missed-output
[4.3.2][Process] Use ReferenceSource process async output/error reader
2016-01-14 17:22:57 +00:00
Zoltan Varga 37ad1431c9 [llvmonly] Implement Assembly.GetCallingAssembly () in llvmonly mode by saving the current assembly in the calling method. Enable it for Activator.CreateInstance () for now. 2016-01-14 11:26:42 -05:00
Marek Safar 88fce13184 [mono] Update predefined Hebrew negative sign. Fixes #37681 2016-01-14 16:38:12 +01:00
Ludovic Henry 4e0ae8c578 [Process] Use ReferenceSource process async output/error reader
By using the referencesource one, we remove a buggy part of the Process class. It will now simply use Stream.{Begin/End}Read, and not a custom implementation that introduces its own bugs.
2016-01-14 15:37:28 +00:00
Zoltan Varga 5499b3ecc6 [runtime] Make sure ptr-to-structure and structure-and-ptr wrappers are unique, this is needed by full aot. Fixes #20186. 2016-01-14 10:12:47 -05:00
Zoltan Varga 6f92ae31be [llvm] Add a missing r4 opcodes. 2016-01-13 16:48:09 -05:00
Zoltan Varga 92a593c17d [llvmonly] Create empty stacktraces if backtraces are not supported by the platform. 2016-01-13 16:48:03 -05:00
Zoltan Varga 8bb9bb703b [runtime] Disable a test which fails with bitcode. 2016-01-13 16:47:58 -05:00
Zoltan Varga 39389be976 [aot] Avoid overwriting entries in domain->seq_points if decode_exception_debug_info () is called more than once. Fixes #37582. 2016-01-13 12:11:09 -05:00
Rolf Bjarne Kvinge 6f50c368f1 [System] xamarin_start_wwan is not available for tvOS and watchOS. 2016-01-13 17:55:24 +01:00
Zoltan Varga 9d96fb5a76 [llvmonly] Avoid disabling llvm for the Selector.GetHandle () intrinsics. 2016-01-12 14:40:14 -05:00
Zoltan Varga 1a77ad3fa7 [llvmonly] Fix support for variant interface methods, they work similarly to generic virtual methods. 2016-01-12 14:23:50 -05:00
Zoltan Varga 1ba53e055a [llvm] Ignore OP_IL_SEQ_POINT. 2016-01-12 12:27:01 -05:00
Rolf Bjarne Kvinge 83e015740a [mscorlib] Add support for intercepting threadpool work, and use it for Xamarin.iOS/Mac.
This is used to Xamarin.iOS/Mac to wrap threadpool work in an NSAutoreleasePool.

Also open up corlib's internals to Xamarin.iOS/Mac so that the linker
doesn't have to be involved when accessing internal API.
2016-01-11 12:21:50 -05:00
211 changed files with 6194 additions and 5303 deletions

No files matched your search

+2
View File
@@ -750,6 +750,8 @@ mono_thread_current
mono_thread_detach
mono_thread_exit
mono_thread_get_main
mono_thread_get_managed_id
mono_thread_get_name_utf8
mono_thread_get_undeniable_exception
mono_thread_hazardous_free_or_queue
mono_thread_hazardous_try_free_all
-436
View File
@@ -1,436 +0,0 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
# Copyright 1999, 2000 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <[email protected]>.
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# `libtool' can also be set to `yes' or `no'.
if test -z "$depfile"; then
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
dir=`echo "$object" | sed 's,/.*$,/,'`
if test "$dir" = "$object"; then
dir=
fi
# FIXME: should be _deps on DOS.
depfile="$dir.deps/$base"
fi
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. This file always lives in the current directory.
# Also, the AIX compiler puts `$object:' at the start of each line;
# $object doesn't have directory information.
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
outname="$stripped.o"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
base=`echo "$object" | sed -e 's/\.o$//' -e 's/\.lo$//'`
tmpdepfile1="$base.o.d"
tmpdepfile2="$base.d"
if test "$libtool" = yes; then
"$@" -Wc,-MD
else
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
else
tmpdepfile="$tmpdepfile2"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a space and a tab in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
test -z "$dashmflag" && dashmflag=-M
( IFS=" "
case " $* " in
*" --mode=compile "*) # this is libtool, let us make it quiet
for arg
do # cycle over the arguments
case "$arg" in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
# X makedepend
(
shift
cleared=no
for arg in "$@"; do
case $cleared in no)
set ""; shift
cleared=yes
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift;;
-*)
;;
*)
set fnord "$@" "$arg"; shift;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
-336
View File
@@ -1,336 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <[email protected]>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing 0.4 - GNU automake"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them.
You can get \`$1Help2man' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
# We have makeinfo, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
tar)
shift
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
fi
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar ${1+"$@"} && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar ${1+"$@"} && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" ${1+"$@"} && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" ${1+"$@"} && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
+3 -1
View File
@@ -889,7 +889,9 @@ environment variable to limit the extent of the messages you get:
If set, the log mask is changed to the set value. Possible values are
"asm" (assembly loader), "type", "dll" (native library loader), "gc"
(garbage collector), "cfg" (config file loader), "aot" (precompiler),
"security" (e.g. Moonlight CoreCLR support) and "all".
"security" (e.g. Moonlight CoreCLR support), "threadpool" (thread pool generic),
"io-threadpool" (thread pool I/O), "io-layer" (I/O layer - sockets, handles, shared memory etc)
and "all".
The default value is "all". Changing the mask value allows you to display only
messages for a certain component. You can use multiple masks by comma
separating them. For example to see config file messages and assembly loader
+6 -2
View File
@@ -44,17 +44,21 @@ static class Consts
public const string FxVersion = "2.0.5.0";
public const string VsVersion = "9.0.0.0"; // unused, but needed for compilation
public const string FxFileVersion = "4.0.50524.0";
public const string EnvironmentVersion = FxFileVersion;
public const string VsFileVersion = "9.0.50727.42"; // unused, but needed for compilation
#elif NET_4_6
public const string FxVersion = "4.0.0.0";
public const string FxFileVersion = "4.6.57.0";
public const string EnvironmentVersion = "4.0.30319.42000";
public const string VsVersion = "0.0.0.0"; // Useless ?
public const string VsFileVersion = "11.0.0.0"; // TODO:
#elif NET_4_5
public const string FxVersion = "4.0.0.0";
public const string FxFileVersion = "4.0.30319.17020";
public const string EnvironmentVersion = FxFileVersion;
public const string VsVersion = "0.0.0.0"; // Useless ?
public const string VsFileVersion = "11.0.0.0"; // TODO:
#elif NET_4_0
@@ -27,6 +27,7 @@ PROFILE_MCS_FLAGS = \
-d:MONOTOUCH \
-d:DISABLE_REMOTING \
-d:DISABLE_COM \
-d:FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK \
-nowarn:1699 \
-nostdlib \
-lib:$(topdir)/class/lib/$(PROFILE) \
+1
View File
@@ -23,6 +23,7 @@ PROFILE_MCS_FLAGS = \
-d:MOBILE \
-d:MOBILE_DYNAMIC \
-d:XAMMAC \
-d:FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK \
-nowarn:1699 \
-nostdlib \
-lib:$(topdir)/class/lib/$(PROFILE) \
+6 -1
View File
@@ -1,5 +1,10 @@
include $(topdir)/build/profiles/net_4_x.make
PROFILE_MCS_FLAGS += -d:NO_SYSTEM_DRAWING_DEPENDENCY -d:NO_WINFORMS_DEPENDENCY -d:NO_SYSTEM_WEB_DEPENDENCY -d:XAMMAC_4_5
PROFILE_MCS_FLAGS += \
-d:FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK \
-d:NO_SYSTEM_DRAWING_DEPENDENCY \
-d:NO_WINFORMS_DEPENDENCY \
-d:NO_SYSTEM_WEB_DEPENDENCY \
-d:XAMMAC_4_5
XAMMAC_4_5=1
NO_WINDOWS_BASE=1
NO_SYSTEM_WEB_DEPENDENCY=1
+7 -4
View File
@@ -53,8 +53,8 @@ mobile_common_dirs := \
Mono.CSharp \
Microsoft.CSharp \
Mono.Security.Providers.DotNet \
Mono.Security.Providers.OldTls \
Mono.Security.Providers.NewSystemSource
Mono.Security.Providers.NewSystemSource \
Mono.Security.Providers.NewTls
mobile_static_dirs := \
$(mobile_common_dirs) \
@@ -133,6 +133,7 @@ xammac_4_5_dirs := \
Mono.Security.Providers.DotNet \
Mono.Security.Providers.OldTls \
Mono.Security.Providers.NewSystemSource \
Mono.Security.Providers.NewTls \
$(pcl_facade_dirs)
net_4_x_dirs := \
@@ -217,7 +218,9 @@ net_4_x_dirs := \
System.Net.Http.Formatting \
System.Web.Http \
System.Web.Http.SelfHost \
System.Web.Http.WebHost
System.Web.Http.WebHost \
Mono.Security.Providers.NewSystemSource \
Mono.Security.Providers.NewTls
# These are the subdirs which depends on libs in net_4_x_dirs
# or have proper dependencies between each other
@@ -262,7 +265,6 @@ net_4_x_parallel_dirs := \
System.Xml.Serialization \
Mono.Security.Providers.DotNet \
Mono.Security.Providers.OldTls \
Mono.Security.Providers.NewSystemSource \
System.DirectoryServices.Protocols \
RabbitMQ.Client \
Microsoft.VisualC \
@@ -324,6 +326,7 @@ DISTFILES = \
notes/BitVecto32.txt \
MicrosoftAjaxLibrary/License.htm \
test-helpers/NetworkHelpers.cs \
test-helpers/SocketResponder.cs \
$(monolite_files)
.PHONY: all-local $(STD_TARGETS:=-local)
@@ -62,7 +62,7 @@ namespace Mono.Security.Providers.DotNet
get { return false; }
}
public override bool SupportsTlsContext {
internal override bool SupportsTlsContext {
get { return false; }
}
@@ -88,7 +88,7 @@ namespace Mono.Security.Providers.DotNet
return new DotNetSslStreamImpl (innerStream, leaveInnerStreamOpen, this, validation_callback, selection_callback);
}
public override IMonoTlsContext CreateTlsContext (
internal override IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, TlsProtocols protocolFlags,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
@@ -30,3 +30,4 @@
../System/Mono.Net.Security/IMonoTlsProvider.cs
../System/Mono.Net.Security/MonoTlsProviderFactory.cs
../System/Mono.Net.Security/MonoTlsProviderWrapper.cs
@@ -45,3 +45,4 @@ using System.Runtime.InteropServices;
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
@@ -0,0 +1,12 @@
thisdir = class/Mono.Security.Providers.NewTls
SUBDIRS =
include ../../build/rules.make
LIBRARY = Mono.Security.Providers.NewTls.dll
LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -r:System.dll \
-r:NewSystemSource=Mono.Security.Providers.NewSystemSource.dll -r:Mono.Security.dll
include ../../build/library.make
$(the_lib): ../Mono.Security/Makefile
@@ -0,0 +1,13 @@
./Properties/AssemblyInfo.cs
../../build/common/SR.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
./Mono.Security.Providers.NewTls/ITlsConfiguration.cs
./Mono.Security.Providers.NewTls/ITlsContext.cs
./Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
./Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
./Mono.Security.Providers.NewTls/NewTlsProvider.cs
./Mono.Security.Providers.NewTls/TlsContextWrapper.cs
./Mono.Security.Providers.NewTls/TlsProviderFactory.cs
@@ -0,0 +1,47 @@
//
// ITlsContext.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015-2016 Xamarin, Inc.
//
// 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;
using System.Security.Cryptography;
using Mono.Security.Interface;
using MX = Mono.Security.X509;
namespace Mono.Security.Providers.NewTls
{
interface ITlsConfiguration
{
bool HasCredentials {
get;
}
void SetCertificate (MX.X509Certificate certificate, AsymmetricAlgorithm privateKey);
bool? AskForClientCertificate {
get; set;
}
}
}
@@ -0,0 +1,70 @@
//
// ITlsContext.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015-2016 Xamarin, Inc.
//
// 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.
extern alias NewSystemSource;
using System;
using System.Security.Cryptography;
using Mono.Security.Interface;
using MX = Mono.Security.X509;
namespace Mono.Security.Providers.NewTls
{
interface ITlsContext : IDisposable
{
bool IsValid {
get;
}
TlsException LastError {
get;
}
bool ReceivedCloseNotify {
get;
}
MonoTlsConnectionInfo ConnectionInfo {
get;
}
MX.X509Certificate GetRemoteCertificate (out MX.X509CertificateCollection remoteCertificateStore);
bool VerifyRemoteCertificate ();
int GenerateNextToken (TlsBuffer incoming, TlsMultiBuffer outgoing);
int DecryptMessage (ref TlsBuffer incoming);
int EncryptMessage (ref TlsBuffer incoming);
byte[] CreateAlert (Alert alert);
byte[] CreateHelloRequest ();
}
}
@@ -0,0 +1,93 @@
//
// MonoNewTlsStream.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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.
extern alias NewSystemSource;
using EncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
using LocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
using RemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
using SslStream = NewSystemSource::System.Net.Security.SslStream;
using System;
using System.IO;
using System.Threading.Tasks;
using MSI = Mono.Security.Interface;
using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
using System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
public class MonoNewTlsStream : SslStream, MSI.IMonoSslStream
{
MSI.MonoTlsProvider provider;
internal MonoNewTlsStream (Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
: this (innerStream, false, provider, settings)
{
}
internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
: base (innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
{
this.provider = provider;
}
public MSI.MonoTlsProvider Provider {
get { return provider; }
}
new public bool IsClosed {
get { return base.IsClosed; }
}
public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
{
return GetMonoConnectionInfo ();
}
public Task Shutdown ()
{
return Task.Factory.FromAsync ((state, result) => BeginShutdown (state, result), EndShutdown, null);
}
public Task RequestRenegotiation ()
{
return Task.Factory.FromAsync ((state, result) => BeginRenegotiate (state, result), EndRenegotiate, null);
}
X509Certificate MSI.IMonoSslStream.InternalLocalCertificate {
get { return InternalLocalCertificate; }
}
XAuthenticatedStream MSI.IMonoSslStream.AuthenticatedStream {
get { return this; }
}
}
}
@@ -0,0 +1,91 @@
//
// MonoNewTlsStreamFactory.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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.
extern alias NewSystemSource;
using XEncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
using XSslPolicyErrors = NewSystemSource::System.Net.Security.SslPolicyErrors;
using XLocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
using XRemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
using System;
using System.IO;
using System.Net.Security;
using System.Security.Authentication;
using Mono.Security.Interface;
using PSSCX = System.Security.Cryptography.X509Certificates;
using SSCX = System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
public static class MonoNewTlsStreamFactory
{
internal static IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsProvider provider, MonoTlsSettings settings = null)
{
return new MonoNewTlsStream (innerStream, leaveInnerStreamOpen, provider, settings);
}
public static MonoNewTlsStream CreateServer (
Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
SSCX.X509Certificate serverCertificate, bool clientCertificateRequired,
SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
try {
stream.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
} catch (Exception ex) {
var tlsEx = stream.LastError;
if (tlsEx != null)
throw new AggregateException (ex, tlsEx);
throw;
}
return stream;
}
public static MonoNewTlsStream CreateClient (
Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
string targetHost, PSSCX.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
try {
stream.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
} catch (Exception ex) {
var tlsEx = stream.LastError;
if (tlsEx != null)
throw new AggregateException (ex, tlsEx);
throw;
}
return stream;
}
}
}
@@ -0,0 +1,95 @@
//
// NewTlsProvider.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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.
extern alias NewSystemSource;
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using MSI = Mono.Security.Interface;
using MX = Mono.Security.X509;
using PSSCX = System.Security.Cryptography.X509Certificates;
using SSCX = System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
public class NewTlsProvider : MSI.MonoTlsProvider
{
static readonly Guid id = new Guid ("e5ff34f1-8b7a-4aa6-aff9-24719d709693");
public override Guid ID {
get { return id; }
}
public override string Name {
get { return "newtls"; }
}
public override bool SupportsSslStream {
get { return true; }
}
public override bool SupportsConnectionInfo {
get { return true; }
}
public override bool SupportsMonoExtensions {
get { return true; }
}
internal override bool SupportsTlsContext {
get { return true; }
}
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
}
public override MSI.IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MSI.MonoTlsSettings settings = null)
{
return MonoNewTlsStreamFactory.CreateSslStream (innerStream, leaveInnerStreamOpen, this, settings);
}
internal override MSI.IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
SSCX.X509Certificate serverCertificate, PSSCX.X509CertificateCollection clientCertificates,
bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
MSI.MonoTlsSettings settings)
{
var config = TlsProviderFactory.CreateTlsConfiguration (
hostname, serverMode, protocolFlags, serverCertificate,
remoteCertRequired, settings);
return new TlsContextWrapper (config, serverMode);
}
}
}
@@ -0,0 +1,221 @@
//
// TlsContextWrapper.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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.
extern alias NewSystemSource;
using System;
using System.Security.Cryptography;
using SSCX = System.Security.Cryptography.X509Certificates;
using PSSCX = System.Security.Cryptography.X509Certificates;
using MSI = Mono.Security.Interface;
using MX = Mono.Security.X509;
namespace Mono.Security.Providers.NewTls
{
class TlsContextWrapper : IDisposable, MSI.IMonoTlsContext
{
ITlsConfiguration config;
ITlsContext context;
bool serverMode;
public TlsContextWrapper (ITlsConfiguration config, bool serverMode)
{
this.config = config;
this.serverMode = serverMode;
}
public bool IsServer {
get { return serverMode; }
}
public bool IsValid {
get { return context != null && context.IsValid; }
}
public void Initialize (MSI.IMonoTlsEventSink eventSink)
{
if (context != null)
throw new InvalidOperationException ();
context = TlsProviderFactory.CreateTlsContext (config, serverMode, eventSink);
}
void Clear ()
{
if (context != null) {
context.Dispose ();
context = null;
}
}
public ITlsConfiguration Configuration {
get {
if (config == null)
throw new ObjectDisposedException ("TlsConfiguration");
return config;
}
}
public ITlsContext Context {
get {
if (!IsValid)
throw new ObjectDisposedException ("TlsContext");
return context;
}
}
public bool HasCredentials {
get { return Configuration.HasCredentials; }
}
public void SetCertificate (SSCX.X509Certificate certificate, AsymmetricAlgorithm privateKey)
{
var monoCert = new MX.X509Certificate (certificate.GetRawCertData ());
Configuration.SetCertificate (monoCert, privateKey);
}
public int GenerateNextToken (MSI.IBufferOffsetSize incoming, out MSI.IBufferOffsetSize outgoing)
{
var input = incoming != null ? new MSI.TlsBuffer (BOSWrapper.Wrap (incoming)) : null;
var output = new MSI.TlsMultiBuffer ();
var retval = Context.GenerateNextToken (input, output);
if (output.IsEmpty)
outgoing = null;
outgoing = BOSWrapper.Wrap (output.StealBuffer ());
return (int)retval;
}
public int EncryptMessage (ref MSI.IBufferOffsetSize incoming)
{
var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
var retval = Context.EncryptMessage (ref buffer);
incoming = BOSWrapper.Wrap (buffer.GetRemaining ());
return (int)retval;
}
public int DecryptMessage (ref MSI.IBufferOffsetSize incoming)
{
var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
var retval = Context.DecryptMessage (ref buffer);
incoming = buffer != null ? BOSWrapper.Wrap (buffer.GetRemaining ()) : null;
return (int)retval;
}
class BOSWrapper : MSI.IBufferOffsetSize
{
public byte[] Buffer {
get;
private set;
}
public int Offset {
get;
private set;
}
public int Size {
get;
private set;
}
BOSWrapper (byte[] buffer, int offset, int size)
{
Buffer = buffer;
Offset = offset;
Size = size;
}
public static BOSWrapper Wrap (MSI.IBufferOffsetSize bos)
{
return bos != null ? new BOSWrapper (bos.Buffer, bos.Offset, bos.Size) : null;
}
}
public byte[] CreateCloseNotify ()
{
return Context.CreateAlert (new MSI.Alert (MSI.AlertLevel.Warning, MSI.AlertDescription.CloseNotify));
}
public byte[] CreateHelloRequest ()
{
return Context.CreateHelloRequest ();
}
public SSCX.X509Certificate GetRemoteCertificate (out PSSCX.X509CertificateCollection remoteCertificateStore)
{
MX.X509CertificateCollection monoCollection;
var remoteCert = Context.GetRemoteCertificate (out monoCollection);
if (remoteCert == null) {
remoteCertificateStore = null;
return null;
}
remoteCertificateStore = new PSSCX.X509CertificateCollection ();
foreach (var cert in monoCollection) {
remoteCertificateStore.Add (new PSSCX.X509Certificate2 (cert.RawData));
}
return new PSSCX.X509Certificate2 (remoteCert.RawData);
}
public bool VerifyRemoteCertificate ()
{
return Context.VerifyRemoteCertificate ();
}
public Exception LastError {
get {
if (context != null)
return context.LastError;
return null;
}
}
public bool ReceivedCloseNotify {
get {
return Context.ReceivedCloseNotify;
}
}
public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
{
return Context.ConnectionInfo;
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
void Dispose (bool disposing)
{
Clear ();
}
}
}
@@ -0,0 +1,97 @@
//
// TlsProviderFactory.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015-2016 Xamarin, Inc.
//
// 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.
extern alias NewSystemSource;
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using MSI = Mono.Security.Interface;
using MX = Mono.Security.X509;
using PSSCX = System.Security.Cryptography.X509Certificates;
using SSCX = System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Providers.NewTls
{
static class TlsProviderFactory
{
const string assemblyName = "Mono.Security.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2";
const string tlsConfigTypeName = "Mono.Security.NewTls.TlsConfiguration";
const string tlsContextTypeName = "Mono.Security.NewTls.TlsContext";
static object CreateInstance (string typeName, object[] args)
{
var type = Type.GetType (typeName + ", " + assemblyName);
return Activator.CreateInstance (type, args);
}
internal static ITlsConfiguration CreateTlsConfiguration (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
SSCX.X509Certificate serverCertificate, bool remoteCertRequired,
MSI.MonoTlsSettings settings)
{
object[] args;
ITlsConfiguration config;
if (serverMode) {
var cert = (PSSCX.X509Certificate2)serverCertificate;
var monoCert = new MX.X509Certificate (cert.RawData);
args = new object[] {
(MSI.TlsProtocols)protocolFlags,
(MSI.MonoTlsSettings)settings,
monoCert,
cert.PrivateKey
};
} else {
args = new object[] {
(MSI.TlsProtocols)protocolFlags,
(MSI.MonoTlsSettings)settings,
hostname
};
}
config = (ITlsConfiguration)CreateInstance (tlsConfigTypeName, args);
if (serverMode && remoteCertRequired)
config.AskForClientCertificate = true;
return config;
}
internal static ITlsContext CreateTlsContext (
ITlsConfiguration config, bool serverMode,
MSI.IMonoTlsEventSink eventSink)
{
return (ITlsContext)CreateInstance (
tlsContextTypeName,
new object[] { config, serverMode, eventSink });
}
}
}
@@ -0,0 +1,47 @@
//
// AssemblyInfo.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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;
using System.Reflection;
using System.Resources;
using System.Security;
using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about the system assembly
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: AssemblyCompany ("Xamarin")]
[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
[assembly: AssemblyDescription ("Mono.Security.Providers.NewTls.dll")]
[assembly: AssemblyProduct ("MONO CLI")]
[assembly: AssemblyTitle ("Mono.Security.Providers.NewTls.dll")]
[assembly: CLSCompliant (false)]
[assembly: ComVisible (false)]
[assembly: NeutralResourcesLanguage ("en-US")]
[assembly: InternalsVisibleTo ("Mono.Security.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
@@ -0,0 +1,7 @@
Properties/AssemblyInfo.cs
Mono.Security.Providers.NewTls/ITlsConfiguration.cs
Mono.Security.Providers.NewTls/ITlsContext.cs
Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
@@ -0,0 +1 @@
#include mobile_Mono.Security.Providers.NewTls.dll.sources
@@ -58,7 +58,7 @@ namespace Mono.Security.Providers.OldTls
get { return false; }
}
public override bool SupportsTlsContext {
internal override bool SupportsTlsContext {
get { return false; }
}
@@ -74,7 +74,7 @@ namespace Mono.Security.Providers.OldTls
return new MNS.Private.MonoSslStreamImpl (impl);
}
public override IMonoTlsContext CreateTlsContext (
internal override IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, TlsProtocols protocolFlags,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
@@ -60,6 +60,13 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../mono.pub")]
#if MOBILE
#if NET_2_1
[assembly: InternalsVisibleTo ("System, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
#else
[assembly: InternalsVisibleTo ("System, PublicKey=00000000000000000400000000000000")]
#endif
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
@@ -0,0 +1,96 @@
//
// BufferOffsetSize.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.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.
using System;
namespace Mono.Security.Interface
{
public class BufferOffsetSize : SecretParameters, IBufferOffsetSize
{
public byte[] Buffer {
get;
private set;
}
public int Offset {
get;
internal set;
}
public int Size {
get { return EndOffset - Offset; }
}
public int EndOffset {
get;
internal set;
}
public BufferOffsetSize (byte[] buffer, int offset, int size)
{
Buffer = buffer;
Offset = offset;
EndOffset = offset + size;
}
public BufferOffsetSize (byte[] buffer)
: this (buffer, 0, buffer.Length)
{
}
public BufferOffsetSize (int size)
: this (new byte [size])
{
}
public byte[] GetBuffer ()
{
var copy = new byte [Size];
Array.Copy (Buffer, Offset, copy, 0, Size);
return copy;
}
public void TruncateTo (int newSize)
{
if (newSize > Size)
throw new ArgumentException ("newSize");
EndOffset = Offset + newSize;
}
protected void SetBuffer (byte[] buffer, int offset, int size)
{
Buffer = buffer;
Offset = offset;
EndOffset = offset + size;
}
protected override void Clear ()
{
Buffer = null;
Offset = EndOffset = 0;
}
}
}
@@ -29,7 +29,7 @@ using System.Security.Cryptography.X509Certificates;
namespace Mono.Security.Interface
{
public interface IMonoTlsContext : IDisposable
interface IMonoTlsContext : IDisposable
{
bool IsServer {
get;
@@ -72,6 +72,10 @@ namespace Mono.Security.Interface
public abstract class MonoTlsProvider
{
internal MonoTlsProvider ()
{
}
public abstract Guid ID {
get;
}
@@ -155,11 +159,11 @@ namespace Mono.Security.Interface
* The managed SSPI implementation from the new TLS code.
*/
public abstract bool SupportsTlsContext {
internal abstract bool SupportsTlsContext {
get;
}
public abstract IMonoTlsContext CreateTlsContext (
internal abstract IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, TlsProtocols protocolFlags,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
@@ -72,14 +72,19 @@ namespace Mono.Security.Interface
}
/*
* Installs a custom TLS Provider.
* Selects the default TLS Provider.
*
* May only be called at application startup and will throw
* @InvalidOperationException if a provider has already been installed.
*/
public static void InstallProvider (MonoTlsProvider provider)
public static void SetDefaultProvider (string name)
{
NoReflectionHelper.InstallProvider (provider);
NoReflectionHelper.SetDefaultProvider (name);
}
public static MonoTlsProvider GetProvider (string name)
{
return (MonoTlsProvider)NoReflectionHelper.GetProvider (name);
}
/*
@@ -82,6 +82,10 @@ namespace Mono.Security.Interface
get; set;
}
public CipherSuiteCode[] EnabledCiphers {
get; set;
}
bool cloned = false;
bool checkCertName = true;
bool checkCertRevocationStatus = false;
@@ -155,6 +159,7 @@ namespace Mono.Security.Interface
callbackNeedsChain = other.callbackNeedsChain;
UserSettings = other.UserSettings;
EnabledProtocols = other.EnabledProtocols;
EnabledCiphers = other.EnabledCiphers;
TrustAnchors = other.TrustAnchors;
cloned = true;
}
@@ -0,0 +1,67 @@
//
// SecretParameters.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.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.
using System;
namespace Mono.Security.Interface
{
public abstract class SecretParameters : IDisposable
{
protected abstract void Clear ();
bool disposed;
protected void CheckDisposed ()
{
if (disposed)
throw new ObjectDisposedException (GetType ().Name);
}
protected static void Clear (byte[] array)
{
Array.Clear (array, 0, array.Length);
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
void Dispose (bool disposing)
{
if (!disposed) {
disposed = true;
Clear ();
}
}
~SecretParameters ()
{
Dispose (false);
}
}
}
@@ -0,0 +1,86 @@
//
// SecureBuffer.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.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.
using System;
namespace Mono.Security.Interface
{
public class SecureBuffer : SecretParameters, IBufferOffsetSize
{
byte[] buffer;
public byte[] Buffer {
get {
CheckDisposed ();
return buffer;
}
}
public int Size {
get {
CheckDisposed ();
return buffer != null ? buffer.Length : 0;
}
}
int IBufferOffsetSize.Offset {
get { return 0; }
}
public SecureBuffer (int size)
{
buffer = new byte [size];
}
public SecureBuffer (byte[] buffer)
{
this.buffer = buffer;
}
public byte[] StealBuffer ()
{
CheckDisposed ();
var retval = this.buffer;
this.buffer = null;
return retval;
}
public static SecureBuffer CreateCopy (byte[] buffer)
{
var copy = new byte [buffer.Length];
Array.Copy (buffer, copy, buffer.Length);
return new SecureBuffer (copy);
}
protected override void Clear ()
{
if (buffer != null) {
Array.Clear (buffer, 0, buffer.Length);
buffer = null;
}
}
}
}
@@ -0,0 +1,334 @@
//
// TlsBuffer.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.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.
using System;
namespace Mono.Security.Interface
{
public class TlsBuffer : SecretParameters
{
public int Position {
get; set;
}
public int Remaining {
get { return Size - (Position - Offset); }
}
public byte[] Buffer {
get { return innerBuffer.Buffer; }
}
public int Offset {
get { return innerBuffer.Offset; }
}
public int Size {
get { return innerBuffer.Size; }
}
public int EndOffset {
get { return Offset + Size; }
}
IBufferOffsetSize innerBuffer;
protected TlsBuffer ()
: this (null, 0, 0)
{
}
public TlsBuffer (IBufferOffsetSize bos)
{
innerBuffer = bos;
Position = bos.Offset;
}
public TlsBuffer (byte[] buffer, int offset, int size)
: this (new BufferOffsetSize (buffer, offset, size))
{
}
public TlsBuffer (byte[] buffer)
: this (buffer, 0, buffer.Length)
{
}
public TlsBuffer (int size)
: this (new byte [size], 0, size)
{
}
public byte ReadByte ()
{
if (Position >= EndOffset)
throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
return Buffer [Position++];
}
public short ReadInt16 ()
{
if (Position + 1 >= EndOffset)
throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
var retval = (short)(Buffer [Position] << 8 | Buffer [Position + 1]);
Position += 2;
return retval;
}
public int ReadInt24 ()
{
if (Position + 2 >= EndOffset)
throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
var retval = ((Buffer [Position] << 16) | (Buffer [Position+1] << 8) | Buffer [Position+2]);
Position += 3;
return retval;
}
public int ReadInt32 ()
{
if (Position + 3 >= EndOffset)
throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
var retval = ((Buffer [Position] << 24) | (Buffer [Position+1] << 16) | (Buffer [Position+2] << 8) | Buffer [Position+3]);
Position += 4;
return retval;
}
public TlsBuffer ReadBuffer (int length)
{
if (Position + length > EndOffset)
throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
var retval = new TlsBuffer (Buffer, Position, length);
Position += length;
return retval;
}
public IBufferOffsetSize GetRemaining ()
{
return new BufferOffsetSize (Buffer, Position, Remaining);
}
protected virtual void MakeRoomInternal (int size)
{
if (Position + size > EndOffset)
throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
}
public void Write (byte value)
{
MakeRoomInternal (1);
Buffer [Position++] = value;
}
public void Write (short value)
{
MakeRoomInternal (2);
WriteInt16 (Buffer, Position, value);
Position += 2;
}
public static void WriteInt16 (byte[] buffer, int offset, short value)
{
buffer[offset] = ((byte)(value >> 8));
buffer[offset+1] = ((byte)value);
}
public void Write (int value)
{
MakeRoomInternal (4);
WriteInt32 (Buffer, Position, value);
Position += 4;
}
public void WriteInt24 (int value)
{
MakeRoomInternal (3);
WriteInt24 (Buffer, Position, value);
Position += 3;
}
#pragma warning disable 3001
public void Write (ulong value)
#pragma warning restore 3001
{
MakeRoomInternal (8);
WriteInt64 (Buffer, Position, value);
Position += 8;
}
public static void WriteInt24 (byte[] buffer, int offset, int value)
{
buffer[offset] = ((byte)(value >> 16));
buffer[offset+1] = ((byte)(value >> 8));
buffer[offset+2] = ((byte)value);
}
public static void WriteInt32 (byte[] buffer, int offset, int value)
{
buffer[offset] = ((byte)(value >> 24));
buffer[offset+1] = ((byte)(value >> 16));
buffer[offset+2] = ((byte)(value >> 8));
buffer[offset+3] = ((byte)value);
}
#pragma warning disable 3001
public static void WriteInt64 (byte[] buffer, int offset, ulong value)
#pragma warning restore 3001
{
buffer[offset] = (byte) (value >> 56);
buffer[offset+1] = (byte) (value >> 48);
buffer[offset+2] = (byte) (value >> 40);
buffer[offset+3] = (byte) (value >> 32);
buffer[offset+4] = (byte) (value >> 24);
buffer[offset+5] = (byte) (value >> 16);
buffer[offset+6] = (byte) (value >> 8);
buffer[offset+7] = (byte) value;
}
public void Write (byte[] buffer)
{
Write (buffer, 0, buffer.Length);
}
public void Write (byte[] buffer, int offset, int size)
{
MakeRoomInternal (size);
Array.Copy (buffer, offset, Buffer, Position, size);
Position += size;
}
public void Write (IBufferOffsetSize buffer)
{
Write (buffer.Buffer, buffer.Offset, buffer.Size);
}
public SecureBuffer ReadSecureBuffer (int count)
{
return new SecureBuffer (ReadBytes (count));
}
public byte[] ReadBytes (int count)
{
if (Position + count > EndOffset)
throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
var retval = new byte [count];
Array.Copy (Buffer, Position, retval, 0, count);
Position += count;
return retval;
}
internal static bool Compare (SecureBuffer buffer1, SecureBuffer buffer2)
{
if (buffer1 == null || buffer2 == null)
return false;
if (buffer1.Size != buffer2.Size)
return false;
for (int i = 0; i < buffer1.Size; i++) {
if (buffer1.Buffer [i] != buffer2.Buffer [i])
return false;
}
return true;
}
public static bool Compare (IBufferOffsetSize buffer1, IBufferOffsetSize buffer2)
{
if (buffer1 == null || buffer2 == null)
return false;
if (buffer1.Size != buffer2.Size)
return false;
for (int i = 0; i < buffer1.Size; i++) {
if (buffer1.Buffer [buffer1.Offset + i] != buffer2.Buffer [buffer2.Offset + i])
return false;
}
return true;
}
public static bool Compare (byte[] buffer1, byte[] buffer2)
{
if (buffer1 == null || buffer2 == null)
return false;
return Compare (buffer1, 0, buffer1.Length, buffer2, 0, buffer2.Length);
}
public static bool Compare (byte[] buffer1, int offset1, int size1, byte[] buffer2, int offset2, int size2)
{
if (buffer1 == null || buffer2 == null)
return false;
if (size1 != size2)
return false;
for (int i = 0; i < size1; i++) {
if (buffer1 [offset1 + i] != buffer2 [offset2 + i])
return false;
}
return true;
}
public static int ConstantTimeCompare (byte[] buffer1, int offset1, int size1, byte[] buffer2, int offset2, int size2)
{
int status = 0;
int effectiveSize;
if (size1 < size2) {
status--;
effectiveSize = size1;
} else if (size2 < size1) {
status--;
effectiveSize = size2;
} else {
effectiveSize = size1;
}
for (int i = 0; i < effectiveSize; i++) {
if (buffer1 [offset1 + i] != buffer2 [offset2 + i])
status--;
}
return status;
}
protected void SetBuffer (byte[] buffer, int offset, int size)
{
innerBuffer = new BufferOffsetSize (buffer, offset, size);
}
protected override void Clear ()
{
var disposable = innerBuffer as IDisposable;
if (disposable != null)
disposable.Dispose ();
innerBuffer = null;
Position = 0;
}
public static readonly byte[] EmptyArray = new byte [0];
}
}
@@ -0,0 +1,119 @@
//
// TlsMultiBuffer.cs
//
// Author:
// Martin Baulig <[email protected]>
//
// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.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.
using System;
namespace Mono.Security.Interface
{
public class TlsMultiBuffer
{
MemoryChunk first, last;
private class MemoryChunk : BufferOffsetSize
{
public MemoryChunk next;
public MemoryChunk (byte[] buffer, int offset, int size)
: base (buffer, offset, size)
{
}
}
public bool IsEmpty {
get { return first == null; }
}
public bool IsSingle {
get { return first != null && first.next == null; }
}
public void Add (TlsBuffer buffer)
{
Add (buffer.Buffer, buffer.Offset, buffer.Size);
}
public void Add (byte[] buffer)
{
Add (buffer, 0, buffer.Length);
}
public void Add (byte[] buffer, int offset, int size)
{
var chunk = new MemoryChunk (buffer, offset, size);
if (last == null)
first = last = chunk;
else {
last.next = chunk;
last = chunk;
}
}
public BufferOffsetSize[] GetBufferArray ()
{
int count = 0;
for (var ptr = first; ptr != null; ptr = ptr.next)
count++;
var array = new BufferOffsetSize [count];
count = 0;
for (var ptr = first; ptr != null; ptr = ptr.next)
array [count++] = ptr;
return array;
}
public void Clear ()
{
for (var ptr = first; ptr != null; ptr = ptr.next)
ptr.Dispose ();
first = last = null;
}
public BufferOffsetSize GetBuffer ()
{
int totalSize = 0;
for (var ptr = first; ptr != null; ptr = ptr.next)
totalSize += ptr.Size;
var outBuffer = new BufferOffsetSize (new byte [totalSize]);
int offset = 0;
for (var ptr = first; ptr != null; ptr = ptr.next) {
Buffer.BlockCopy (ptr.Buffer, ptr.Offset, outBuffer.Buffer, offset, ptr.Size);
offset += ptr.Size;
}
return outBuffer;
}
public BufferOffsetSize StealBuffer ()
{
if (IsSingle) {
var retval = first;
first = last = null;
return retval;
}
return GetBuffer ();
}
}
}
@@ -46,12 +46,7 @@ using Mono.Security.Cryptography;
namespace Mono.Security.Protocol.Ntlm {
[Obsolete (Type3Message.LegacyAPIWarning)]
#if INSIDE_SYSTEM
internal
#else
public
#endif
class ChallengeResponse : IDisposable {
public class ChallengeResponse : IDisposable {
static private byte[] magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 };
@@ -49,12 +49,7 @@ using Mono.Security.Cryptography;
namespace Mono.Security.Protocol.Ntlm {
#if INSIDE_SYSTEM
internal
#else
public
#endif
static class ChallengeResponse2 {
public static class ChallengeResponse2 {
static private byte[] magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 };
@@ -39,12 +39,7 @@ using System.Globalization;
namespace Mono.Security.Protocol.Ntlm {
#if INSIDE_SYSTEM
internal
#else
public
#endif
abstract class MessageBase {
public abstract class MessageBase {
static private byte[] header = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00 };
@@ -36,12 +36,7 @@ namespace Mono.Security.Protocol.Ntlm {
* is LM_and_NTLM_and_try_NTLMv2_Session.
*/
#if INSIDE_SYSTEM
internal
#else
public
#endif
enum NtlmAuthLevel {
public enum NtlmAuthLevel {
/* Use LM and NTLM, never use NTLMv2 session security. */
LM_and_NTLM,
@@ -40,12 +40,7 @@ using System;
namespace Mono.Security.Protocol.Ntlm {
[Flags]
#if INSIDE_SYSTEM
internal
#else
public
#endif
enum NtlmFlags : int {
public enum NtlmFlags : int {
// The client sets this flag to indicate that it supports Unicode strings.
NegotiateUnicode = 0x00000001,
// This is set to indicate that the client supports OEM strings.
@@ -38,48 +38,13 @@ namespace Mono.Security.Protocol.Ntlm {
* is LM_and_NTLM_and_try_NTLMv2_Session.
*/
#if INSIDE_SYSTEM
internal
#else
public
#endif
static class NtlmSettings {
public static class NtlmSettings {
static NtlmAuthLevel defaultAuthLevel = NtlmAuthLevel.LM_and_NTLM_and_try_NTLMv2_Session;
static FieldInfo GetDefaultAuthLevelField ()
{
#if INSIDE_SYSTEM
return null;
#else
var type = typeof (HttpWebRequest).Assembly.GetType ("Mono.Security.Protocol.Ntlm.NtlmSettings", false);
if (type == null)
return null;
return type.GetField ("defaultAuthLevel", BindingFlags.Static | BindingFlags.NonPublic);
#endif
}
#if INSIDE_SYSTEM
internal
#else
public
#endif
static NtlmAuthLevel DefaultAuthLevel {
get {
var field = GetDefaultAuthLevelField ();
if (field != null)
return (NtlmAuthLevel)field.GetValue (null);
else
return defaultAuthLevel;
}
set {
var field = GetDefaultAuthLevelField ();
if (field != null)
field.SetValue (null, value);
else
defaultAuthLevel = value;
}
public static NtlmAuthLevel DefaultAuthLevel {
get { return defaultAuthLevel; }
set { defaultAuthLevel = value; }
}
}
}
@@ -39,12 +39,7 @@ using System.Text;
namespace Mono.Security.Protocol.Ntlm {
#if INSIDE_SYSTEM
internal
#else
public
#endif
class Type1Message : MessageBase {
public class Type1Message : MessageBase {
private string _host;
private string _domain;
@@ -39,12 +39,7 @@ using System.Security.Cryptography;
namespace Mono.Security.Protocol.Ntlm {
#if INSIDE_SYSTEM
internal
#else
public
#endif
class Type2Message : MessageBase {
public class Type2Message : MessageBase {
private byte[] _nonce;
private string _targetName;
@@ -39,12 +39,7 @@ using System.Text;
namespace Mono.Security.Protocol.Ntlm {
#if INSIDE_SYSTEM
internal
#else
public
#endif
class Type3Message : MessageBase {
public class Type3Message : MessageBase {
private NtlmAuthLevel _level;
private byte[] _challenge;
@@ -152,3 +152,9 @@
./Mono.Security.Interface/TlsException.cs
./Mono.Security.Interface/TlsProtocolCode.cs
./Mono.Security.Interface/TlsProtocols.cs
./Mono.Security.Interface/BufferOffsetSize.cs
./Mono.Security.Interface/SecretParameters.cs
./Mono.Security.Interface/SecureBuffer.cs
./Mono.Security.Interface/TlsBuffer.cs
./Mono.Security.Interface/TlsMultiBuffer.cs
@@ -61,15 +61,6 @@
./Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs
./Mono.Security.Cryptography/TlsHMAC.cs
./Mono.Security.Cryptography/MD5SHA1.cs
./Mono.Security.Protocol.Ntlm/ChallengeResponse.cs
./Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs
./Mono.Security.Protocol.Ntlm/MessageBase.cs
./Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs
./Mono.Security.Protocol.Ntlm/NtlmFlags.cs
./Mono.Security.Protocol.Ntlm/NtlmSettings.cs
./Mono.Security.Protocol.Ntlm/Type1Message.cs
./Mono.Security.Protocol.Ntlm/Type2Message.cs
./Mono.Security.Protocol.Ntlm/Type3Message.cs
./Mono.Security.Protocol.Tls/Alert.cs
./Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
./Mono.Security.Protocol.Tls/CipherSuite.cs
@@ -130,3 +121,9 @@
./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs
./Mono.Xml/MiniParser.cs
./Mono.Xml/SecurityParser.cs
./Mono.Security.Interface/BufferOffsetSize.cs
./Mono.Security.Interface/SecretParameters.cs
./Mono.Security.Interface/SecureBuffer.cs
./Mono.Security.Interface/TlsBuffer.cs
./Mono.Security.Interface/TlsMultiBuffer.cs
@@ -277,6 +277,10 @@ namespace MonoTests.System.Linq.Expressions
[Test]
public void NegateDecimal ()
{
// Make sure the negate method is not linked away
decimal d1 = 1;
decimal d2 = -d1;
var d = Expression.Parameter (typeof (decimal), "l");
var meth = typeof (decimal).GetMethod ("op_UnaryNegation", new [] { typeof (decimal) });
@@ -66,7 +66,7 @@ namespace System.Net.Http
public string ReasonPhrase {
get {
return reasonPhrase ?? HttpListenerResponse.GetStatusDescription ((int) statusCode);
return reasonPhrase ?? HttpListenerResponseHelper.GetStatusDescription ((int) statusCode);
}
set {
reasonPhrase = value;
@@ -19,6 +19,10 @@ else
LIB_MCS_FLAGS += /d:NO_CONFIGURATION /d:NO_SECURITY_ATTRIBUTES /d:NO_CODEDOM /d:NO_DESKTOP_SECURITY
endif
ifdef XAMMAC_4_5
LIB_MCS_FLAGS += /d:NO_CONFIGURATION
endif
TEST_RESOURCE_FILES = \
Test/Resources/WSDL/collections.wsdl \
Test/Resources/WSDL/custom-collections.wsdl
@@ -0,0 +1 @@
#include monotouch_System.ServiceModel.Internals.dll.sources
@@ -31,6 +31,6 @@ System.Web.Services.Description/WebReferenceOptionsTest.cs
System.Web.Services.Description/WebServicesInteroperabilityTest.cs
System.Web.Services.Protocols/LogicalMethodInfoTest.cs
System.Web.Services.Protocols/SoapHttpClientProtocolTest.cs
System.Web.Services.Protocols/SocketResponder.cs
System.Web.Services.Protocols/WebClientProtocolTest.cs
System.Web.Services.Protocols/SoapServerTypeTest.cs
../../test-helpers/SocketResponder.cs
@@ -39,6 +39,8 @@ using System.Xml.Serialization;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.Web.Services.Protocols
{
[TestFixture]
@@ -49,9 +51,7 @@ namespace MonoTests.System.Web.Services.Protocols
public void OutParametersTest ()
{
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 5000);
using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (OutParametersResponse))) {
sr.Start ();
using (SocketResponder sr = new SocketResponder (localEP, s => OutParametersResponse (s))) {
FooService service = new FooService ();
service.Url = "http://" + IPAddress.Loopback.ToString () + ":5000/";
@@ -62,8 +62,6 @@ namespace MonoTests.System.Web.Services.Protocols
Assert.AreEqual (0, a, "#A2");
Assert.IsFalse (b, "#A3");
service.Dispose ();
sr.Stop ();
}
}
@@ -72,9 +70,7 @@ namespace MonoTests.System.Web.Services.Protocols
public void FaultTest ()
{
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 5000);
using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (FaultResponse_Qualified))) {
sr.Start ();
using (SocketResponder sr = new SocketResponder (localEP, s => FaultResponse_Qualified (s))) {
FooService service = new FooService ();
service.Url = "http://" + IPAddress.Loopback.ToString () + ":5000/";
try {
@@ -97,13 +93,9 @@ namespace MonoTests.System.Web.Services.Protocols
Assert.AreEqual ("Failure processing request.", ex.Message, "#A9");
}
service.Dispose ();
sr.Stop ();
}
using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (FaultResponse_Unqualified))) {
sr.Start ();
using (SocketResponder sr = new SocketResponder (localEP, s => FaultResponse_Unqualified (s))) {
FooService service = new FooService ();
service.Url = "http://" + IPAddress.Loopback.ToString () + ":5000/";
try {
@@ -126,8 +118,6 @@ namespace MonoTests.System.Web.Services.Protocols
Assert.AreEqual ("Failure processing request.", ex.Message, "#B9");
}
service.Dispose ();
sr.Stop ();
}
}
@@ -1,125 +0,0 @@
//
// SocketResponder.cs - Utility class for tests that require a listener
//
// Author:
// Gert Driesen ([email protected])
//
// Copyright (C) 2007 Gert Driesen
//
// 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;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace MonoTests.System.Web.Services.Protocols
{
public delegate byte [] SocketRequestHandler (Socket socket);
public class SocketResponder : IDisposable
{
private TcpListener tcpListener;
private readonly IPEndPoint _localEndPoint;
private Thread listenThread;
private SocketRequestHandler _requestHandler;
private bool _stopped = true;
private readonly object _syncRoot = new object ();
private const int SOCKET_CLOSED = 10004;
public SocketResponder (IPEndPoint localEP, SocketRequestHandler requestHandler)
{
_localEndPoint = localEP;
_requestHandler = requestHandler;
}
public IPEndPoint LocalEndPoint
{
get { return _localEndPoint; }
}
public void Dispose ()
{
Stop ();
}
public bool IsStopped
{
get
{
lock (_syncRoot) {
return _stopped;
}
}
}
public void Start ()
{
lock (_syncRoot) {
if (!_stopped)
return;
_stopped = false;
listenThread = new Thread (new ThreadStart (Listen));
listenThread.Start ();
Thread.Sleep (20); // allow listener to start
}
}
public void Stop ()
{
lock (_syncRoot) {
if (_stopped)
return;
_stopped = true;
if (tcpListener != null) {
tcpListener.Stop ();
tcpListener = null;
#if MONO_FEATURE_THREAD_ABORT
listenThread.Abort ();
#else
listenThread.Interrupt ();
#endif
listenThread.Join ();
listenThread = null;
}
}
}
private void Listen ()
{
tcpListener = new TcpListener (LocalEndPoint);
tcpListener.Start ();
try {
Socket socket = tcpListener.AcceptSocket ();
socket.Send (_requestHandler (socket));
socket.Close ();
} catch (SocketException ex) {
// ignore interruption of blocking call
if (ex.ErrorCode != SOCKET_CLOSED)
throw;
}
}
}
}
@@ -39,6 +39,30 @@ namespace System.Web
{
}
public override void Add (string name, string value)
{
if (IsReadOnly)
throw new PlatformNotSupportedException ();
base.Set (name, value);
}
public override void Set (string name, string value)
{
if (IsReadOnly)
throw new PlatformNotSupportedException ();
base.Set (name, value);
}
public override void Remove (string name)
{
if (IsReadOnly)
throw new PlatformNotSupportedException ();
base.Remove (name);
}
protected override void InsertInfo()
{
HttpWorkerRequest worker_request = _request.WorkerRequest;
@@ -254,6 +254,30 @@ namespace MonoTests.System.Web {
{
HttpContext.Current.Request.MapPath ("Web.config", "something", false);
}
[Test]
[ExpectedException (typeof (PlatformNotSupportedException))]
public void ReadOnlyHeadersAdd ()
{
var r = new HttpRequest ("file", "http://www.gnome.org", "key=value&key2=value%32second");
r.Headers.Add ("a","a");
}
[Test]
[ExpectedException (typeof (PlatformNotSupportedException))]
public void ReadOnlyHeadersSet ()
{
var r = new HttpRequest ("file", "http://www.gnome.org", "key=value&key2=value%32second");
r.Headers.Set ("a","a");
}
[Test]
[ExpectedException (typeof (PlatformNotSupportedException))]
public void ReadOnlyHeadersRemove ()
{
var r = new HttpRequest ("file", "http://www.gnome.org", "key=value&key2=value%32second");
r.Headers.Remove ("a");
}
}
[TestFixture]
@@ -35,6 +35,7 @@ namespace System.Windows.Forms {
public object [] Args;
public AsyncMethodResult Result;
public ExecutionContext Context;
public SynchronizationContext SyncContext;
}
}
@@ -468,11 +468,10 @@ namespace System.Windows.Forms {
#endregion // XplatUI Driver Methods
}
internal class XplatUIDriverSupport {
static class XplatUIDriverSupport {
#region XplatUI Driver Support Methods
internal static void ExecutionCallback (object state)
internal static void ExecutionCallback (AsyncMethodData data)
{
AsyncMethodData data = (AsyncMethodData) state;
AsyncMethodResult result = data.Result;
object ret;
@@ -492,6 +491,25 @@ namespace System.Windows.Forms {
}
}
static void ExecutionCallbackInContext (object state)
{
AsyncMethodData data = (AsyncMethodData) state;
if (data.SyncContext == null) {
ExecutionCallback (data);
return;
}
var oldContext = SynchronizationContext.Current;
SynchronizationContext.SetSynchronizationContext (data.SyncContext);
try {
ExecutionCallback (data);
} finally {
SynchronizationContext.SetSynchronizationContext (oldContext);
}
}
internal static void ExecuteClientMessage (GCHandle gchandle)
{
AsyncMethodData data = (AsyncMethodData) gchandle.Target;
@@ -499,7 +517,8 @@ namespace System.Windows.Forms {
if (data.Context == null) {
ExecutionCallback (data);
} else {
ExecutionContext.Run (data.Context, new ContextCallback (ExecutionCallback), data);
data.SyncContext = SynchronizationContext.Current;
ExecutionContext.Run (data.Context, new ContextCallback (ExecutionCallbackInContext), data);
}
}
finally {
@@ -646,8 +646,15 @@ namespace System.Xml.Serialization
{
if (memberValue == null) return null;
Type type = memberValue.GetType();
foreach (XmlTypeMapElementInfo elem in _itemInfo)
if (elem.TypeData.Type == type) return elem;
XmlTypeMapElementInfo bestMatch = null;
foreach (XmlTypeMapElementInfo elem in _itemInfo) {
if (elem.TypeData.Type == type)
return elem;
if (elem.TypeData.Type.IsAssignableFrom (type) &&
(bestMatch == null || elem.TypeData.Type.IsAssignableFrom (bestMatch.TypeData.Type)))
bestMatch = elem;
}
return bestMatch;
}
return null;
}
@@ -711,6 +711,13 @@ namespace MonoTests.System.Xml.TestClasses
public object data;
}
public class SubclassTestList
{
[XmlElement ("a", typeof (SimpleClass))]
[XmlElement ("b", typeof (SubclassTestBase))]
public List<object> Items;
}
public class DictionaryWithIndexer : DictionaryBase
{
public TimeSpan this[int index]
@@ -1939,6 +1939,17 @@ namespace MonoTests.System.XmlSerialization
Assert.AreEqual (Infoset (res), WriterText);
}
[Test] // Covers #36829
public void TestSubclassElementList ()
{
var o = new SubclassTestList () { Items = new List<object> () { new SubclassTestSub () } };
Serialize (o);
string res = "<SubclassTestList xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
res += "<b xsi:type=\"SubclassTestSub\"/></SubclassTestList>";
Assert.AreEqual (Infoset (res), WriterText);
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void TestArrayAttributeWithWrongDataType ()
@@ -80,4 +80,6 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
@@ -366,8 +366,6 @@ namespace Mono.CSharp
}
}
args.Append("/sdk:4.5");
args.Append (" -- ");
foreach (string source in fileNames)
args.AppendFormat("\"{0}\" ",source);
+1 -1
View File
@@ -148,7 +148,7 @@ namespace Mono.Http
return null;
lock (cache) {
var ds = cache.GetOrCreateValue (request);
var ds = cache.GetValue (request, x => new NtlmSession ());
return ds.Authenticate (header, webRequest, credentials);
}
}
@@ -86,7 +86,7 @@ namespace Mono.Net.Security.Private
get { return false; }
}
public override bool SupportsTlsContext {
internal override bool SupportsTlsContext {
get { return false; }
}
@@ -134,25 +134,35 @@ namespace Mono.Net.Security
#if SECURITY_DEP && !MONO_FEATURE_NEW_SYSTEM_SOURCE
#if !MOBILE
static Dictionary<string,string> providerRegistration;
internal static void RegisterProvider (string name, string type)
static Type LookupProviderType (string name, bool throwOnError)
{
lock (locker) {
InitializeProviderRegistration ();
providerRegistration.Add (name, type);
string typeName;
if (!providerRegistration.TryGetValue (name, out typeName)) {
if (throwOnError)
throw new NotSupportedException (string.Format ("No such TLS Provider: `{0}'.", name));
return null;
}
var type = Type.GetType (typeName, false);
if (type == null && throwOnError)
throw new NotSupportedException (string.Format ("Could not find TLS Provider: `{0}'.", typeName));
return type;
}
}
static string LookupProvider (string name)
static MSI.MonoTlsProvider LookupProvider (string name, bool throwOnError)
{
lock (locker) {
InitializeProviderRegistration ();
string type;
if (!providerRegistration.TryGetValue (name, out type))
type = null;
return type;
var type = LookupProviderType (name, throwOnError);
if (type == null)
return null;
try {
return (MSI.MonoTlsProvider)Activator.CreateInstance (type);
} catch (Exception ex) {
throw new NotSupportedException (string.Format ("Unable to instantiate TLS Provider `{0}'.", type), ex);
}
}
@@ -162,11 +172,12 @@ namespace Mono.Net.Security
if (providerRegistration != null)
return;
providerRegistration = new Dictionary<string,string> ();
providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2");
providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2");
providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
}
}
#if !MOBILE
static IMonoTlsProvider TryDynamicLoad ()
{
var variable = Environment.GetEnvironmentVariable ("MONO_TLS_PROVIDER");
@@ -176,25 +187,7 @@ namespace Mono.Net.Security
if (string.Equals (variable, "default", StringComparison.OrdinalIgnoreCase))
return null;
string typeName;
if (variable.IndexOfAny (new char[] { ',', '.', '=' }) > 0) {
typeName = variable;
} else {
typeName = LookupProvider (variable);
if (typeName == null)
throw new NotSupportedException (string.Format ("No such TLS Provider: `{0}'.", typeName));
}
var type = Type.GetType (typeName, false);
if (type == null)
throw new NotSupportedException (string.Format ("Could not find TLS Provider: `{0}'.", typeName));
MSI.MonoTlsProvider provider;
try {
provider = (MSI.MonoTlsProvider)Activator.CreateInstance (type);
} catch (Exception ex) {
throw new NotSupportedException (string.Format ("Unable to instantiate TLS Provider `{0}'.", typeName), ex);
}
var provider = LookupProvider (variable, true);
return new Private.MonoTlsProviderWrapper (provider);
}
@@ -237,6 +230,11 @@ namespace Mono.Net.Security
return provider.Provider;
}
internal static MSI.MonoTlsProvider GetProvider (string name)
{
return LookupProvider (name, false);
}
internal static bool HasProvider {
get {
lock (locker) {
@@ -245,9 +243,10 @@ namespace Mono.Net.Security
}
}
internal static void InstallProvider (MSI.MonoTlsProvider provider)
internal static void SetDefaultProvider (string name)
{
lock (locker) {
var provider = LookupProvider (name, true);
currentProvider = new Private.MonoTlsProviderWrapper (provider);
}
}
@@ -100,7 +100,7 @@ namespace Mono.Net.Security.Private
bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
MSI.MonoTlsSettings settings);
public override MSI.IMonoTlsContext CreateTlsContext (
internal override MSI.IMonoTlsContext CreateTlsContext (
string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
@@ -84,10 +84,10 @@ namespace Mono.Net.Security
}
}
internal static void InstallProvider (object provider)
internal static void SetDefaultProvider (string name)
{
#if SECURITY_DEP
MonoTlsProviderFactory.InstallProvider ((MSI.MonoTlsProvider)provider);
MonoTlsProviderFactory.SetDefaultProvider (name);
#else
throw new NotSupportedException ();
#endif
@@ -120,5 +120,13 @@ namespace Mono.Net.Security
#endif
}
internal static object GetProvider (string name)
{
#if SECURITY_DEP
return MonoTlsProviderFactory.GetProvider (name);
#else
throw new NotSupportedException ();
#endif
}
}
}
+64 -149
View File
@@ -1281,11 +1281,11 @@ namespace System.Diagnostics {
return false;
#if MONO_FEATURE_PROCESS_START
if (async_output != null && !async_output.IsCompleted)
async_output.AsyncWaitHandle.WaitOne ();
if (async_output != null)
async_output.WaitUtilEOF ();
if (async_error != null && !async_error.IsCompleted)
async_error.AsyncWaitHandle.WaitOne ();
if (async_error != null)
async_error.WaitUtilEOF ();
#endif // MONO_FEATURE_PROCESS_START
if (EnableRaisingEvents)
@@ -1327,20 +1327,6 @@ namespace System.Diagnostics {
[MonitoringDescription ("Raised when it receives error data")]
public event DataReceivedEventHandler ErrorDataReceived;
void OnOutputDataReceived (string str)
{
DataReceivedEventHandler cb = OutputDataReceived;
if (cb != null)
cb (this, new DataReceivedEventArgs (str));
}
void OnErrorDataReceived (string str)
{
DataReceivedEventHandler cb = ErrorDataReceived;
if (cb != null)
cb (this, new DataReceivedEventArgs (str));
}
#if MONO_FEATURE_PROCESS_START
[Flags]
enum AsyncModes {
@@ -1351,121 +1337,9 @@ namespace System.Diagnostics {
AsyncError = 1 << 3
}
[StructLayout (LayoutKind.Sequential)]
sealed class ProcessAsyncReader : IOAsyncResult
{
Process process;
IntPtr handle;
Stream stream;
bool err_out;
StringBuilder sb = new StringBuilder ();
byte[] buffer = new byte [4096];
const int ERROR_INVALID_HANDLE = 6;
public ProcessAsyncReader (Process process, FileStream stream, bool err_out)
: base (null, null)
{
this.process = process;
this.handle = stream.SafeFileHandle.DangerousGetHandle ();
this.stream = stream;
this.err_out = err_out;
}
public void BeginReadLine ()
{
IOSelector.Add (this.handle, new IOSelectorJob (IOOperation.Read, _ => Read (), null));
}
void Read ()
{
int nread = 0;
try {
nread = stream.Read (buffer, 0, buffer.Length);
} catch (ObjectDisposedException) {
} catch (IOException ex) {
if (ex.HResult != (unchecked((int) 0x80070000) | (int) ERROR_INVALID_HANDLE))
throw;
} catch (NotSupportedException) {
if (stream.CanRead)
throw;
}
if (nread == 0) {
Flush (true);
if (err_out)
process.OnOutputDataReceived (null);
else
process.OnErrorDataReceived (null);
IsCompleted = true;
return;
}
try {
sb.Append (Encoding.Default.GetString (buffer, 0, nread));
} catch {
// Just in case the encoding fails...
for (int i = 0; i < nread; i++) {
sb.Append ((char) buffer [i]);
}
}
Flush (false);
IOSelector.Add (this.handle, new IOSelectorJob (IOOperation.Read, _ => Read (), null));
}
void Flush (bool last)
{
if (sb.Length == 0 || (err_out && process.output_canceled) || (!err_out && process.error_canceled))
return;
string[] strs = sb.ToString ().Split ('\n');
sb.Length = 0;
if (strs.Length == 0)
return;
for (int i = 0; i < strs.Length - 1; i++) {
if (err_out)
process.OnOutputDataReceived (strs [i]);
else
process.OnErrorDataReceived (strs [i]);
}
string end = strs [strs.Length - 1];
if (last || (strs.Length == 1 && end == "")) {
if (err_out)
process.OnOutputDataReceived (end);
else
process.OnErrorDataReceived (end);
} else {
sb.Append (end);
}
}
public void Close ()
{
IOSelector.Remove (handle);
}
internal override void CompleteDisposed ()
{
throw new NotSupportedException ();
}
}
AsyncModes async_mode;
bool output_canceled;
bool error_canceled;
ProcessAsyncReader async_output;
ProcessAsyncReader async_error;
AsyncStreamReader async_output;
AsyncStreamReader async_error;
[ComVisibleAttribute(false)]
public void BeginOutputReadLine ()
@@ -1476,11 +1350,26 @@ namespace System.Diagnostics {
if ((async_mode & AsyncModes.SyncOutput) != 0)
throw new InvalidOperationException ("Cannot mix asynchronous and synchonous reads.");
if ((async_mode & AsyncModes.AsyncOutput) != 0)
throw new InvalidOperationException ("An async read operation has already been started on the stream.");
async_mode |= AsyncModes.AsyncOutput;
output_canceled = false;
if (async_output == null) {
async_output = new ProcessAsyncReader (this, (FileStream) output_stream.BaseStream, true);
async_output.BeginReadLine ();
if (async_output == null)
async_output = new AsyncStreamReader (this, output_stream.BaseStream, new UserCallBack(this.OutputReadNotifyUser), output_stream.CurrentEncoding);
async_output.BeginReadLine ();
}
void OutputReadNotifyUser (String data)
{
// To avoid ---- between remove handler and raising the event
DataReceivedEventHandler outputDataReceived = OutputDataReceived;
if (outputDataReceived != null) {
if (SynchronizingObject != null && SynchronizingObject.InvokeRequired)
SynchronizingObject.Invoke (outputDataReceived, new object[] { this, new DataReceivedEventArgs (data) });
else
outputDataReceived (this, new DataReceivedEventArgs (data)); // Call back to user informing data is available.
}
}
@@ -1496,7 +1385,9 @@ namespace System.Diagnostics {
if (async_output == null)
throw new InvalidOperationException ("No async operation in progress.");
output_canceled = true;
async_output.CancelOperation ();
async_mode &= ~AsyncModes.AsyncOutput;
}
[ComVisibleAttribute(false)]
@@ -1508,11 +1399,26 @@ namespace System.Diagnostics {
if ((async_mode & AsyncModes.SyncError) != 0)
throw new InvalidOperationException ("Cannot mix asynchronous and synchonous reads.");
if ((async_mode & AsyncModes.AsyncError) != 0)
throw new InvalidOperationException ("An async read operation has already been started on the stream.");
async_mode |= AsyncModes.AsyncError;
error_canceled = false;
if (async_error == null) {
async_error = new ProcessAsyncReader (this, (FileStream) error_stream.BaseStream, false);
async_error.BeginReadLine ();
if (async_error == null)
async_error = new AsyncStreamReader (this, error_stream.BaseStream, new UserCallBack(this.ErrorReadNotifyUser), error_stream.CurrentEncoding);
async_error.BeginReadLine ();
}
void ErrorReadNotifyUser (String data)
{
// To avoid ---- between remove handler and raising the event
DataReceivedEventHandler errorDataReceived = ErrorDataReceived;
if (errorDataReceived != null) {
if (SynchronizingObject != null && SynchronizingObject.InvokeRequired)
SynchronizingObject.Invoke (errorDataReceived, new object[] { this, new DataReceivedEventArgs (data) });
else
errorDataReceived (this, new DataReceivedEventArgs (data)); // Call back to user informing data is available.
}
}
@@ -1528,7 +1434,9 @@ namespace System.Diagnostics {
if (async_error == null)
throw new InvalidOperationException ("No async operation in progress.");
error_canceled = true;
async_error.CancelOperation ();
async_mode &= ~AsyncModes.AsyncError;
}
#else
[Obsolete ("Process.BeginOutputReadLine is not supported on the current platform.", true)]
@@ -1588,11 +1496,8 @@ namespace System.Diagnostics {
// dispose all managed resources.
if (disposing) {
#if MONO_FEATURE_PROCESS_START
/* These have open FileStreams on the pipes we are about to close */
if (async_output != null)
async_output.Close ();
if (async_error != null)
async_error.Close ();
async_output = null;
async_error = null;
if (input_stream != null) {
if (!input_stream_exposed)
@@ -1667,16 +1572,26 @@ namespace System.Diagnostics {
void StartBackgroundWaitForExit ()
{
IntPtr handle = process_handle;
if (enable_raising_events == 0)
return;
if (exited_event == null)
return;
if (process_handle == IntPtr.Zero)
if (handle == IntPtr.Zero)
return;
if (background_wait_for_exit_thread != null)
return;
Thread t = new Thread (_ => WaitForExit ()) { IsBackground = true };
Thread t = new Thread (_ => {
if (!WaitForExit_internal (handle, -1))
return;
if (EnableRaisingEvents)
OnExited ();
});
t.IsBackground = true;
if (Interlocked.CompareExchange (ref background_wait_for_exit_thread, t, null) == null)
t.Start ();
+10 -2
View File
@@ -592,8 +592,16 @@ namespace System.Net.Mail {
// FIXME: parse the list of extensions so we don't bother wasting
// our time trying commands if they aren't supported.
// Get the FQDN of the local machine
string fqdn = Dns.GetHostEntry (Dns.GetHostName ()).HostName;
// get the host name (not fully qualified)
string fqdn = Dns.GetHostName ();
try {
// we'll try for the fully qualified name - ref: bug #33551
fqdn = Dns.GetHostEntry (fqdn).HostName;
}
catch (SocketException) {
// we could not resolve our name but will continue with the partial name
// IOW we won't fail to send email because of this - ref: bug #37246
}
status = SendCommand ("EHLO " + fqdn);
if (IsError (status)) {
@@ -397,7 +397,7 @@ namespace System.Net {
HttpListenerResponse response = context.Response;
response.StatusCode = status;
response.ContentType = "text/html";
string description = HttpListenerResponse.GetStatusDescription (status);
string description = HttpListenerResponseHelper.GetStatusDescription (status);
string str;
if (msg != null)
str = String.Format ("<h1>{0} ({1})</h1>", description, msg);
@@ -218,63 +218,10 @@ namespace System.Net {
if (value < 100 || value > 999)
throw new ProtocolViolationException ("StatusCode must be between 100 and 999.");
status_code = value;
status_description = GetStatusDescription (value);
status_description = HttpListenerResponseHelper.GetStatusDescription (value);
}
}
internal static string GetStatusDescription (int code)
{
switch (code){
case 100: return "Continue";
case 101: return "Switching Protocols";
case 102: return "Processing";
case 200: return "OK";
case 201: return "Created";
case 202: return "Accepted";
case 203: return "Non-Authoritative Information";
case 204: return "No Content";
case 205: return "Reset Content";
case 206: return "Partial Content";
case 207: return "Multi-Status";
case 300: return "Multiple Choices";
case 301: return "Moved Permanently";
case 302: return "Found";
case 303: return "See Other";
case 304: return "Not Modified";
case 305: return "Use Proxy";
case 307: return "Temporary Redirect";
case 400: return "Bad Request";
case 401: return "Unauthorized";
case 402: return "Payment Required";
case 403: return "Forbidden";
case 404: return "Not Found";
case 405: return "Method Not Allowed";
case 406: return "Not Acceptable";
case 407: return "Proxy Authentication Required";
case 408: return "Request Timeout";
case 409: return "Conflict";
case 410: return "Gone";
case 411: return "Length Required";
case 412: return "Precondition Failed";
case 413: return "Request Entity Too Large";
case 414: return "Request-Uri Too Long";
case 415: return "Unsupported Media Type";
case 416: return "Requested Range Not Satisfiable";
case 417: return "Expectation Failed";
case 422: return "Unprocessable Entity";
case 423: return "Locked";
case 424: return "Failed Dependency";
case 500: return "Internal Server Error";
case 501: return "Not Implemented";
case 502: return "Bad Gateway";
case 503: return "Service Unavailable";
case 504: return "Gateway Timeout";
case 505: return "Http Version Not Supported";
case 507: return "Insufficient Storage";
}
return "";
}
public string StatusDescription {
get { return status_description; }
set {
@@ -552,6 +499,64 @@ namespace System.Net {
cookies.Add (cookie);
}
}
// do not inline into HttpListenerResponse as this recursively brings everything that's
// reachable by IDisposable.Dispose (and that's quite a lot in this case).
static class HttpListenerResponseHelper {
internal static string GetStatusDescription (int code)
{
switch (code){
case 100: return "Continue";
case 101: return "Switching Protocols";
case 102: return "Processing";
case 200: return "OK";
case 201: return "Created";
case 202: return "Accepted";
case 203: return "Non-Authoritative Information";
case 204: return "No Content";
case 205: return "Reset Content";
case 206: return "Partial Content";
case 207: return "Multi-Status";
case 300: return "Multiple Choices";
case 301: return "Moved Permanently";
case 302: return "Found";
case 303: return "See Other";
case 304: return "Not Modified";
case 305: return "Use Proxy";
case 307: return "Temporary Redirect";
case 400: return "Bad Request";
case 401: return "Unauthorized";
case 402: return "Payment Required";
case 403: return "Forbidden";
case 404: return "Not Found";
case 405: return "Method Not Allowed";
case 406: return "Not Acceptable";
case 407: return "Proxy Authentication Required";
case 408: return "Request Timeout";
case 409: return "Conflict";
case 410: return "Gone";
case 411: return "Length Required";
case 412: return "Precondition Failed";
case 413: return "Request Entity Too Large";
case 414: return "Request-Uri Too Long";
case 415: return "Unsupported Media Type";
case 416: return "Requested Range Not Satisfiable";
case 417: return "Expectation Failed";
case 422: return "Unprocessable Entity";
case 423: return "Locked";
case 424: return "Failed Dependency";
case 500: return "Internal Server Error";
case 501: return "Not Implemented";
case 502: return "Bad Gateway";
case 503: return "Service Unavailable";
case 504: return "Gateway Timeout";
case 505: return "Http Version Not Supported";
case 507: return "Insufficient Storage";
}
return "";
}
}
}
#endif
+2 -1
View File
@@ -25,11 +25,12 @@
//
using System;
using System.Net;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Net
namespace Mono.Net
{
internal class CFObject : IDisposable
{
+8 -2
View File
@@ -415,12 +415,18 @@ namespace System.Net
internal void SetServerCertificate (X509Certificate server)
{
this.certificate = server;
var cloned = server != null ? new X509Certificate (server) : null;
var old = Interlocked.Exchange (ref certificate, cloned);
if (old != null)
old.Dispose ();
}
internal void SetClientCertificate (X509Certificate clientCertificate)
{
this.clientCertificate = clientCertificate;
var cloned = clientCertificate != null ? new X509Certificate (clientCertificate) : null;
var old = Interlocked.Exchange (ref clientCertificate, cloned);
if (old != null)
old.Dispose ();
}
internal bool CallEndPointDelegate (Socket sock, IPEndPoint remote)
+3 -3
View File
@@ -86,7 +86,7 @@ namespace System.Net
static object classLock = new object ();
MonoTlsStream tlsStream;
#if MONOTOUCH
#if MONOTOUCH && !MONOTOUCH_TV && !MONOTOUCH_WATCH
[System.Runtime.InteropServices.DllImport ("__Internal")]
static extern void xamarin_start_wwan (string uri);
#endif
@@ -152,7 +152,7 @@ namespace System.Net
IPHostEntry hostEntry = sPoint.HostEntry;
if (hostEntry == null) {
#if MONOTOUCH
#if MONOTOUCH && !MONOTOUCH_TV && !MONOTOUCH_WATCH
xamarin_start_wwan (sPoint.Address.ToString ());
hostEntry = sPoint.HostEntry;
if (hostEntry == null) {
@@ -160,7 +160,7 @@ namespace System.Net
status = sPoint.UsesProxy ? WebExceptionStatus.ProxyNameResolutionFailure :
WebExceptionStatus.NameResolutionFailure;
return;
#if MONOTOUCH
#if MONOTOUCH && !MONOTOUCH_TV && !MONOTOUCH_WATCH
}
#endif
}
@@ -41,6 +41,7 @@ using System.Net.Cache;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Mono.Net;
#if NET_2_1
using ConfigurationException = System.ArgumentException;
@@ -44,6 +44,7 @@ using MX = Mono.Security.X509;
using System.IO;
using System.Text;
using System.Collections;
namespace System.Security.Cryptography.X509Certificates {
@@ -557,12 +558,17 @@ namespace System.Security.Cryptography.X509Certificates {
{
var pfx = new MX.PKCS12 ();
try {
var attrs = new Hashtable ();
var localKeyId = new ArrayList ();
localKeyId.Add (new byte[] { 1, 0, 0, 0 });
attrs.Add (MX.PKCS9.localKeyId, localKeyId);
if (password != null)
pfx.Password = password;
pfx.AddCertificate (_cert);
pfx.AddCertificate (_cert, attrs);
var privateKey = PrivateKey;
if (privateKey != null)
pfx.AddPkcs8ShroudedKeyBag (privateKey);
pfx.AddPkcs8ShroudedKeyBag (privateKey, attrs);
return pfx.GetBytes ();
} finally {
pfx.Password = null;
+2
View File
@@ -1176,3 +1176,5 @@ ReferenceSources/_SslStream.cs
../../../external/referencesource/System/compmod/system/codedom/compiler/ICodeParser.cs
../../../external/referencesource/System/compmod/system/codedom/compiler/IndentTextWriter.cs
../../../external/referencesource/System/compmod/system/codedom/compiler/LanguageOptions.cs
../../../external/referencesource/System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs
+1 -1
View File
@@ -231,7 +231,6 @@ System.Net/ServicePointManagerTest.cs
System.Net/ServicePointTest.cs
System.Net/SocketPermissionAttributeTest.cs
System.Net/SocketPermissionTest.cs
System.Net/SocketResponder.cs
System.Net/WebHeaderCollectionTest.cs
System.Net/WebPermissionAttributeTest.cs
System.Net/WebPermissionTest.cs
@@ -510,3 +509,4 @@ System.Collections.Concurrent/CollectionStressTestHelper.cs
System.Collections.Concurrent/ParallelTestHelper.cs
System.Net.WebSockets/ClientWebSocketTest.cs
../../test-helpers/NetworkHelpers.cs
../../test-helpers/SocketResponder.cs
@@ -1018,5 +1018,47 @@ namespace MonoTests.System.Diagnostics
Assert.IsTrue (found, sb.ToString ());
}
}
#if MONO_FEATURE_PROCESS_START
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
[ExpectedException (typeof (InvalidOperationException))]
public void TestDoubleBeginOutputReadLine ()
{
using (Process p = new Process ()) {
p.StartInfo = GetCrossPlatformStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start ();
p.BeginOutputReadLine ();
p.BeginOutputReadLine ();
Assert.Fail ();
}
}
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
[ExpectedException (typeof (InvalidOperationException))]
public void TestDoubleBeginErrorReadLine ()
{
using (Process p = new Process ()) {
p.StartInfo = GetCrossPlatformStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start ();
p.BeginErrorReadLine ();
p.BeginErrorReadLine ();
Assert.Fail ();
}
}
#endif // MONO_FEATURE_PROCESS_START
}
}
@@ -3495,6 +3495,14 @@ namespace MonoTests.System.Net.Sockets
s.Close ();
}
#if MONOTOUCH
// when the linker is enabled then reflection won't work and would throw an NRE
// this is also always true for iOS - so we do not need to poke internals
static bool SupportsPortReuse ()
{
return true;
}
#else
static bool? supportsPortReuse;
static bool SupportsPortReuse ()
{
@@ -3506,6 +3514,7 @@ namespace MonoTests.System.Net.Sockets
.Invoke (null, new object [] {});
return supportsPortReuse.Value;
}
#endif
// Test case for bug #31557
[Test]
@@ -13,6 +13,8 @@ using System.Net;
using System.Net.Sockets;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.Net.Sockets
{
/// <summary>
@@ -76,9 +78,7 @@ namespace MonoTests.System.Net.Sockets
public void CloseTest ()
{
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8765);
using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (CloseRequestHandler))) {
sr.Start ();
using (SocketResponder sr = new SocketResponder (localEP, s => CloseRequestHandler (s))) {
TcpClient tcpClient = new TcpClient (IPAddress.Loopback.ToString (), 8765);
NetworkStream ns = tcpClient.GetStream ();
Assert.IsNotNull (ns, "#A1");
@@ -103,9 +103,7 @@ namespace MonoTests.System.Net.Sockets
*/
}
using (SocketResponder sr = new SocketResponder (localEP, new SocketRequestHandler (CloseRequestHandler))) {
sr.Start ();
using (SocketResponder sr = new SocketResponder (localEP, s => CloseRequestHandler (s))) {
TcpClient tcpClient = new TcpClient (IPAddress.Loopback.ToString (), 8765);
Assert.AreEqual (0, tcpClient.Available, "#B1");
Assert.IsTrue (tcpClient.Connected, "#B2");
@@ -100,9 +100,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -119,8 +117,6 @@ namespace MonoTests.System.Net
response.Close ();
rs.Close ();
responder.Stop ();
}
}
@@ -250,26 +246,24 @@ namespace MonoTests.System.Net
string url = "http://" + ep.ToString () + "/test/";
foreach (DictionaryEntry de in methods) {
SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler));
responder.Start ();
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = (string) de.Key;
req.Timeout = 2000;
req.ReadWriteTimeout = 2000;
req.KeepAlive = false;
Stream rs = req.GetRequestStream ();
rs.Close ();
using (HttpWebResponse resp = (HttpWebResponse) req.GetResponse ()) {
StreamReader sr = new StreamReader (resp.GetResponseStream (),
Encoding.UTF8);
string line = sr.ReadLine ();
sr.Close ();
Assert.AreEqual (((string) de.Value) + " /test/ HTTP/1.1",
line, req.Method);
resp.Close ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = (string) de.Key;
req.Timeout = 2000;
req.ReadWriteTimeout = 2000;
req.KeepAlive = false;
Stream rs = req.GetRequestStream ();
rs.Close ();
using (HttpWebResponse resp = (HttpWebResponse) req.GetResponse ()) {
StreamReader sr = new StreamReader (resp.GetResponseStream (),
Encoding.UTF8);
string line = sr.ReadLine ();
sr.Close ();
Assert.AreEqual (((string) de.Value) + " /test/ HTTP/1.1",
line, req.Method);
resp.Close ();
}
}
responder.Stop ();
}
}
@@ -279,9 +273,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest request;
request = (HttpWebRequest) WebRequest.Create (url);
@@ -318,9 +310,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req;
Stream rs;
IAsyncResult ar;
@@ -374,9 +364,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req;
req = (HttpWebRequest) WebRequest.Create (url);
@@ -471,9 +459,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Abort ();
@@ -498,9 +484,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Abort ();
@@ -525,9 +509,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.BeginGetRequestStream (null, null);
@@ -553,9 +535,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
IAsyncResult ar = req.BeginGetRequestStream (null, null);
@@ -583,9 +563,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -609,9 +587,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Timeout = 2000;
req.ReadWriteTimeout = 2000;
@@ -642,9 +618,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -666,9 +640,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Abort ();
@@ -694,9 +666,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req;
Stream rs;
@@ -763,9 +733,7 @@ namespace MonoTests.System.Net
string url = "http://" + ep.ToString () + "/test/";
// buffered, non-chunked
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req;
Stream rs;
byte [] buffer;
@@ -815,9 +783,7 @@ namespace MonoTests.System.Net
}
// buffered, chunked
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req;
Stream rs;
byte [] buffer;
@@ -853,9 +819,7 @@ namespace MonoTests.System.Net
}
// non-buffered, non-chunked
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req;
Stream rs;
byte [] buffer;
@@ -907,9 +871,7 @@ namespace MonoTests.System.Net
}
// non-buffered, chunked
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req;
Stream rs;
byte [] buffer;
@@ -973,9 +935,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Abort ();
@@ -1001,9 +961,7 @@ namespace MonoTests.System.Net
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8764);
string url = "http://" + localEP.ToString () + "/original/";
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (RedirectRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => RedirectRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.AllowAutoRedirect = false;
@@ -1024,7 +982,6 @@ namespace MonoTests.System.Net
Assert.AreEqual (WebExceptionStatus.Timeout, ex.Status, "#5");
}
}
responder.Stop ();
}
}
@@ -1035,9 +992,7 @@ namespace MonoTests.System.Net
string url = "http://" + localEP.ToString () + "/original/";
// allow autoredirect
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (RedirectRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => RedirectRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -1056,13 +1011,10 @@ namespace MonoTests.System.Net
Assert.AreEqual ("GET", resp.Method, "#A3");
Assert.AreEqual ("LOOKS OK", body, "#A4");
}
responder.Stop ();
}
// do not allow autoredirect
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (RedirectRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => RedirectRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.AllowAutoRedirect = false;
@@ -1076,7 +1028,6 @@ namespace MonoTests.System.Net
Assert.AreEqual (url, resp.ResponseUri.ToString (), "#B2");
Assert.AreEqual ("POST", resp.Method, "#B3");
}
responder.Stop ();
}
}
@@ -1086,9 +1037,7 @@ namespace MonoTests.System.Net
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8769);
string url = "http://" + localEP.ToString () + "/original/";
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (RedirectRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => RedirectRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -1107,7 +1056,6 @@ namespace MonoTests.System.Net
Assert.AreEqual ("GET", resp.Method, "#A3");
Assert.AreEqual ("LOOKS OK", body, "#A4");
}
responder.Stop ();
}
}
@@ -1117,9 +1065,7 @@ namespace MonoTests.System.Net
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8770);
string url = "http://" + localEP.ToString () + "/original/";
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (RedirectRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => RedirectRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -1138,7 +1084,6 @@ namespace MonoTests.System.Net
Assert.AreEqual ("GET", resp.Method, "#A3");
Assert.AreEqual ("LOOKS OK", body, "#A4");
}
responder.Stop ();
}
}
@@ -1148,9 +1093,7 @@ namespace MonoTests.System.Net
IPEndPoint localEP = new IPEndPoint (IPAddress.Loopback, 8771);
string url = "http://" + localEP.ToString () + "/original/";
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (RedirectRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => RedirectRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -1169,7 +1112,6 @@ namespace MonoTests.System.Net
Assert.AreEqual ("GET", resp.Method, "#A3");
Assert.AreEqual ("LOOKS OK", body, "#A4");
}
responder.Stop ();
}
}
@@ -1181,9 +1123,7 @@ namespace MonoTests.System.Net
string url = "http://" + localEP.ToString () + "/original/";
// POST
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (InternalErrorHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => InternalErrorHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -1206,14 +1146,10 @@ namespace MonoTests.System.Net
Assert.AreEqual ("POST", webResponse.Method, "#A7");
webResponse.Close ();
}
responder.Stop ();
}
// GET
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (InternalErrorHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => InternalErrorHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -1233,8 +1169,6 @@ namespace MonoTests.System.Net
Assert.AreEqual ("GET", webResponse.Method, "#B6");
webResponse.Close ();
}
responder.Stop ();
}
}
@@ -1246,9 +1180,7 @@ namespace MonoTests.System.Net
string url = "http://" + localEP.ToString () + "/original/";
// POST
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (NoContentLengthHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => NoContentLengthHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
req.Timeout = 2000;
@@ -1288,14 +1220,10 @@ namespace MonoTests.System.Net
HttpWebResponse webResponse = ex.Response as HttpWebResponse;
Assert.IsNull (webResponse, "#A11");
}
responder.Stop ();
}
// GET
using (SocketResponder responder = new SocketResponder (localEP, new SocketRequestHandler (NoContentLengthHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (localEP, s => NoContentLengthHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -1317,8 +1245,6 @@ namespace MonoTests.System.Net
Assert.AreEqual ("GET", webResponse.Method, "#B6");
webResponse.Close ();
}
responder.Stop ();
}
}
@@ -1328,9 +1254,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/moved/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (VerbEchoHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => VerbEchoHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "WhatEver";
req.KeepAlive = false;
@@ -1351,8 +1275,6 @@ namespace MonoTests.System.Net
Assert.AreEqual ("WhatEver", resp.Method, "#3");
Assert.AreEqual ("WhatEver", body, "#4");
}
responder.Stop ();
}
}
@@ -1363,9 +1285,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (NotModifiedSinceHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => NotModifiedSinceHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.KeepAlive = false;
@@ -1393,8 +1313,6 @@ namespace MonoTests.System.Net
TimeSpan elapsed = DateTime.Now - start;
Assert.IsTrue (elapsed.TotalMilliseconds < 2000, "#4");
responder.Stop ();
}
}
@@ -1504,11 +1422,7 @@ namespace MonoTests.System.Net
using (var responder = new SocketResponder (ep, TimeOutHandler))
{
responder.Start ();
TestTimeOut (url, WebExceptionStatus.Timeout);
responder.Stop ();
}
}
@@ -2771,9 +2685,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString ();
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (CookieRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => CookieRequestHandler (s))) {
CookieContainer container = new CookieContainer ();
container.Add(new Uri (url), new Cookie ("foo", "bar"));
HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
@@ -2790,9 +2702,7 @@ namespace MonoTests.System.Net
Assert.AreEqual ("foo=bar", response.Headers.Get("Set-Cookie"), "#02");
}
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (CookieRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => CookieRequestHandler (s))) {
CookieContainer container = new CookieContainer ();
HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
request.CookieContainer = container;
@@ -2859,9 +2769,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -2889,9 +2797,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -2918,9 +2824,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -2942,9 +2846,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -2966,9 +2868,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -2990,9 +2890,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3014,9 +2912,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3043,9 +2939,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3071,9 +2965,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3095,9 +2987,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3123,9 +3013,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3151,9 +3039,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3181,9 +3067,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3211,9 +3095,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3241,9 +3123,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3271,9 +3151,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3301,9 +3179,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3330,9 +3206,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -3359,9 +3233,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebRequestTest.EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebRequestTest.EchoRequestHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "POST";
@@ -29,9 +29,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -59,9 +57,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -80,9 +76,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -110,9 +104,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -132,9 +124,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -162,9 +152,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -202,9 +190,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -232,9 +218,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -262,9 +246,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -291,9 +273,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -321,9 +301,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -351,9 +329,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -381,9 +357,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -411,9 +385,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -441,9 +413,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -463,9 +433,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -516,9 +484,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -567,9 +533,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -602,9 +566,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -631,9 +593,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -660,9 +620,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -689,9 +647,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -718,9 +674,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -757,9 +711,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -808,9 +760,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -860,9 +810,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -912,9 +860,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -964,9 +910,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -1017,9 +961,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req;
req = (HttpWebRequest) WebRequest.Create (url);
@@ -1082,9 +1024,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -1111,9 +1051,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -1145,9 +1083,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (HttpWebResponseTest.FullResponseHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => HttpWebResponseTest.FullResponseHandler (s))) {
HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url);
req.Method = "GET";
req.Timeout = 2000;
@@ -1423,9 +1423,7 @@ namespace MonoTests.System.Net
IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString () + "/test/";
using (SocketResponder responder = new SocketResponder (ep, new SocketRequestHandler (EchoRequestHandler))) {
responder.Start ();
using (SocketResponder responder = new SocketResponder (ep, s => EchoRequestHandler (s))) {
WebClient wc = new WebClient ();
wc.Encoding = Encoding.ASCII;
@@ -1880,10 +1878,8 @@ namespace MonoTests.System.Net
var ep = NetworkHelpers.LocalEphemeralEndPoint ();
string url = "http://" + ep.ToString() + "/test/";
using (var responder = new SocketResponder (ep, EchoRequestHandler))
using (var responder = new SocketResponder (ep, s => EchoRequestHandler (s)))
{
responder.Start ();
var webClient = new WebClient ();
var cancellationTokenSource = new CancellationTokenSource ();
@@ -881,3 +881,5 @@ ReferenceSources/Win32Exception.cs
../Mono.Security/Mono.Security.Interface/TlsException.cs
../Mono.Security/Mono.Security.Interface/TlsProtocolCode.cs
../Mono.Security/Mono.Security.Interface/TlsProtocols.cs
../../../external/referencesource/System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs
+16 -1
View File
@@ -82,5 +82,20 @@ using System.Runtime.InteropServices;
#endif
[assembly: InternalsVisibleTo ("System.Numerics, PublicKey=00000000000000000400000000000000")]
[assembly: Guid ("BED7F4EA-1A96-11D2-8F08-00A0C9A6186D")]
#if MONOTOUCH
#if MONOTOUCH_TV
[assembly: InternalsVisibleTo ("Xamarin.TVOS, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#elif MONOTOUCH_WATCH
[assembly: InternalsVisibleTo ("Xamarin.WatchOS, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#else
[assembly: InternalsVisibleTo ("monotouch, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo ("Xamarin.iOS, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#endif
#endif
#if XAMMAC || XAMMAC_4_5
[assembly: InternalsVisibleTo ("XamMac, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo ("Xamarin.Mac, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#endif
[assembly: Guid ("BED7F4EA-1A96-11D2-8F08-00A0C9A6186D")]
@@ -33,10 +33,8 @@ namespace System {
[System.Security.SecurityCritical]
[ResourceExposure(ResourceScope.None)]
[SuppressUnmanagedCodeSecurity]
internal static bool CheckThrowUnobservedTaskExceptions()
{
return false;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern internal static bool CheckThrowUnobservedTaskExceptions();
} // internal class CLRConfig
+1 -1
View File
@@ -60,7 +60,7 @@ namespace System
private object m_target;
private IntPtr method;
private IntPtr delegate_trampoline;
private IntPtr rgctx;
private IntPtr extra_arg;
private IntPtr method_code;
private MethodInfo method_info;
+1 -1
View File
@@ -375,7 +375,7 @@ namespace System {
/// </summary>
public static Version Version {
get {
return new Version (Consts.FxFileVersion);
return new Version (Consts.EnvironmentVersion);
}
}
+8 -5
View File
@@ -327,8 +327,13 @@ namespace System
private static bool TryAddTicks (DateTime date, long ticks, out DateTime result, DateTimeKind kind = DateTimeKind.Unspecified)
{
var resultTicks = date.Ticks + ticks;
if (resultTicks < DateTime.MinValue.Ticks || resultTicks > DateTime.MaxValue.Ticks) {
result = default (DateTime);
if (resultTicks < DateTime.MinValue.Ticks) {
result = DateTime.SpecifyKind (DateTime.MinValue, kind);
return false;
}
if (resultTicks > DateTime.MaxValue.Ticks) {
result = DateTime.SpecifyKind (DateTime.MaxValue, kind);
return false;
}
@@ -475,9 +480,7 @@ namespace System
var utcOffset = sourceTimeZone.GetUtcOffset (dateTime, out isDst);
DateTime utcDateTime;
if (!TryAddTicks (dateTime, -utcOffset.Ticks, out utcDateTime, DateTimeKind.Utc))
return DateTime.SpecifyKind (DateTime.MinValue, DateTimeKind.Utc);
TryAddTicks (dateTime, -utcOffset.Ticks, out utcDateTime, DateTimeKind.Utc);
return utcDateTime;
}
@@ -1660,6 +1660,25 @@ namespace MonoTests.System.IO
}
[Test]
public void OpenCharDeviceRepeatedly ()
{
// https://bugzilla.xamarin.com/show_bug.cgi?id=38408
try {
using (var f = new FileStream ("/dev/zero", FileMode.Open))
{
}
} catch (FileNotFoundException) {
// Only run this test on platforms where /dev/zero exists
Assert.Ignore();
}
// this shouldn't throw
using (var g = new FileStream ("/dev/zero", FileMode.Open))
{
}
}
#if !MOBILE
[Test]
public void WriteWithExposedHandle ()
@@ -65,9 +65,11 @@ namespace MonoTests.System.Threading
{
int called = 0;
var cts = new CancellationTokenSource ();
cts.Token.Register (() => called++);
var mre = new ManualResetEvent(false);
cts.Token.Register (() => { called++; mre.Set (); });
cts.CancelAfter (20);
Thread.Sleep (50);
Assert.IsTrue(mre.WaitOne (1000), "Should be cancelled in ~20ms");
Assert.AreEqual (1, called, "#1");
}
@@ -193,6 +193,9 @@ namespace MonoTests.System.Threading
}
[Test]
#if MONOTOUCH
[Category ("NotWorking")] // https://bugzilla.xamarin.com/show_bug.cgi?id=34617
#endif
public void DisposeOnThreadExit ()
{
var threadLocal = new ThreadLocal<SetMreOnFinalize>();
@@ -29,7 +29,7 @@ namespace MonoTests.System.Threading {
// this makes fair for the "DueTime" test since it
// doesn't have to wait for the scheduler thread to be
// created.
new Timer (new TimerCallback (DoNothing), null, Timeout.Infinite, 0);
new Timer (o => DoNothing (o), null, Timeout.Infinite, 0);
}
void DoNothing (object foo)
@@ -40,32 +40,34 @@ namespace MonoTests.System.Threading {
public void TestDueTime ()
{
Bucket bucket = new Bucket();
Timer t = new Timer (new TimerCallback (Callback), bucket, 200, Timeout.Infinite);
Thread.Sleep (50);
Assert.AreEqual (0, bucket.count, "#1");
Thread.Sleep (200);
Assert.AreEqual (1, bucket.count, "#2");
Thread.Sleep (500);
Assert.AreEqual (1, bucket.count, "#3");
t.Change (10, 10);
Thread.Sleep (1000);
Assert.IsTrue(bucket.count > 20, "#4");
t.Dispose ();
using (Timer t = new Timer (o => Callback (o), bucket, 200, Timeout.Infinite)) {
Thread.Sleep (50);
Assert.AreEqual (0, bucket.count, "#1");
Thread.Sleep (200);
Assert.AreEqual (1, bucket.count, "#2");
Thread.Sleep (500);
Assert.AreEqual (1, bucket.count, "#3");
t.Change (10, 10);
Thread.Sleep (1000);
Assert.IsTrue(bucket.count > 20, "#4");
}
}
[Test]
public void TestChange ()
{
Bucket bucket = new Bucket();
Timer t = new Timer (new TimerCallback (Callback), bucket, 10, 10);
Thread.Sleep (500);
int c = bucket.count;
Assert.IsTrue (c > 20, "#1 " + c.ToString ());
t.Change (100, 100);
c = bucket.count;
Thread.Sleep (500);
Assert.IsTrue (bucket.count <= c + 20, "#2 " + c.ToString ());
t.Dispose ();
using (Timer t = new Timer (o => Callback (o), bucket, 10, 10)) {
Thread.Sleep (500);
int c = bucket.count;
Assert.IsTrue (c > 20, "#1 " + c.ToString ());
t.Change (100, 100);
c = bucket.count;
Thread.Sleep (500);
Assert.IsTrue (bucket.count <= c + 20, "#2 " + c.ToString ());
}
}
[Test]
@@ -73,22 +75,24 @@ namespace MonoTests.System.Threading {
{
Bucket bucket = new Bucket();
Timer t = new Timer (new TimerCallback (Callback), bucket, 0, Timeout.Infinite);
Thread.Sleep (100);
Assert.AreEqual (1, bucket.count, "#1");
t.Change (0, Timeout.Infinite);
Thread.Sleep (100);
Assert.AreEqual (2, bucket.count, "#2");
t.Dispose ();
using (Timer t = new Timer (o => Callback (o), bucket, 0, Timeout.Infinite)) {
Thread.Sleep (100);
Assert.AreEqual (1, bucket.count, "#1");
t.Change (0, Timeout.Infinite);
Thread.Sleep (100);
Assert.AreEqual (2, bucket.count, "#2");
}
}
[Test]
public void TestDispose ()
{
Bucket bucket = new Bucket();
Timer t = new Timer (new TimerCallback (Callback), bucket, 10, 10);
Thread.Sleep (200);
t.Dispose ();
using (Timer t = new Timer (o => Callback (o), bucket, 10, 10)) {
Thread.Sleep (200);
}
Thread.Sleep (20);
int c = bucket.count;
Assert.IsTrue (bucket.count > 5, "#1");
@@ -99,7 +103,7 @@ namespace MonoTests.System.Threading {
[Test] // bug #320950
public void TestDispose2 ()
{
Timer t = new Timer (new TimerCallback (Callback), null, 10, 10);
Timer t = new Timer (o => Callback (o), null, 10, 10);
t.Dispose ();
t.Dispose ();
}
@@ -108,9 +112,10 @@ namespace MonoTests.System.Threading {
public void TestHeavyCreationLoad ()
{
Bucket b = new Bucket ();
for (int i = 0; i < 500; ++i)
new Timer (new TimerCallback (Callback), b, 10,
Timeout.Infinite);
new Timer (o => Callback (o), b, 10, Timeout.Infinite);
// 1000 * 10 msec = 10,000 msec or 10 sec - if everything goes well
// we add some slack to cope with timing issues caused by system load etc.
for (int i = 0; i < 20; ++i) {
@@ -118,23 +123,22 @@ namespace MonoTests.System.Threading {
break;
Thread.Sleep (1000);
}
Assert.AreEqual (500, b.count);
}
[Test]
public void TestQuickDisposeDeadlockBug ()
{
int i = 0;
Bucket b = new Bucket ();
ArrayList timers = new ArrayList();
while (i < 500) {
Timer t = new Timer (new TimerCallback (Callback),
b, 10, Timeout.Infinite);
timers.Add (t);
i++;
t.Dispose ();
ArrayList timers = new ArrayList (500);
for (int i = 0; i < 500; ++i) {
using (Timer t = new Timer (o => Callback (o), b, 10, Timeout.Infinite)) {
timers.Add (t);
}
}
Thread.Sleep (11 * 500);
}
@@ -142,46 +146,41 @@ namespace MonoTests.System.Threading {
public void TestInt32MaxDelay ()
{
Bucket b = new Bucket ();
new Timer (new TimerCallback (Callback), b, Int32.MaxValue,
Timeout.Infinite);
Thread.Sleep (50);
Assert.AreEqual (0, b.count);
using (new Timer (o => Callback (o), b, Int32.MaxValue, Timeout.Infinite)) {
Thread.Sleep (50);
Assert.AreEqual (0, b.count);
}
}
[Test]
public void TestInt32MaxPeriod ()
{
Bucket b = new Bucket ();
new Timer (new TimerCallback (Callback), b, 0,
Int32.MaxValue);
Thread.Sleep (50);
Assert.AreEqual (1, b.count);
}
[Test]
public void TestNegativeDelay ()
{
Bucket b = new Bucket ();
try {
new Timer (new TimerCallback (Callback), b, -10,
Timeout.Infinite);
Assert.Fail ();
} catch (ArgumentOutOfRangeException) {
return;
using (new Timer (o => Callback (o), b, 0, Int32.MaxValue)) {
Thread.Sleep (50);
Assert.AreEqual (1, b.count);
}
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestNegativeDelay ()
{
Bucket b = new Bucket ();
using (new Timer (o => Callback (o), b, -10, Timeout.Infinite)) {
}
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestNegativePeriod ()
{
Bucket b = new Bucket ();
try {
new Timer (new TimerCallback (Callback), b, 0,
-10);
Assert.Fail ();
} catch (ArgumentOutOfRangeException) {
return;
using (new Timer (o => Callback (o), b, 0, -10)) {
}
}
@@ -189,11 +188,13 @@ namespace MonoTests.System.Threading {
public void TestDelayZeroPeriodZero()
{
Bucket b = new Bucket();
Timer t = new Timer(new TimerCallback(Callback),b,0,0);
Thread.Sleep(100);
t.Change (int.MaxValue, Timeout.Infinite);
// since period is 0 the callback should happen once (bug #340212)
Assert.AreEqual (1, b.count, "only once");
using (Timer t = new Timer(o => Callback (o),b,0,0)) {
Thread.Sleep(100);
t.Change (int.MaxValue, Timeout.Infinite);
// since period is 0 the callback should happen once (bug #340212)
Assert.AreEqual (1, b.count, "only once");
}
}
[Test]
@@ -204,7 +205,7 @@ namespace MonoTests.System.Threading {
// that was ignored before 238785a3e3d510528228fc551625975bc508c2f3 and most unit test runner won't
// report it since the NRE will not happen on the main thread (but Touch.Unit will)
Timer t1 = null;
t1 = new Timer (new TimerCallback (CallbackTestDisposeOnCallback), t1, 0, 10);
t1 = new Timer (o => CallbackTestDisposeOnCallback (o), t1, 0, 10);
Thread.Sleep (200);
Assert.IsNotNull (t1);
@@ -225,7 +226,7 @@ namespace MonoTests.System.Threading {
[ExpectedException (typeof (ArgumentNullException))]
public void DisposeNullWaitHandle ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Dispose (null);
}
}
@@ -233,7 +234,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_IntInt_Infinite ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change ((int)Timeout.Infinite, (int)Timeout.Infinite);
}
}
@@ -241,7 +242,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_IntInt_MaxValue ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change (Int32.MaxValue, Int32.MaxValue);
}
}
@@ -249,7 +250,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_UIntUInt_Infinite ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change (unchecked ((uint) Timeout.Infinite), unchecked ((uint) Timeout.Infinite));
}
}
@@ -257,7 +258,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_UIntUInt_MaxValue ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
// UInt32.MaxValue == Timeout.Infinite == 0xffffffff
t.Change (UInt32.MaxValue, UInt32.MaxValue);
}
@@ -266,7 +267,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_LongLong_Infinite ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change ((long) Timeout.Infinite, (long) Timeout.Infinite);
}
}
@@ -275,7 +276,7 @@ namespace MonoTests.System.Threading {
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void Change_LongLong_MaxValue ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change (Int64.MaxValue, Int64.MaxValue);
}
}
@@ -284,7 +285,7 @@ namespace MonoTests.System.Threading {
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void Change_LongLong_UInt32MaxValue ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
// not identical to (long)-1
t.Change ((long)UInt32.MaxValue, (long)UInt32.MaxValue);
}
@@ -293,7 +294,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_LongLong_UInt32MaxValueMinusOne ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
// not identical to (long)-1
t.Change ((long) UInt32.MaxValue - 1, (long) UInt32.MaxValue -1);
}
@@ -302,7 +303,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_TimeSpanTimeSpan_Infinite ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change (new TimeSpan (-1), new TimeSpan (-1));
}
}
@@ -311,7 +312,7 @@ namespace MonoTests.System.Threading {
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void Change_TimeSpanTimeSpan_MaxValue ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change (TimeSpan.MaxValue, TimeSpan.MaxValue);
}
}
@@ -319,7 +320,7 @@ namespace MonoTests.System.Threading {
[Test]
public void Change_TimeSpanTimeSpan_UInt32MaxValue ()
{
using (Timer t = new Timer (DoNothing, null, 0, 0)) {
using (Timer t = new Timer (o => DoNothing (o), null, 0, 0)) {
t.Change (new TimeSpan (UInt32.MaxValue), new TimeSpan (UInt32.MaxValue));
}
}
@@ -2644,5 +2644,28 @@ namespace MonoTests.System
Assert.AreEqual (2, res.Year, "#1");
Assert.AreEqual (12, res.Month, "#2");
}
[Test]
[Culture ("en-us")]
public void ToUniversalTime_TimeZoneOffsetShouldNotOverflow ()
{
var m = DateTime.MaxValue;
var res = m.ToUniversalTime ();
// It does not matter which time zone but we should never overflow or have DateTime.MinValue
Assert.AreEqual (9999, res.Year, "#1");
Assert.AreEqual (12, res.Month, "#2");
Assert.AreEqual (31, res.Day, "#3");
Assert.AreEqual (DateTimeKind.Utc, res.Kind, "#4");
m = DateTime.MinValue;
res = m.ToUniversalTime ();
// It does not matter which time zone but we should never overflow or have DateTime.MinValue
Assert.AreEqual (0, res.Year, "#10");
Assert.AreEqual (1, res.Month, "#11");
Assert.AreEqual (1, res.Day, "#12");
Assert.AreEqual (DateTimeKind.Utc, res.Kind, "#13");
}
}
}
+18 -8
View File
@@ -4,16 +4,26 @@ include ../../build/rules.make
all-local:
PROFILE_DIR=$(DESTDIR)$(mono_libdir)/mono/
PROFILE_DIR=$(DESTDIR)$(mono_libdir)/mono
install-local:
$(MKINSTALLDIRS) $(PROFILE_DIR)/2.0
$(MKINSTALLDIRS) $(PROFILE_DIR)/3.5
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.0
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v2.0/* $(PROFILE_DIR)/2.0
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v3.5/* $(PROFILE_DIR)/3.5
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.0/* $(PROFILE_DIR)/4.0
$(MKINSTALLDIRS) $(PROFILE_DIR)/2.0-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/3.5-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.0-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.5-api
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.5-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
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.0/*.dll $(PROFILE_DIR)/4.0-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5/*.dll $(PROFILE_DIR)/4.5-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5/Facades/*.dll $(PROFILE_DIR)/4.5-api/Facades
DISTFILES = $(wildcard ../../../external/binary-reference-assemblies/v4.0/*) $(wildcard ../../../external/binary-reference-assemblies/v3.5/*) $(wildcard ../../../external/binary-reference-assemblies/v2.0/*) Makefile
# Unfortunately, a few programs (most notably NUnit) have hardcoded checks for <prefix>/lib/mono/4.0/mscorlib.dll,
# so we need to place something there or those tools break. We decided to symlink to the reference assembly for now.
# See https://bugzilla.xamarin.com/show_bug.cgi?id=38331
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.0
ln -sf ../4.0-api/mscorlib.dll $(PROFILE_DIR)/4.0/mscorlib.dll
DISTFILES = $(wildcard ../../../external/binary-reference-assemblies/v4.5/Facades/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v4.5/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v4.0/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v3.5/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v2.0/*.dll) Makefile
dist-local: dist-default
@@ -32,98 +32,64 @@ using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MonoTests.System.Net
namespace MonoTests.Helpers
{
public delegate byte [] SocketRequestHandler (Socket socket);
public class SocketResponderException : Exception
{
public SocketResponderException (string message)
: base (message)
{
}
}
public class SocketResponder : IDisposable
{
private TcpListener tcpListener;
private readonly IPEndPoint _localEndPoint;
private Thread listenThread;
private Task listenTask;
private Socket listenSocket;
private SocketRequestHandler _requestHandler;
private int _state = 0;
private readonly object _syncRoot = new object ();
private SocketRequestHandler requestHandler;
private bool disposed;
private const int SOCKET_CLOSED = 10004;
private const int SOCKET_INVALID_ARGS = 10022;
private const int STATE_UNINITIALIZED = 0;
private const int STATE_RUNNING = 1;
private const int STATE_STOPPED = 2;
public SocketResponder (IPEndPoint localEP, SocketRequestHandler requestHandler)
public SocketResponder (IPEndPoint ep, SocketRequestHandler rh)
{
_localEndPoint = localEP;
_requestHandler = requestHandler;
}
requestHandler = rh;
public IPEndPoint LocalEndPoint
{
get { return _localEndPoint; }
tcpListener = new TcpListener (ep);
tcpListener.Start ();
listenTask = Task.Run (Listen);
}
public void Dispose ()
{
Stop ();
}
if (disposed)
return;
public bool IsStopped
{
get
{
lock (_syncRoot) {
return _state != STATE_RUNNING;
}
}
}
disposed = true;
public void Start ()
{
lock (_syncRoot) {
if (_state != STATE_UNINITIALIZED)
throw new InvalidOperationException ("cannot restart SocketResponder");
_state = STATE_RUNNING;
tcpListener = new TcpListener (LocalEndPoint);
tcpListener.Start ();
listenThread = new Thread (new ThreadStart (Listen));
listenThread.Start ();
}
}
tcpListener.Stop ();
public void Stop ()
{
lock (_syncRoot) {
if (_state != STATE_RUNNING)
return;
_state = STATE_STOPPED;
if (tcpListener != null) {
tcpListener.Stop ();
tcpListener = null;
if (listenSocket != null)
listenSocket.Close ();
#if MONO_FEATURE_THREAD_ABORT
listenThread.Abort ();
#else
listenThread.Interrupt ();
#endif
listenThread.Join ();
listenThread = null;
Thread.Sleep (50);
}
}
if (listenSocket != null)
listenSocket.Close ();
if (!listenTask.Wait (5000))
throw new SocketResponderException ("Failed to stop in less than 5 seconds");
}
private void Listen ()
{
while (_state == STATE_RUNNING) {
while (!disposed) {
listenSocket = null;
try {
listenSocket = tcpListener.AcceptSocket ();
listenSocket.Send (_requestHandler (listenSocket));
listenSocket.Send (requestHandler (listenSocket));
try {
listenSocket.Shutdown (SocketShutdown.Receive);
listenSocket.Shutdown (SocketShutdown.Send);
@@ -131,16 +97,11 @@ namespace MonoTests.System.Net
}
} catch (SocketException ex) {
// ignore interruption of blocking call
if (ex.ErrorCode != SOCKET_CLOSED && ex.ErrorCode != SOCKET_INVALID_ARGS && _state != STATE_STOPPED)
if (ex.ErrorCode != SOCKET_CLOSED && ex.ErrorCode != SOCKET_INVALID_ARGS && !disposed)
throw;
} catch (ObjectDisposedException ex) {
Console.WriteLine (ex);
if (_state != STATE_STOPPED)
if (!disposed)
throw;
#if !MONO_FEATURE_THREAD_ABORT
} catch (ThreadInterruptedException) {
break;
#endif
#if MOBILE
} catch (InvalidOperationException ex) {
// This breaks some tests running on Android. The problem is that the stack trace
@@ -150,15 +111,6 @@ namespace MonoTests.System.Net
Console.WriteLine (ex);
#endif
} finally {
#if MONO_FEATURE_THREAD_ABORT
Thread.Sleep (500);
#else
try {
Thread.Sleep (500);
} catch (ThreadInterruptedException) {
// nothing to do
}
#endif
if (listenSocket != null)
listenSocket.Close ();
}
+141 -6
View File
@@ -13,6 +13,11 @@ using System;
using System.Linq;
using SLE = System.Linq.Expressions;
using System.Dynamic;
#if STATIC
using IKVM.Reflection.Emit;
#else
using System.Reflection.Emit;
#endif
namespace Mono.CSharp
{
@@ -314,6 +319,50 @@ namespace Mono.CSharp
EmitCall (ec, binder_expr, arguments, true);
}
protected void EmitConditionalAccess (EmitContext ec)
{
var a_expr = arguments [0].Expr;
var des = a_expr as DynamicExpressionStatement;
if (des != null) {
des.EmitConditionalAccess (ec);
}
if (HasConditionalAccess ()) {
var NullOperatorLabel = ec.DefineLabel ();
if (ExpressionAnalyzer.IsInexpensiveLoad (a_expr)) {
a_expr.Emit (ec);
} else {
var lt = new LocalTemporary (a_expr.Type);
lt.EmitAssign (ec, a_expr, true, false);
Arguments [0].Expr = lt;
}
ec.Emit (OpCodes.Brtrue_S, NullOperatorLabel);
if (!ec.ConditionalAccess.Statement) {
if (ec.ConditionalAccess.Type.IsNullableType)
Nullable.LiftedNull.Create (ec.ConditionalAccess.Type, Location.Null).Emit (ec);
else
ec.EmitNull ();
}
ec.Emit (OpCodes.Br, ec.ConditionalAccess.EndLabel);
ec.MarkLabel (NullOperatorLabel);
return;
}
if (a_expr.HasConditionalAccess ()) {
var lt = new LocalTemporary (a_expr.Type);
lt.EmitAssign (ec, a_expr, false, false);
Arguments [0].Expr = lt;
}
}
protected void EmitCall (EmitContext ec, Expression binder, Arguments arguments, bool isStatement)
{
//
@@ -502,6 +551,24 @@ namespace Mono.CSharp
StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args)));
using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
var conditionalAccessReceiver = IsConditionalAccessReceiver;
var ca = ec.ConditionalAccess;
if (conditionalAccessReceiver) {
ec.ConditionalAccess = new ConditionalAccessContext (type, ec.DefineLabel ()) {
Statement = isStatement
};
//
// Emit conditional access expressions before dynamic call
// is initialized. It pushes site_field_expr on stack before
// the actual instance argument is emited which would cause
// jump from non-empty stack.
//
EmitConditionalAccess (ec);
}
if (s.Resolve (bc)) {
Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc);
init.Emit (ec);
@@ -526,9 +593,15 @@ namespace Mono.CSharp
}
}
Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, false, loc).Resolve (bc);
if (target != null)
var target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, false, loc).Resolve (bc);
if (target != null) {
target.Emit (ec);
}
if (conditionalAccessReceiver) {
ec.CloseConditionalAccess (!isStatement && type.IsNullableType ? type : null);
ec.ConditionalAccess = ca;
}
}
}
@@ -547,6 +620,12 @@ namespace Mono.CSharp
{
return new MemberAccess (new TypeExpression (binder_type, loc), name, loc);
}
protected virtual bool IsConditionalAccessReceiver {
get {
return false;
}
}
}
//
@@ -671,14 +750,18 @@ namespace Mono.CSharp
class DynamicIndexBinder : DynamicMemberAssignable
{
bool can_be_mutator;
readonly bool conditional_access_receiver;
readonly bool conditional_access;
public DynamicIndexBinder (Arguments args, Location loc)
public DynamicIndexBinder (Arguments args, bool conditionalAccessReceiver, bool conditionalAccess, Location loc)
: base (args, loc)
{
this.conditional_access_receiver = conditionalAccessReceiver;
this.conditional_access = conditionalAccess;
}
public DynamicIndexBinder (CSharpBinderFlags flags, Arguments args, Location loc)
: this (args, loc)
: this (args, false, false, loc)
{
base.flags = flags;
}
@@ -732,22 +815,35 @@ namespace Mono.CSharp
setter_args.Add (new Argument (rhs));
return setter_args;
}
protected override bool IsConditionalAccessReceiver {
get {
return conditional_access_receiver;
}
}
public override bool HasConditionalAccess ()
{
return conditional_access;
}
}
class DynamicInvocation : DynamicExpressionStatement, IDynamicBinder
{
readonly ATypeNameExpression member;
readonly bool conditional_access_receiver;
public DynamicInvocation (ATypeNameExpression member, Arguments args, Location loc)
public DynamicInvocation (ATypeNameExpression member, Arguments args, bool conditionalAccessReceiver, Location loc)
: base (null, args, loc)
{
base.binder = this;
this.member = member;
this.conditional_access_receiver = conditionalAccessReceiver;
}
public static DynamicInvocation CreateSpecialNameInvoke (ATypeNameExpression member, Arguments args, Location loc)
{
return new DynamicInvocation (member, args, loc) {
return new DynamicInvocation (member, args, false, loc) {
flags = CSharpBinderFlags.InvokeSpecialName
};
}
@@ -805,11 +901,36 @@ namespace Mono.CSharp
flags |= CSharpBinderFlags.ResultDiscarded;
base.EmitStatement (ec);
}
protected override bool IsConditionalAccessReceiver {
get {
return conditional_access_receiver;
}
}
public override bool HasConditionalAccess ()
{
return member is ConditionalMemberAccess;
}
}
class DynamicConditionalMemberBinder : DynamicMemberBinder
{
public DynamicConditionalMemberBinder (string name, Arguments args, Location loc)
: base (name, args, loc)
{
}
public override bool HasConditionalAccess ()
{
return true;
}
}
class DynamicMemberBinder : DynamicMemberAssignable
{
readonly string name;
bool conditionalAccessReceiver;
public DynamicMemberBinder (string name, Arguments args, Location loc)
: base (args, loc)
@@ -835,6 +956,20 @@ namespace Mono.CSharp
isSet |= (flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0;
return new Invocation (GetBinder (isSet ? "SetMember" : "GetMember", loc), binder_args);
}
protected override Expression DoResolve (ResolveContext rc)
{
if (!rc.HasSet (ResolveContext.Options.DontSetConditionalAccessReceiver))
conditionalAccessReceiver = HasConditionalAccess () || Arguments [0].Expr.HasConditionalAccess ();
return base.DoResolve (rc);
}
protected override bool IsConditionalAccessReceiver {
get {
return conditionalAccessReceiver;
}
}
}
//
Loaded 100 of 211 files, more files were not shown because too many files have changed in this diff. Show more