Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build bgen and the product assemblies using/referencing netcore3.1. #8070

Merged
merged 29 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0500cd8
[src] Create bgen subdirectory and move the bgen script there.
rolfbjarne Feb 25, 2020
eef4ea7
[builds] Download the netcore 3.1 assemblies to use as reference asse…
rolfbjarne Mar 5, 2020
5135ce2
[bgen] Build bgen as a .netcoreapp 3.1.
rolfbjarne Feb 27, 2020
d242066
Add .NET 5 target frameworks.
rolfbjarne Feb 27, 2020
d659a86
[bgen] Don't try to load assemblies we've already loaded.
rolfbjarne Feb 27, 2020
72626bd
[src] Hide API usage that doesn't compile (but which we'll have to re…
rolfbjarne Feb 27, 2020
11fb1fd
[src] Adjust to .NET 5 API.
rolfbjarne Feb 27, 2020
4648db4
[src] Build platform assemblies referencing the .NET5 BCL.
rolfbjarne Feb 27, 2020
9b65dd5
[bgen] Don't yield the old-style location for product assemblies when…
rolfbjarne Mar 5, 2020
342e60c
[bgen] Don't fix references when in .NET mode.
rolfbjarne Mar 5, 2020
36db0dd
[bgen] .NET 5 has System.Drawing.dll, no need to skip it.
rolfbjarne Mar 5, 2020
2fa6989
[bgen] Intercept IKVM's assembly resolution to find assemblies oursel…
rolfbjarne Mar 5, 2020
7a1a8bb
[bgen] Add netcore version of the generator tests.
rolfbjarne Mar 6, 2020
1fc2f8e
[xharness] Add support for running the generator tests in .NET mode.
rolfbjarne Mar 9, 2020
0c10206
[System.Net.Http] Add issue about CFNetworkHandler .NET todo.
rolfbjarne Mar 10, 2020
398989a
[Compression] Obsolete [Begin|End][Read|Write] in .NET.
rolfbjarne Mar 10, 2020
7bef994
Revert whitespace change.
rolfbjarne Mar 10, 2020
d7d9bae
Use full path to the 'dotnet' executable.
rolfbjarne Mar 10, 2020
5c323ce
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne Mar 10, 2020
187a5d7
[bgen] Don't handle resources quite yet in the .NET version of bgen.
rolfbjarne Mar 10, 2020
7108f59
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne Mar 10, 2020
2f2c8c3
[src] Reduce the list of referenced netcore assemblies.
rolfbjarne Mar 11, 2020
1acba86
[Compression] Copy the TaskToApm implementation to provide a backward…
rolfbjarne Mar 11, 2020
53b54fa
[src] Define NET[_TODO] instead of DOTNET[_TODO].
rolfbjarne Mar 11, 2020
dac68f3
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne Mar 11, 2020
067c88e
[xharness] Fix merge problem.
rolfbjarne Mar 11, 2020
f56fe80
Bump system mono to fix a csc compilation problem.
rolfbjarne Mar 12, 2020
5dda97a
[xharness] Unset a few environment variables when running .NET tests.
rolfbjarne Mar 12, 2020
800d63b
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne Mar 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ endif

DOTNET_VERSION=3.1.100
DOTNET_URL=https://download.visualstudio.microsoft.com/download/pr/787e81f1-f0da-4e3b-a989-8a199132ed8c/61a8dba81fbf2b3d533562d7b96443ec/dotnet-sdk-3.1.100-osx-x64.pkg
DOTNET=/usr/local/share/dotnet/dotnet
DOTNET_BCL_REF_URL=https://www.nuget.org/api/v2/package/Microsoft.NETCore.App.Ref/3.1.0
DOTNET_BCL_REF_NAME=microsoft.netcore.app.ref.3.1.0.nupkg
DOTNET_BCL_DIR:=$(abspath $(TOP)/builds/downloads/$(basename $(DOTNET_BCL_REF_NAME)))/ref/netcoreapp3.1

