Skip to content

Commit

Permalink
PublicApiGenerator script and current report
Browse files Browse the repository at this point in the history
  • Loading branch information
eduard-dumitru committed Oct 9, 2024
1 parent 8e0b232 commit 84bb59a
Show file tree
Hide file tree
Showing 270 changed files with 18,140 additions and 3,106 deletions.
1 change: 1 addition & 0 deletions src/NuGet.Config → NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<configuration>
<packageSources>
<add key="Nuget" value="https://api.nuget.org/v3/index.json" />
<add key="UiPath-Internal" value="https://uipath.pkgs.visualstudio.com/Public.Feeds/_packaging/UiPath-Internal/nuget/v3/index.json" />
</packageSources>
</configuration>
4 changes: 2 additions & 2 deletions src/CI/azp-dotnet-dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ steps:

- task: DotNetCoreCLI@2
displayName: 'dotnet push to UiPath-Internal'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
condition: succeeded()
inputs:
command: push
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
publishVstsFeed: 'Public.Feeds/UiPath-Internal'

- task: PublishSymbols@2
displayName: 'Publish Symbols to UiPath Azure Artifacts Symbol Server'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
condition: succeeded()
inputs:
symbolsFolder: $(Build.SourcesDirectory)
searchPattern: '**/UiPath.CoreIpc/bin/**/UiPath.CoreIpc.pdb'
Expand Down
6 changes: 6 additions & 0 deletions src/CI/azp-dotnet.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
steps:
- task: DotNetCoreCLI@2
displayName: '$(Label_DotNet) Restore, build and pack'
inputs:
projects: '$(DotNet_SessionSolution)'
arguments: '--configuration $(DotNet_BuildConfiguration) -p:Version="$(FullVersion)" -p:DefineConstantsEx="CI"'

- task: DotNetCoreCLI@2
displayName: '$(Label_DotNet) Run unit tests'
inputs:
Expand Down
19 changes: 19 additions & 0 deletions src/CI/azp-initialization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
steps:
# Runtime version should match with SDK version.
# The runtime should be the one that is contained in SDK.
# https://dotnet.microsoft.com/en-us/download/dotnet/6.0
- powershell: |
Write-Host "##vso[task.setvariable variable=DotnetRuntimeVersion;]8.0.8"
Write-Host "##vso[task.setvariable variable=DOTNET_NOLOGO;]true"
displayName: 'Use .NET Runtime 8.0.8'
- task: UseDotNet@2
displayName: 'Use .NET SDK 6.0.317'
inputs:
packageType: 'sdk'
version: '6.0.317'

- task: UseDotNet@2
displayName: 'Use .NET SDK 8.0.400'
inputs:
packageType: 'sdk'
version: 8.0.400

# Read $(Version) from the UiPath.CoreIpc.csproj file
- powershell: |
Expand Down
2 changes: 1 addition & 1 deletion src/CI/azp-nodejs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
inputs:
workingDirectory: $(NodeJS_ProjectPath)
script: 'npm test'

- task: PublishTestResults@2
displayName: 'Publish Web Test Results'
condition: succeededOrFailed()
Expand Down
50 changes: 25 additions & 25 deletions src/CI/azp-start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variables:
DotNet_MainProjectName: 'UiPath.CoreIpc'
DotNet_MainProjectPath: './src/UiPath.CoreIpc/UiPath.CoreIpc.csproj'
DotNet_ArtifactName: 'NuGet package'

NodeJS_DotNet_BuildConfiguration: 'Debug'
NodeJS_ProjectPath: './src/Clients/js'
NodeJS_ArchivePath: './src/Clients/js/dist/pack/nodejs.zip'
Expand All @@ -23,32 +23,32 @@ stages:
- stage: Build
displayName: '🏭 Build'
jobs:
# The following 3 jobs will run in parallel:
- job:
displayName: '.NET on Windows'
pool:
# The following 3 jobs will run in parallel:
- job:
displayName: '.NET on Windows'
pool:
vmImage: 'windows-2022'
steps:
- template: azp-initialization.yaml
- template: azp-dotnet.yaml
- template: azp-dotnet-dist.yaml
- job:
displayName: 'node.js on Windows'
pool:
steps:
- template: azp-initialization.yaml
- template: azp-dotnet.yaml
- template: azp-dotnet-dist.yaml

