~ruther/NosSmooth.Comms

edcd26a2f21092371c9169ae56ae85c144a8bfd7 — Rutherther 2 years ago a2b40dc main 2023.6
feat: move to new injection supporting passing in data and returning integer
M src/Core/NosSmooth.Comms.Abstractions/NosSmooth.Comms.Abstractions.csproj => src/Core/NosSmooth.Comms.Abstractions/NosSmooth.Comms.Abstractions.csproj +3 -3
@@ 5,13 5,13 @@
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <RootNamespace>NosSmooth.Comms.Data</RootNamespace>
        <VersionPrefix>1.3.0</VersionPrefix>
        <PackageReleaseNotes>Add result to handshake response.</PackageReleaseNotes>
        <VersionPrefix>1.4.0</VersionPrefix>
        <PackageReleaseNotes>Update dependencies.</PackageReleaseNotes>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
      <PackageReference Include="NosSmooth.Core" Version="4.0.3" />
      <PackageReference Include="NosSmooth.Core" Version="5.0.0" />
      <PackageReference Include="NosSmooth.Packets" Version="3.6.0" />
      <PackageReference Include="NosSmooth.PacketSerializer.Abstractions" Version="1.3.2" />
    </ItemGroup>

M src/Core/NosSmooth.Comms.Core/NosSmooth.Comms.Core.csproj => src/Core/NosSmooth.Comms.Core/NosSmooth.Comms.Core.csproj +3 -2
@@ 4,13 4,14 @@
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <VersionPrefix>1.1.1</VersionPrefix>
        <VersionPrefix>1.2.0</VersionPrefix>
        <PackageReleaseNotes>Update dependencies.</PackageReleaseNotes>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="MessagePack" Version="2.4.59" />
      <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
      <PackageReference Include="NosSmooth.Core" Version="4.0.3" />
      <PackageReference Include="NosSmooth.Core" Version="5.0.0" />
      <PackageReference Include="NosSmooth.PacketSerializer.Abstractions" Version="1.3.2" />
    </ItemGroup>


M src/Local/NosSmooth.Comms.Inject/DllMain.cs => src/Local/NosSmooth.Comms.Inject/DllMain.cs +34 -19
@@ 34,10 34,11 @@ public class DllMain
    /// <summary>
    /// Enable named pipes server.
    /// </summary>
    /// <param name="data">Should be zero, is not used.</param>
    /// <returns>The result, 0 success, 1 failure.</returns>
    [UnmanagedCallersOnly(EntryPoint = "EnableNamedPipes")]
    public static void EnableNamedPipes()
    {
        Main
    public static int EnableNamedPipes(nuint data)
        => Main
        (
            host =>
            {


@@ 46,42 47,56 @@ public class DllMain
                    (host.Services.GetRequiredService<IHostApplicationLifetime>().ApplicationStopping);
            }
        );
    }

    /// <summary>
    /// Open a console.
    /// </summary>
    /// <param name="data">Should be zero, is not used.</param>
    /// <returns>The result, 0 success, 1 failure.</returns>
    [UnmanagedCallersOnly(EntryPoint = "OpenConsole")]
    public static void OpenConsole()
    public static int OpenConsole(nuint data)
    {
        WinConsole.Initialize(false);
        return 0;
    }

    /// <summary>
    /// Close a console.
    /// </summary>
    /// <param name="data">Should be zero, is not used.</param>
    /// <returns>The result, 0 success, 1 failure.</returns>
    [UnmanagedCallersOnly(EntryPoint = "CloseConsole")]
    public static void CloseConsole()
    public static int CloseConsole(nuint data)
    {
        WinConsole.Close();
        return 0;
    }

    private static void Main(Func<IHost, Task<Result>> host)
    private static int Main(Func<IHost, Task<Result>> host)
    {
        new Thread
        (
            () =>
            {
                try
                {
                    MainEntry(host).GetAwaiter().GetResult();
                }
                catch (Exception e)
        try
        {
            new Thread
            (
                () =>
                {
                    Console.WriteLine(e.ToString());
                    try
                    {
                        MainEntry(host).GetAwaiter().GetResult();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
            }
        ).Start();
            ).Start();

            return 0;
        }
        catch (Exception)
        {
            return 1;
        }
    }

    /// <summary>

M src/Local/NosSmooth.Comms.Inject/NosSmooth.Comms.Inject.csproj => src/Local/NosSmooth.Comms.Inject/NosSmooth.Comms.Inject.csproj +5 -5
@@ 5,8 5,8 @@
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <EnableDynamicLoading>true</EnableDynamicLoading>
        <VersionPrefix>1.3.0</VersionPrefix>
        <PackageReleaseNotes>Add Costura.Fody support.</PackageReleaseNotes>
        <VersionPrefix>1.4.0</VersionPrefix>
        <PackageReleaseNotes>Update to new injection passing in data and returning an integer.</PackageReleaseNotes>
    </PropertyGroup>

    <ItemGroup>


@@ 16,10 16,10 @@
      </PackageReference>
      <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
      <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
      <PackageReference Include="NosSmooth.Core" Version="4.0.3" />
      <PackageReference Include="NosSmooth.Extensions.SharedBinding" Version="1.0.1" />
      <PackageReference Include="NosSmooth.Core" Version="5.0.0" />
      <PackageReference Include="NosSmooth.Extensions.SharedBinding" Version="1.0.2" />
      <PackageReference Include="NosSmooth.LocalBinding" Version="2.0.1" />
      <PackageReference Include="NosSmooth.LocalClient" Version="2.0.1" />
      <PackageReference Include="NosSmooth.LocalClient" Version="2.2.0" />
      <PackageReference Include="NosSmooth.PacketSerializer.Abstractions" Version="1.3.2" />
    </ItemGroup>


M src/Local/NosSmooth.Comms.Local/CommsInjector.cs => src/Local/NosSmooth.Comms.Local/CommsInjector.cs +10 -1
@@ 172,12 172,21 @@ public class CommsInjector

    private Result Inject(Process process, string method)
    {
        return _injector.Inject
        var injectResult = _injector.Inject
        (
            process,
            Path.GetFullPath("NosSmooth.Comms.Inject.dll"),
            "NosSmooth.Comms.Inject.DllMain, NosSmooth.Comms.Inject",
            method
        );

        if (!injectResult.IsDefined(out var result))
        {
            return Result.FromError(injectResult);
        }

        return result == 0
            ? Result.FromSuccess()
            : new GenericError("Unknown injection error has happened.");
    }
}
\ No newline at end of file

M src/Local/NosSmooth.Comms.Local/NosSmooth.Comms.Local.csproj => src/Local/NosSmooth.Comms.Local/NosSmooth.Comms.Local.csproj +3 -3
@@ 4,8 4,8 @@
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <VersionPrefix>1.3.0</VersionPrefix>
        <PackageReleaseNotes>Update Inject version to 1.3.0.</PackageReleaseNotes>
        <VersionPrefix>1.4.0</VersionPrefix>
        <PackageReleaseNotes>Update to new injection passing in data and returning an integer.</PackageReleaseNotes>
    </PropertyGroup>

    <ItemGroup>


@@ 17,7 17,7 @@
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="NosSmooth.Injector" Version="1.1.1">
        <PackageReference Include="NosSmooth.Injector" Version="2.0.0">
            <IncludeAssets>All</IncludeAssets>
            <PrivateAssets>None</PrivateAssets>
        </PackageReference>

Do not follow this link