-
Notifications
You must be signed in to change notification settings - Fork 518
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
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 eef4ea7
[builds] Download the netcore 3.1 assemblies to use as reference asse…
rolfbjarne 5135ce2
[bgen] Build bgen as a .netcoreapp 3.1.
rolfbjarne d242066
Add .NET 5 target frameworks.
rolfbjarne d659a86
[bgen] Don't try to load assemblies we've already loaded.
rolfbjarne 72626bd
[src] Hide API usage that doesn't compile (but which we'll have to re…
rolfbjarne 11fb1fd
[src] Adjust to .NET 5 API.
rolfbjarne 4648db4
[src] Build platform assemblies referencing the .NET5 BCL.
rolfbjarne 9b65dd5
[bgen] Don't yield the old-style location for product assemblies when…
rolfbjarne 342e60c
[bgen] Don't fix references when in .NET mode.
rolfbjarne 36db0dd
[bgen] .NET 5 has System.Drawing.dll, no need to skip it.
rolfbjarne 2fa6989
[bgen] Intercept IKVM's assembly resolution to find assemblies oursel…
rolfbjarne 7a1a8bb
[bgen] Add netcore version of the generator tests.
rolfbjarne 1fc2f8e
[xharness] Add support for running the generator tests in .NET mode.
rolfbjarne 0c10206
[System.Net.Http] Add issue about CFNetworkHandler .NET todo.
rolfbjarne 398989a
[Compression] Obsolete [Begin|End][Read|Write] in .NET.
rolfbjarne 7bef994
Revert whitespace change.
rolfbjarne d7d9bae
Use full path to the 'dotnet' executable.
rolfbjarne 5c323ce
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne 187a5d7
[bgen] Don't handle resources quite yet in the .NET version of bgen.
rolfbjarne 7108f59
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne 2f2c8c3
[src] Reduce the list of referenced netcore assemblies.
rolfbjarne 1acba86
[Compression] Copy the TaskToApm implementation to provide a backward…
rolfbjarne 53b54fa
[src] Define NET[_TODO] instead of DOTNET[_TODO].
rolfbjarne dac68f3
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne 067c88e
[xharness] Fix merge problem.
rolfbjarne f56fe80
Bump system mono to fix a csc compilation problem.
rolfbjarne 5dda97a
[xharness] Unset a few environment variables when running .NET tests.
rolfbjarne 800d63b
Merge remote-tracking branch 'origin/master' into dotnet-bgen
rolfbjarne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 \ | ||
|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.