- job:
displayName: 'node.js on Windows'
pool:
vmImage: 'windows-2022'
steps:
- template: azp-initialization.yaml
- template: azp-nodejs.yaml
- template: azp-nodejs-dist.yaml
- job:
displayName: 'node.js on Ubuntu'
pool:
vmImage: 'ubuntu-20.04'
steps:
- template: azp-initialization.yaml
- template: azp-nodejs.yaml
steps:
- template: azp-initialization.yaml
- template: azp-nodejs.yaml
- template: azp-nodejs-dist.yaml

- job:
displayName: 'node.js on Ubuntu'
pool:
vmImage: 'ubuntu-20.04'
steps:
- template: azp-initialization.yaml
- template: azp-nodejs.yaml

- stage: Publish
displayName: 🚚 Publish
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/js/dotnet/UiPath.CoreIpc.NodeInterop.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30320.27
# Visual Studio Version 17
VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UiPath.CoreIpc.NodeInterop", "UiPath.CoreIpc.NodeInterop\UiPath.CoreIpc.NodeInterop.csproj", "{B514D2A2-B8ED-4A2A-BDE7-42F74A316FBE}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace UiPath.CoreIpc.NodeInterop;
namespace UiPath.Ipc.NodeInterop;

internal static class Contracts
{
Expand Down
146 changes: 88 additions & 58 deletions src/Clients/js/dotnet/UiPath.CoreIpc.NodeInterop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using UiPath.CoreIpc.NamedPipe;
using UiPath.CoreIpc.WebSockets;
using UiPath.Ipc.Transport.NamedPipe;
using UiPath.Ipc.Transport.WebSocket;

namespace UiPath.CoreIpc.NodeInterop;
namespace UiPath.Ipc.NodeInterop;

using static Contracts;
using static ServiceImpls;
using static Signalling;
using static UiPath.Ipc.NodeInterop.Extensions;

class Program
{
Expand Down Expand Up @@ -61,6 +62,11 @@ static async Task<int> Main(

static async Task MainCore(string? pipeName, string? webSocketUrl, int? maybeSecondsPowerOnDelay)
{
if (pipeName is null && webSocketUrl is null)
{
throw new ArgumentException($"At least one of {nameof(pipeName)} or {nameof(webSocketUrl)} must be specified.");
}

if (maybeSecondsPowerOnDelay is { } secondsPowerOnDelay)
{
await Task.Delay(TimeSpan.FromSeconds(secondsPowerOnDelay));
Expand All @@ -71,34 +77,41 @@ static async Task MainCore(string? pipeName, string? webSocketUrl, int? maybeSec

var sp = services
.AddLogging()
.AddIpc()
.AddSingleton<IAlgebra, Algebra>()
.AddSingleton<ICalculus, Calculus>()
.AddSingleton<IBrittleService, BrittleService>()
.AddSingleton<IEnvironmentVariableGetter, EnvironmentVariableGetter>()
.AddSingleton<IDtoService, DtoService>()
.BuildServiceProvider();

var serviceHost = new ServiceHostBuilder(sp)
.UseNamedPipesAndOrWebSockets(pipeName, webSocketUrl)
.AddEndpoint<IAlgebra, IArithmetic>()
.AddEndpoint<ICalculus>()
.AddEndpoint<IBrittleService>()
.AddEndpoint<IEnvironmentVariableGetter>()
.AddEndpoint<IDtoService>()
.Build();

var thread = new AsyncContextThread();
thread.Context.SynchronizationContext.Send(_ => Thread.CurrentThread.Name = "GuiThread", null);
var sched = thread.Context.Scheduler;
var scheduler = thread.Context.Scheduler;

var ipcServer = new IpcServer()
{
Endpoints = new()
{
typeof(IAlgebra),
typeof(ICalculus),
typeof(IBrittleService),
typeof(IEnvironmentVariableGetter),
typeof(IDtoService)
},
Listeners = [
..EnumerateListeners(pipeName, webSocketUrl)
],
ServiceProvider = sp,
Scheduler = scheduler
};
ipcServer.Start();

_ = Task.Run(async () =>
{
try
{
await using var sp = new ServiceCollection()
.AddLogging()
.AddIpc()
.BuildServiceProvider();

var callback = new Arithmetic();
Expand All @@ -107,25 +120,51 @@ IEnumerable<Task> EnumeratePings()
{
if (webSocketUrl is not null)
{
yield return new WebSocketClientBuilder<IAlgebra, IArithmetic>(uri: new(webSocketUrl), sp)
.RequestTimeout(TimeSpan.FromHours(5))
.CallbackInstance(callback)
.Build()
.Ping();
yield return new IpcClient
{
Config = new()
{
ServiceProvider = sp,
RequestTimeout = TimeSpan.FromHours(5),
Callbacks = new()
{
{ typeof(IArithmetic), callback }
},
},
Transport = new WebSocketTransport
{
Uri = new(webSocketUrl),
}
}
.GetProxy<IAlgebra>()
.Ping();
}

if (pipeName is not null)
{
yield return new NamedPipeClientBuilder<IAlgebra, IArithmetic>(pipeName, sp)
.RequestTimeout(TimeSpan.FromHours(5))
.CallbackInstance(callback)
.Build()
.Ping();
yield return new IpcClient
{
Config = new()
{
ServiceProvider = sp,
RequestTimeout = TimeSpan.FromHours(5),
Callbacks = new()
{
{ typeof(IArithmetic), callback }
}
},
Transport = new NamedPipeTransport()
{
PipeName = pipeName,
}
}
.GetProxy<IAlgebra>()
.Ping();
}
}

await Task.WhenAll(EnumeratePings());

Send(SignalKind.ReadyToConnect);
}
catch (Exception ex)
Expand All @@ -135,7 +174,29 @@ IEnumerable<Task> EnumeratePings()
}
});

await serviceHost.RunAsync(sched);
await ipcServer.WaitForStop();

IEnumerable<ListenerConfig> EnumerateListeners(string? pipeName, string? webSocketUrl)
{
if (pipeName is not null)
{
yield return new NamedPipeListener() { PipeName = pipeName };
}

if (webSocketUrl is not null)
{
string url = CurateWebSocketUrl(webSocketUrl);
var accept = new HttpSysWebSocketsListener(url).Accept;
yield return new WebSocketListener() { Accept = accept };
}

static string CurateWebSocketUrl(string raw)
{
var builder = new UriBuilder(raw);
builder.Scheme = "http";
return builder.ToString();
}
}
}

private class Arithmetic : IArithmetic
Expand All @@ -148,37 +209,6 @@ private class Arithmetic : IArithmetic

internal static class Extensions
{
public static ServiceHostBuilder UseNamedPipesAndOrWebSockets(this ServiceHostBuilder builder, string? pipeName, string? webSocketUrl)
{
if (pipeName is null && webSocketUrl is null)
{
throw new ArgumentOutOfRangeException();
}

if (pipeName is not null)
{
builder = builder.UseNamedPipes(new NamedPipeSettings(pipeName));
}

if (webSocketUrl is not null)
{
string url = CurateWebSocketUrl(webSocketUrl);
var accept = new HttpSysWebSocketsListener(url).Accept;
WebSocketSettings settings = new(accept);

builder = builder.UseWebSockets(settings);
}

return builder;
}

private static string CurateWebSocketUrl(string raw)
{
var builder = new UriBuilder(raw);
builder.Scheme = "http";
return builder.ToString();
}

public class HttpSysWebSocketsListener : IDisposable
{
HttpListener _httpListener = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading;
using System.Threading.Tasks;

namespace UiPath.CoreIpc.NodeInterop;
namespace UiPath.Ipc.NodeInterop;

using static Contracts;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Newtonsoft.Json.Converters;
using System;

namespace UiPath.CoreIpc.NodeInterop;
namespace UiPath.Ipc.NodeInterop;

internal static class Signalling
{
Expand Down
Loading

0 comments on commit 84bb59a

Please sign in to comment.