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

First task to create a nuget package and remove sources from mono/mono #288

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
122 changes: 11 additions & 111 deletions Mono.Debugger.Soft/Mono.Debugger.Soft.csproj
Original file line number Diff line number Diff line change
@@ -1,132 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Mono.Debugger.Soft</RootNamespace>
<AssemblyName>Mono.Debugger.Soft</AssemblyName>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>mono.snk</AssemblyOriginatorKeyFile>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DefineConstants>MONO_DATACONVERTER_STATIC_METHODS;ENABLE_CECIL</DefineConstants>
<ConsolePause>False</ConsolePause>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>MONO_DATACONVERTER_STATIC_METHODS;ENABLE_CECIL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<DefineConstants>MONO_DATACONVERTER_STATIC_METHODS;ENABLE_CECIL</DefineConstants>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<NuGetVersionCecil Condition="$(NuGetVersionCecil) == ''">0.10.0-beta5</NuGetVersionCecil>
</PropertyGroup>
<Import Project="..\Mono.Debugging.settings" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="Mono.Debugger.Soft\AbsentInformationException.cs" />
<Compile Include="Mono.Debugger.Soft\AppDomainCreateEvent.cs" />
<Compile Include="Mono.Debugger.Soft\AppDomainMirror.cs" />
<Compile Include="Mono.Debugger.Soft\AppDomainUnloadEvent.cs" />
<Compile Include="Mono.Debugger.Soft\ArrayMirror.cs" />
<Compile Include="Mono.Debugger.Soft\AssemblyLoadEvent.cs" />
<Compile Include="Mono.Debugger.Soft\AssemblyMirror.cs" />
<Compile Include="Mono.Debugger.Soft\AssemblyUnloadEvent.cs" />
<Compile Include="Mono.Debugger.Soft\BreakpointEvent.cs" />
<Compile Include="Mono.Debugger.Soft\BreakpointEventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\Connection.cs" />
<Compile Include="Mono.Debugger.Soft\CustomAttributeDataMirror.cs" />
<Compile Include="Mono.Debugger.Soft\CustomAttributeNamedArgumentMirror.cs" />
<Compile Include="Mono.Debugger.Soft\CustomAttributeTypedArgumentMirror.cs" />
<Compile Include="Mono.Debugger.Soft\DataConverter.cs" />
<Compile Include="Mono.Debugger.Soft\EnumMirror.cs" />
<Compile Include="Mono.Debugger.Soft\Event.cs" />
<Compile Include="Mono.Debugger.Soft\EventQueueImpl.cs" />
<Compile Include="Mono.Debugger.Soft\EventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\EventSet.cs" />
<Compile Include="Mono.Debugger.Soft\EventType.cs" />
<Compile Include="Mono.Debugger.Soft\ExceptionEvent.cs" />
<Compile Include="Mono.Debugger.Soft\ExceptionEventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\FieldInfoMirror.cs" />
<Compile Include="Mono.Debugger.Soft\IInvokeAsyncResult.cs" />
<Compile Include="Mono.Debugger.Soft\ILExceptionHandler.cs" />
<Compile Include="Mono.Debugger.Soft\ILInstruction.cs" />
<Compile Include="Mono.Debugger.Soft\ILInterpreter.cs" />
<Compile Include="Mono.Debugger.Soft\IMirror.cs" />
<Compile Include="Mono.Debugger.Soft\InterfaceMappingMirror.cs" />
<Compile Include="Mono.Debugger.Soft\InvalidStackFrameException.cs" />
<Compile Include="Mono.Debugger.Soft\InvocationException.cs" />
<Compile Include="Mono.Debugger.Soft\InvokeOptions.cs" />
<Compile Include="Mono.Debugger.Soft\ITargetProcess.cs" />
<Compile Include="Mono.Debugger.Soft\LocalVariable.cs" />
<Compile Include="Mono.Debugger.Soft\Location.cs" />
<Compile Include="Mono.Debugger.Soft\MethodBodyMirror.cs" />
<Compile Include="Mono.Debugger.Soft\MethodEntryEvent.cs" />
<Compile Include="Mono.Debugger.Soft\MethodEntryEventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\MethodExitEvent.cs" />
<Compile Include="Mono.Debugger.Soft\MethodExitEventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\MethodMirror.cs" />
<Compile Include="Mono.Debugger.Soft\Mirror.cs" />
<Compile Include="Mono.Debugger.Soft\ModuleMirror.cs" />
<Compile Include="Mono.Debugger.Soft\ObjectCollectedException.cs" />
<Compile Include="Mono.Debugger.Soft\ObjectMirror.cs" />
<Compile Include="Mono.Debugger.Soft\ParameterInfoMirror.cs" />
<Compile Include="Mono.Debugger.Soft\PrimitiveValue.cs" />
<Compile Include="Mono.Debugger.Soft\PropertyInfoMirror.cs" />
<Compile Include="Mono.Debugger.Soft\StackFrame.cs" />
<Compile Include="Mono.Debugger.Soft\StepEvent.cs" />
<Compile Include="Mono.Debugger.Soft\StepEventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\StringMirror.cs" />
<Compile Include="Mono.Debugger.Soft\StructMirror.cs" />
<Compile Include="Mono.Debugger.Soft\SuspendPolicy.cs" />
<Compile Include="Mono.Debugger.Soft\ThreadDeathEvent.cs" />
<Compile Include="Mono.Debugger.Soft\ThreadMirror.cs" />
<Compile Include="Mono.Debugger.Soft\ThreadStartEvent.cs" />
<Compile Include="Mono.Debugger.Soft\TypeLoadEvent.cs" />
<Compile Include="Mono.Debugger.Soft\TypeLoadEventRequest.cs" />
<Compile Include="Mono.Debugger.Soft\TypeMirror.cs" />
<Compile Include="Mono.Debugger.Soft\UserBreakEvent.cs" />
<Compile Include="Mono.Debugger.Soft\UserLogEvent.cs" />
<Compile Include="Mono.Debugger.Soft\Value.cs" />
<Compile Include="Mono.Debugger.Soft\VirtualMachine.cs" />
<Compile Include="Mono.Debugger.Soft\VirtualMachineManager.cs" />
<Compile Include="Mono.Debugger.Soft\VMDeathEvent.cs" />
<Compile Include="Mono.Debugger.Soft\VMDisconnectedException.cs" />
<Compile Include="Mono.Debugger.Soft\VMDisconnectEvent.cs" />
<Compile Include="Mono.Debugger.Soft\VMMismatchException.cs" />
<Compile Include="Mono.Debugger.Soft\VMStartEvent.cs" />
<Compile Include="Mono.Debugger.Soft\AssemblyLoadEventRequest.cs" />
<Compile Include="Locale.cs" />
<Compile Include="Mono.Debugger.Soft\PointerValue.cs" />
<Compile Include="Mono.Debugger.Soft\LocalScope.cs" />
<Compile Include="Mono.Debugger.Soft\DelayedLambdaValue.cs" />
<Compile Include="Mono.Debugger.Soft\DelayedLambdaType.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.am" />
<None Include="mono-git-revision" />
</ItemGroup>
<PropertyGroup>
<NuGetVersionCecil Condition="$(NuGetVersionCecil) == ''">0.10.1</NuGetVersionCecil>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="$(NuGetVersionCecil)" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Core" />
<Reference Include="System" />
<PackageReference Include="Mono.Cecil" Version="$(NuGetVersionCecil)" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
</ItemGroup>
</Project>
</Project>
3 changes: 2 additions & 1 deletion Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;

