diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 94341fa..7353b8a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,40 +1,24 @@ name: Build and Test on: - pull_request: + pull_request: env: TEST_RESULTS_PATH: ${{ github.workspace }}/test-results.trx -permissions: - contents: read - actions: read - checks: write - jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4.1.7 - - name: Setup .NET - uses: actions/setup-dotnet@v4.0.0 + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-dotnet@v4.0.0 with: dotnet-version: 8.0.100 - - name: Dotnet Build - run: dotnet build --configuration Release - - name: Dotnet Test - run: | - dotnet test --configuration Release --no-restore --no-build --logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH }}" - - name: Upload test results - uses: actions/upload-artifact@v4 - if: success() || failure() - with: - name: test-results - path: ${{ env.TEST_RESULTS_PATH }} - - name: Upload test results - uses: dorny/test-reporter@v1.9.1 - if: success() || failure() + - run: dotnet build --configuration Release + - run: | + dotnet test --configuration Release --no-restore --no-build \ + --logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH }}" + - uses: dorny/test-reporter@v1 with: name: XUnit Tests path: ${{ env.TEST_RESULTS_PATH }} diff --git a/.github/workflows/check-changelog.yml b/.github/workflows/check-changelog.yml new file mode 100644 index 0000000..bd01836 --- /dev/null +++ b/.github/workflows/check-changelog.yml @@ -0,0 +1,12 @@ +name: Check Changelog + +on: + pull_request: + +jobs: + check-changelog: + runs-on: ubuntu-latest + steps: + - uses: tarides/changelog-check-action@v2 + with: + changelog: CHANGES.md diff --git a/.github/workflows/publish-and-test.yml b/.github/workflows/publish-and-test.yml new file mode 100644 index 0000000..131b383 --- /dev/null +++ b/.github/workflows/publish-and-test.yml @@ -0,0 +1,14 @@ +name: Publish Test + +on: + pull_request: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-dotnet@v4.0.0 + with: + dotnet-version: 8.0.100 + - run: dotnet publish diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 0000000..41ef03b --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,11 @@ +name: Check Typos + +on: + pull_request: + +jobs: + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: crate-ci/typos@v1.22.9 diff --git a/src/JSSoft.Communication/Extensions/ISerializerExtensions.cs b/src/JSSoft.Communication/Extensions/ISerializerExtensions.cs index fe9fb91..7aa2838 100644 --- a/src/JSSoft.Communication/Extensions/ISerializerExtensions.cs +++ b/src/JSSoft.Communication/Extensions/ISerializerExtensions.cs @@ -23,13 +23,13 @@ public static string[] SerializeMany(this ISerializer @this, Type[] types, objec return items; } - public static object?[] DeserializeMany(this ISerializer @this, Type[] types, string[] datas) + public static object?[] DeserializeMany(this ISerializer @this, Type[] types, string[] data) { - var items = new object?[datas.Length]; - for (var i = 0; i < datas.Length; i++) + var items = new object?[data.Length]; + for (var i = 0; i < data.Length; i++) { var type = types[i]; - var value = datas[i]; + var value = data[i]; items[i] = @this.Deserialize(type, value); } @@ -37,20 +37,20 @@ public static string[] SerializeMany(this ISerializer @this, Type[] types, objec } public static object?[] DeserializeMany( - this ISerializer @this, Type[] types, string[] datas, CancellationToken? cancellationToken) + this ISerializer @this, Type[] types, string[] data, CancellationToken? cancellationToken) { - var length = cancellationToken != null ? datas.Length + 1 : datas.Length; + var length = cancellationToken != null ? data.Length + 1 : data.Length; var items = new object?[length]; - for (var i = 0; i < datas.Length; i++) + for (var i = 0; i < data.Length; i++) { var type = types[i]; - var value = datas[i]; + var value = data[i]; items[i] = @this.Deserialize(type, value); } if (cancellationToken != null) { - items[datas.Length] = cancellationToken; + items[data.Length] = cancellationToken; } return items; diff --git a/src/JSSoft.Communication/Grpc/AdaptorServer.cs b/src/JSSoft.Communication/Grpc/AdaptorServer.cs index 2895b3e..67a3143 100644 --- a/src/JSSoft.Communication/Grpc/AdaptorServer.cs +++ b/src/JSSoft.Communication/Grpc/AdaptorServer.cs @@ -139,7 +139,7 @@ public async Task InvokeAsync(InvokeRequest request, ServerCallCont var instance = peer.Services[service]; var args = _serializer.DeserializeMany( types: methodDescriptor.ParameterTypes, - datas: [.. request.Data], + data: [.. request.Data], cancellationToken: cancellationToken); if (methodDescriptor.IsOneWay == true) { diff --git a/src/JSSoft.Communication/Grpc/Peer.cs b/src/JSSoft.Communication/Grpc/Peer.cs index 320cb49..f7fa341 100644 --- a/src/JSSoft.Communication/Grpc/Peer.cs +++ b/src/JSSoft.Communication/Grpc/Peer.cs @@ -47,7 +47,7 @@ public void EndPolling() } } - public void Disconect(int closeCode) + public void Disconnect(int closeCode) { lock (_lockObject) { diff --git a/src/JSSoft.Communication/Grpc/PeerCollection.cs b/src/JSSoft.Communication/Grpc/PeerCollection.cs index 32a8be8..d144fc1 100644 --- a/src/JSSoft.Communication/Grpc/PeerCollection.cs +++ b/src/JSSoft.Communication/Grpc/PeerCollection.cs @@ -38,7 +38,7 @@ public bool Remove(IServiceContext serviceContext, string id, int closeCode) { peer.Descriptor = null; _instanceContext.DestroyInstance(peer); - peer.Disconect(closeCode); + peer.Disconnect(closeCode); serviceContext.Debug($"{id} Disconnected ({closeCode})"); return true; } @@ -53,7 +53,7 @@ public async Task DisconnectAsync( using var cancellationTokenSource = new CancellationTokenSource(millisecondsDelay: 3000); foreach (var item in items) { - item.Disconect(closeCode: 0); + item.Disconnect(closeCode: 0); } while (Count > 0 && cancellationTokenSource.IsCancellationRequested != true) diff --git a/src/JSSoft.Communication/MethodDescriptorCollection.cs b/src/JSSoft.Communication/MethodDescriptorCollection.cs index bd98b86..2ba7bd1 100644 --- a/src/JSSoft.Communication/MethodDescriptorCollection.cs +++ b/src/JSSoft.Communication/MethodDescriptorCollection.cs @@ -12,7 +12,7 @@ namespace JSSoft.Communication; public sealed class MethodDescriptorCollection : IEnumerable { - private readonly Dictionary _discriptorByName; + private readonly Dictionary _descriptorByName; internal MethodDescriptorCollection(Type type) { @@ -25,23 +25,23 @@ internal MethodDescriptorCollection(Type type) { var methodInfos = type.GetMethods(); var methodDescriptors = methodInfos.Select(item => new MethodDescriptor(item)); - _discriptorByName = methodDescriptors.ToDictionary(item => item.Name); + _descriptorByName = methodDescriptors.ToDictionary(item => item.Name); } else { - _discriptorByName = []; + _descriptorByName = []; } } - public int Count => _discriptorByName.Count; + public int Count => _descriptorByName.Count; - public MethodDescriptor this[string name] => _discriptorByName[name]; + public MethodDescriptor this[string name] => _descriptorByName[name]; - public bool Contains(string name) => _discriptorByName.ContainsKey(name); + public bool Contains(string name) => _descriptorByName.ContainsKey(name); public IEnumerator GetEnumerator() - => _discriptorByName.Values.GetEnumerator(); + => _descriptorByName.Values.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() - => _discriptorByName.Values.GetEnumerator(); + => _descriptorByName.Values.GetEnumerator(); } diff --git a/test/JSSoft.Communication.Tests/ClientTestBase.cs b/test/JSSoft.Communication.Tests/ClientTestBase.cs index 27cdd37..91fd5d3 100644 --- a/test/JSSoft.Communication.Tests/ClientTestBase.cs +++ b/test/JSSoft.Communication.Tests/ClientTestBase.cs @@ -57,9 +57,9 @@ public async Task DisposeAsync() } } -public abstract class ClientTestBase : IAsyncLifetime +public abstract class ClientTestBase : IAsyncLifetime where TService : class - where TServerSevice : ServerService + where TServerService : ServerService { private readonly ClientService _clientService = new(); private readonly ServerContext _serverContext; @@ -70,7 +70,7 @@ public abstract class ClientTestBase : IAsyncLifetime private Guid _clientToken; private Guid _serverToken; - protected ClientTestBase(ITestOutputHelper logger, TServerSevice serverService) + protected ClientTestBase(ITestOutputHelper logger, TServerService serverService) { Logger = logger; ServerService = serverService; @@ -82,7 +82,7 @@ protected ClientTestBase(ITestOutputHelper logger, TServerSevice serverService) protected TService Client => _client!; - protected TServerSevice ServerService { get; } + protected TServerService ServerService { get; } public async Task InitializeAsync() {