.SUFFIXES:
MAKEFLAGS += --no-builtin-rules
24 changes: 23 additions & 1 deletion builds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ download-mono: downloads/$(basename $(MONO_IOS_FILENAME)) downloads/$(basename $

downloads/$(basename $(MONO_IOS_FILENAME)): MONO_URL=$(MONO_IOS_URL)
downloads/$(basename $(MONO_MAC_FILENAME)): MONO_URL=$(MONO_MAC_URL)
downloads/$(DOTNET_BCL_REF_NAME): MONO_URL=$(DOTNET_BCL_REF_URL)

include $(TOP)/mk/colors.mk

DOWNLOADS = \
downloads/$(MONO_IOS_FILENAME) \
downloads/$(MONO_MAC_FILENAME) \
downloads/$(DOTNET_BCL_REF_NAME) \

# This target downloads the mono archives, there's one for Xamarin.iOS and one for Xamarin.Mac.
# If doing many clean builds, it's possible to copy the downloaded zip file to ~/Library/Caches/xamarin-macios
# to avoid having to download it every time. The zip files have to be copied manually, otherwise
# we'd end up filling up a lot of hard drives around the world.
downloads/$(MONO_IOS_FILENAME) downloads/$(MONO_MAC_FILENAME):
$(DOWNLOADS):
$(Q) mkdir -p downloads
$(Q) echo "Downloading $(MONO_URL)..."
$(Q) if test -f ~/Library/Caches/xamarin-macios/$(notdir $@); then \
Expand All @@ -49,9 +55,25 @@ downloads/%: downloads/%.7z
$(Q) mv [email protected] $@
$(Q) echo "Unzipped $*."

downloads/%: downloads/%.nupkg
$(Q) echo "Unzipping $*..."
$(Q) rm -Rf [email protected]
$(Q) unzip -d [email protected] $<
$(Q) find [email protected] -exec touch {} +
$(Q) mv [email protected] $@
$(Q) echo "Unzipped $*."

.stamp-download-mono: download-mono $(TOP)/Make.config $(TOP)/mk/mono.mk
$(Q) touch $@

DOTNET_DOWNLOADS = \
downloads/$(basename $(DOTNET_BCL_REF_NAME)) \

dotnet: $(DOTNET_DOWNLOADS)
ifdef ENABLE_DOTNET
all-local:: $(DOTNET_DOWNLOADS)
endif

clean-local::
$(Q) rm -Rf downloads .stamp-download-mono

Expand Down
3 changes: 3 additions & 0 deletions mk/quiet.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Q_XBUILD=$(if $(V),,@echo "XBUILD $(@F)";)
Q_TT= $(if $(V),,@echo "TT $(@F)";)
Q_BUILD=$(if $(V),,@echo "BUILD $(@F)";)

Q_DOTNET_BUILD=$(if $(V),,@echo "CSC [dotnet] $(@F)";)
Q_DOTNET_GEN =$(if $(V),,@echo "GEN [dotnet] $(@F)";)

Q_PROF_MCS = $(if $(V),,@echo "MCS [$(1)] $(@F)";)
Q_PROF_CSC = $(if $(V),,@echo "CSC [$(1)] $(@F)";)
Q_PROF_GEN = $(if $(V),,@echo "GEN [$(1)] $(@F)";)
Expand Down
2 changes: 1 addition & 1 deletion src/CFNetwork/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal Content (WebResponseStream stream)
this.responseStream = stream;
}