namespace Mono.Debugger.Soft
{
Expand Down Expand Up @@ -1597,7 +1598,7 @@ int Send (CommandSet command_set, int command, PacketWriter packet, Action<Packe
LogPacket (packet_id, encoded_packet, p, command_set, command, watch);
/* Run the callback on a tp thread to avoid blocking the receive thread */
PacketReader r = new PacketReader (this, p);
cb.BeginInvoke (r, null, null);
Task.Run (() => cb (r));
};
reply_cb_counts [id] = count;
}
Expand Down
1 change: 0 additions & 1 deletion Mono.Debugger.Soft/Mono.Debugger.Soft/ObjectMirror.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
using System.Threading;
using System.Threading.Tasks;

Expand Down
71 changes: 35 additions & 36 deletions Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace Mono.Debugger.Soft
{
Expand Down Expand Up @@ -69,12 +69,12 @@ public static VirtualMachine LaunchInternal (ITargetProcess p, ProcessStartInfo
return vm;
}

public static IAsyncResult BeginLaunch (ProcessStartInfo info, AsyncCallback callback)
public static Task<VirtualMachine> BeginLaunch (ProcessStartInfo info, Action<Task<VirtualMachine>> callback)
{
return BeginLaunch (info, callback, null);
}

public static IAsyncResult BeginLaunch (ProcessStartInfo info, AsyncCallback callback, LaunchOptions options)
public static Task<VirtualMachine> BeginLaunch (ProcessStartInfo info, Action<Task<VirtualMachine>> callback, LaunchOptions options)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we ok with API breakages?

{
if (info == null)
throw new ArgumentNullException ("info");
Expand Down Expand Up @@ -111,20 +111,19 @@ public static IAsyncResult BeginLaunch (ProcessStartInfo info, AsyncCallback cal
socket.Close ();
};

LaunchCallback c = new LaunchCallback (LaunchInternal);
return c.BeginInvoke (p, info, socket, callback, socket);
Task<VirtualMachine> t3 = Task<VirtualMachine>.Run (() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing a Task.Run here does not mirror previous functionality. Maybe simplify it to:

return LaunchInternal (p, info, socket)
    .ContinueWith (antecendent => callback (antecendent));

return LaunchInternal (p, info, socket);
});
t3.ContinueWith ((antecendent => callback (antecendent)));
return t3;
}

public static VirtualMachine EndLaunch (IAsyncResult asyncResult) {
public static VirtualMachine EndLaunch (Task<VirtualMachine> asyncResult) {
if (asyncResult == null)
throw new ArgumentNullException ("asyncResult");

if (!asyncResult.IsCompleted)
asyncResult.AsyncWaitHandle.WaitOne ();

AsyncResult result = (AsyncResult) asyncResult;
LaunchCallback cb = (LaunchCallback) result.AsyncDelegate;
return cb.EndInvoke (asyncResult);
asyncResult.Wait ();
Copy link
Contributor

Choose a reason for hiding this comment

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

.Wait() is not needed if we're doing .Result.

One other remark is that we probably don't want to force a .Result here. Maybe we need a public static Task<VirtualMachine> Launch()?

return asyncResult.Result;
}

public static VirtualMachine Launch (ProcessStartInfo info)
Expand Down Expand Up @@ -193,17 +192,17 @@ public static VirtualMachine ListenInternal (Socket dbg_sock, Socket con_sock) {
return Connect (transport, console, null);
}

public static IAsyncResult BeginListen (IPEndPoint dbg_ep, AsyncCallback callback) {
public static Task<VirtualMachine> BeginListen (IPEndPoint dbg_ep, Action<Task<VirtualMachine>> callback) {
return BeginListen (dbg_ep, null, callback);
}

public static IAsyncResult BeginListen (IPEndPoint dbg_ep, IPEndPoint con_ep, AsyncCallback callback)
public static Task<VirtualMachine> BeginListen (IPEndPoint dbg_ep, IPEndPoint con_ep, Action<Task<VirtualMachine>> callback)
{
int dbg_port, con_port;
return BeginListen (dbg_ep, con_ep, callback, out dbg_port, out con_port);
}

public static IAsyncResult BeginListen (IPEndPoint dbg_ep, IPEndPoint con_ep, AsyncCallback callback,
public static Task<VirtualMachine> BeginListen (IPEndPoint dbg_ep, IPEndPoint con_ep, Action<Task<VirtualMachine>> callback,
out int dbg_port, out int con_port)
{
dbg_port = con_port = 0;
Expand All @@ -222,21 +221,22 @@ public static IAsyncResult BeginListen (IPEndPoint dbg_ep, IPEndPoint con_ep, As
con_sock.Listen (1000);
con_port = ((IPEndPoint) con_sock.LocalEndPoint).Port;
}

ListenCallback c = new ListenCallback (ListenInternal);
return c.BeginInvoke (dbg_sock, con_sock, callback, con_sock ?? dbg_sock);

Task<VirtualMachine> t = Task<VirtualMachine>.Run (() => {
Copy link
Contributor

@Therzok Therzok Jan 31, 2020

Choose a reason for hiding this comment

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

Same as above:

return ListenInternal (dbg_sock, conn_sock)
    .ContinueWith (antecendent => callback (antecendent));

return ListenInternal (dbg_sock, con_sock);
});
t.ContinueWith ((antecendent => callback (antecendent)));
return t;
}

public static VirtualMachine EndListen (IAsyncResult asyncResult) {
public static VirtualMachine EndListen (Task<VirtualMachine> asyncResult) {
if (asyncResult == null)
throw new ArgumentNullException ("asyncResult");

if (!asyncResult.IsCompleted)
asyncResult.AsyncWaitHandle.WaitOne ();
asyncResult.Wait ();


AsyncResult result = (AsyncResult) asyncResult;
ListenCallback cb = (ListenCallback) result.AsyncDelegate;
return cb.EndInvoke (asyncResult);
return asyncResult.Result;
}

public static VirtualMachine Listen (IPEndPoint dbg_ep)
Expand Down Expand Up @@ -292,11 +292,11 @@ public static VirtualMachine ConnectInternal (Socket dbg_sock, Socket con_sock,
return Connect (transport, console, null);
}

public static IAsyncResult BeginConnect (IPEndPoint dbg_ep, AsyncCallback callback) {
public static Task<VirtualMachine> BeginConnect (IPEndPoint dbg_ep, Action<Task<VirtualMachine>> callback) {
return BeginConnect (dbg_ep, null, callback);
}

public static IAsyncResult BeginConnect (IPEndPoint dbg_ep, IPEndPoint con_ep, AsyncCallback callback) {
public static Task<VirtualMachine> BeginConnect (IPEndPoint dbg_ep, IPEndPoint con_ep, Action<Task<VirtualMachine>> callback) {
Socket dbg_sock = null;
Socket con_sock = null;

Expand All @@ -305,21 +305,20 @@ public static IAsyncResult BeginConnect (IPEndPoint dbg_ep, IPEndPoint con_ep, A
if (con_ep != null) {
con_sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}

ConnectCallback c = new ConnectCallback (ConnectInternal);
return c.BeginInvoke (dbg_sock, con_sock, dbg_ep, con_ep, callback, con_sock ?? dbg_sock);

Task<VirtualMachine> t3 = Task<VirtualMachine>.Run (() => {
return ConnectInternal (dbg_sock, con_sock, dbg_ep, con_ep);
});
t3.ContinueWith((antecendent => callback (antecendent)));
return t3;
}

public static VirtualMachine EndConnect (IAsyncResult asyncResult) {
public static VirtualMachine EndConnect (Task<VirtualMachine> asyncResult) {
if (asyncResult == null)
throw new ArgumentNullException ("asyncResult");

if (!asyncResult.IsCompleted)
asyncResult.AsyncWaitHandle.WaitOne ();

AsyncResult result = (AsyncResult) asyncResult;
ConnectCallback cb = (ConnectCallback) result.AsyncDelegate;
return cb.EndInvoke (asyncResult);
asyncResult.Wait ();
return asyncResult.Result;
}

public static void CancelConnection (IAsyncResult asyncResult)
Expand Down
Loading