#if MONOMAC && XAMCORE_2_0
#if (MONOMAC && XAMCORE_2_0) && !NET
internal
#endif
protected override bool TryComputeLength (out long length)
Expand Down
2 changes: 1 addition & 1 deletion src/CFNetwork/MessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public WorkerThread WorkerThread {
CFHTTPAuthentication auth;

#region implemented abstract members of HttpMessageHandler
#if MONOMAC && XAMCORE_2_0
#if (MONOMAC && XAMCORE_2_0) && !NET
internal
#endif
protected override async Task<HttpResponseMessage> SendAsync (HttpRequestMessage request,
Expand Down
129 changes: 129 additions & 0 deletions src/Compression/TaskToApm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

// Helper methods for using Tasks to implement the APM pattern.
//
// Example usage, wrapping a Task<int>-returning FooAsync method with Begin/EndFoo methods:
//
// public IAsyncResult BeginFoo(..., AsyncCallback callback, object state) =>
// TaskToApm.Begin(FooAsync(...), callback, state);
//
// public int EndFoo(IAsyncResult asyncResult) =>
// TaskToApm.End<int>(asyncResult);

//
// Xamarin:
// This is a copy of this file: https://github.com/dotnet/runtime/blob/25d316cefafc4c3884f38acf7bdef971d2b9fe4b/src/libraries/Common/src/System/Threading/Tasks/TaskToApm.cs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this file is a copy of a file from elsewhere, it does not follow our style guidelines. This is expected.

// We need it to be backwards compatible in .NET 5 for the implementations of Compression.[Begin|End]|[Read|Write].
//

#if NET
#nullable enable
using System.Diagnostics;

namespace System.Threading.Tasks
{
/// <summary>
/// Provides support for efficiently using Tasks to implement the APM (Begin/End) pattern.
/// </summary>
internal static class TaskToApm
{
/// <summary>
/// Marshals the Task as an IAsyncResult, using the supplied callback and state
/// to implement the APM pattern.
/// </summary>
/// <param name="task">The Task to be marshaled.</param>
/// <param name="callback">The callback to be invoked upon completion.</param>
/// <param name="state">The state to be stored in the IAsyncResult.</param>
/// <returns>An IAsyncResult to represent the task's asynchronous operation.</returns>
public static IAsyncResult Begin(Task task, AsyncCallback? callback, object? state) =>
new TaskAsyncResult(task, state, callback);

/// <summary>Processes an IAsyncResult returned by Begin.</summary>
/// <param name="asyncResult">The IAsyncResult to unwrap.</param>
public static void End(IAsyncResult asyncResult)
{
if (asyncResult is TaskAsyncResult twar)
{
twar._task.GetAwaiter().GetResult();
return;
}

throw new ArgumentNullException();
}

/// <summary>Processes an IAsyncResult returned by Begin.</summary>
/// <param name="asyncResult">The IAsyncResult to unwrap.</param>
public static TResult End<TResult>(IAsyncResult asyncResult)
{
if (asyncResult is TaskAsyncResult twar && twar._task is Task<TResult> task)
{
return task.GetAwaiter().GetResult();
}

throw new ArgumentNullException();
}

/// <summary>Provides a simple IAsyncResult that wraps a Task.</summary>
/// <remarks>
/// We could use the Task as the IAsyncResult if the Task's AsyncState is the same as the object state,
/// but that's very rare, in particular in a situation where someone cares about allocation, and always
/// using TaskAsyncResult simplifies things and enables additional optimizations.
/// </remarks>
internal sealed class TaskAsyncResult : IAsyncResult
{
/// <summary>The wrapped Task.</summary>
internal readonly Task _task;
/// <summary>Callback to invoke when the wrapped task completes.</summary>
private readonly AsyncCallback? _callback;

/// <summary>Initializes the IAsyncResult with the Task to wrap and the associated object state.</summary>
/// <param name="task">The Task to wrap.</param>
/// <param name="state">The new AsyncState value.</param>
/// <param name="callback">Callback to invoke when the wrapped task completes.</param>
internal TaskAsyncResult(Task task, object? state, AsyncCallback? callback)
{
Debug.Assert(task != null);
_task = task;
AsyncState = state;

if (task.IsCompleted)
{
// Synchronous completion. Invoke the callback. No need to store it.
CompletedSynchronously = true;
callback?.Invoke(this);
}
else if (callback != null)
{
// Asynchronous completion, and we have a callback; schedule it. We use OnCompleted rather than ContinueWith in
// order to avoid running synchronously if the task has already completed by the time we get here but still run
// synchronously as part of the task's completion if the task completes after (the more common case).
_callback = callback;
_task.ConfigureAwait(continueOnCapturedContext: false)
.GetAwaiter()
.OnCompleted(InvokeCallback); // allocates a delegate, but avoids a closure
}
}

/// <summary>Invokes the callback.</summary>
private void InvokeCallback()
{
Debug.Assert(!CompletedSynchronously);
Debug.Assert(_callback != null);
_callback.Invoke(this);
}

/// <summary>Gets a user-defined object that qualifies or contains information about an asynchronous operation.</summary>
public object? AsyncState { get; }
/// <summary>Gets a value that indicates whether the asynchronous operation completed synchronously.</summary>
/// <remarks>This is set lazily based on whether the <see cref="_task"/> has completed by the time this object is created.</remarks>
public bool CompletedSynchronously { get; }
/// <summary>Gets a value that indicates whether the asynchronous operation has completed.</summary>
public bool IsCompleted => _task.IsCompleted;
/// <summary>Gets a <see cref="WaitHandle"/> that is used to wait for an asynchronous operation to complete.</summary>
public WaitHandle AsyncWaitHandle => ((IAsyncResult)_task).AsyncWaitHandle;
}
}
}
#endif
7 changes: 5 additions & 2 deletions src/Foundation/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ async Task<NSUrlRequest> CreateRequest (HttpRequestMessage request)
return nsrequest;
}

#if SYSTEM_NET_HTTP || MONOMAC
#if (SYSTEM_NET_HTTP || MONOMAC) && !NET
internal
#endif
protected override async Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
Expand Down Expand Up @@ -935,7 +935,10 @@ protected override Task SerializeToStreamAsync (Stream stream, TransportContext
return content.CopyToAsync (stream, bufferSize, cancellationToken);
}

protected internal override bool TryComputeLength (out long length)
#if !NET
internal
#endif
protected override bool TryComputeLength (out long length)
{
if (!content.CanSeek) {
length = 0;
Expand Down
Loading