diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 18d2266..b4d6bad 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -23,7 +23,6 @@ jobs:
with:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
- # Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
@@ -31,12 +30,10 @@ jobs:
8.x
9.x
10.x
+ 11.x
- - name: Setup NuGet
- uses: nuget/setup-nuget@v3
-
- name: Restore NuGet packages
- run: nuget restore OpenAC.Net.Devices.sln
+ run: dotnet restore OpenAC.Net.Devices.sln
working-directory: src
- name: Build solution
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
new file mode 100644
index 0000000..b762322
--- /dev/null
+++ b/.github/workflows/pull-request.yml
@@ -0,0 +1,49 @@
+name: Pull Request CI
+
+on:
+ pull_request:
+
+permissions:
+ contents: read
+
+defaults:
+ run:
+ working-directory: src
+
+jobs:
+ validate:
+ name: Build, Test and Pack
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ persist-credentials: false
+
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v6
+ with:
+ dotnet-version: |
+ 8.x
+ 9.x
+ 10.x
+ 11.x
+
+ - name: Build solution
+ run: dotnet build OpenAC.Net.Devices.sln --configuration Release -p:GeneratePackageOnBuild=false
+
+ - name: Run tests on .NET 9
+ run: dotnet run --project OpenAC.Net.Devices.Tests/OpenAC.Net.Devices.Tests.csproj --configuration Release --framework net9.0 --no-build
+
+ - name: Run tests on .NET 11
+ run: dotnet run --project OpenAC.Net.Devices.Tests/OpenAC.Net.Devices.Tests.csproj --configuration Release --framework net11.0 --no-build
+
+ - name: Pack NuGet package
+ run: dotnet pack OpenAC.Net.Devices/OpenAC.Net.Devices.csproj --configuration Release --no-build --output ../nuget
+
+ - name: Upload NuGet package
+ uses: actions/upload-artifact@v7
+ with:
+ name: nuget
+ if-no-files-found: error
+ retention-days: 7
+ path: nuget/*.nupkg
diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index a156380..d21c4b0 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -23,7 +23,6 @@ jobs:
with:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
- # Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
@@ -31,12 +30,10 @@ jobs:
8.x
9.x
10.x
+ 11.x
- - name: Setup NuGet
- uses: nuget/setup-nuget@v3
-
- name: Restore NuGet packages
- run: nuget restore OpenAC.Net.Devices.sln
+ run: dotnet restore OpenAC.Net.Devices.sln
working-directory: src
- name: Build solution
diff --git a/README.md b/README.md
index 3d62461..5414846 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[](https://discord.com/invite/brdmJ7Yv6w)
[](https://opensource.org/licenses/MIT)
[](https://dotnet.microsoft.com/)
-[](https://dotnet.microsoft.com/)
+[](https://dotnet.microsoft.com/)
Biblioteca .NET multiplataforma para abstração e comunicação com dispositivos de automação comercial (impressoras térmicas ESC/POS, balanças, leitores, etiquetadoras e periféricos em geral).
@@ -33,7 +33,7 @@ Desenvolvida pelo time **OpenAC .Net**, a biblioteca fornece uma interface unifi
- Escrita direta em arquivos ou dispositivos de bloco/caractere (`FileConfig`).
- **Suporte a Blazor Server e WebAssembly (`OpenAC.Net.Devices.Blazor`)**:
- WebSerial, WebUSB e Web Bluetooth (BLE/GATT) por interop assíncrono próprio, sem SpawnDev.
- - .NET 8, 9 e 10, com seleção por gesto do usuário e verificação de suporte do navegador.
+ - .NET 8, 9, 10 e 11, com seleção por gesto do usuário e verificação de suporte do navegador.
---
@@ -232,7 +232,7 @@ await fileDevice.WriteAsync([0x1B, 0x40]);
A extensão `OpenAC.Net.Devices.Blazor` usa as APIs do navegador por meio de
`Microsoft.JSInterop`, sem SpawnDev nem bibliotecas JavaScript externas. Os alvos
-são **.NET 8, 9 e 10**, nos modos **Server / Interactive Server**, **WebAssembly /
+são **.NET 8, 9, 10 e 11**, nos modos **Server / Interactive Server**, **WebAssembly /
Interactive WebAssembly** e **Interactive Auto**.
No `Program.cs`, registre o serviço:
diff --git a/src/.idea/.idea.OpenAC.Net.Devices/.idea/workspace.xml b/src/.idea/.idea.OpenAC.Net.Devices/.idea/workspace.xml
index 813dc73..f50d928 100644
--- a/src/.idea/.idea.OpenAC.Net.Devices/.idea/workspace.xml
+++ b/src/.idea/.idea.OpenAC.Net.Devices/.idea/workspace.xml
@@ -13,73 +13,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -102,7 +36,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{
@@ -204,8 +138,9 @@
"cidr.known.project.marker": "true",
"codeWithMe.voiceChat.enabledByDefault": "false",
"com.jetbrains.opentelemetry.toolwindow.stripe.promo": "true",
- "git-widget-placeholder": "main",
+ "git-widget-placeholder": "ajustes",
"ignore.virus.scanning.warn.message": "true",
+ "last_opened_file_path": "/mnt/e/Programacao/OpenAC .Net/OpenAC.Net.NFSe.Nacional",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@@ -287,7 +222,8 @@
-
+
+
diff --git a/src/OpenAC.Net.Devices.Blazor/OpenAC.Net.Devices.Blazor.csproj b/src/OpenAC.Net.Devices.Blazor/OpenAC.Net.Devices.Blazor.csproj
index d15ab6b..ff08409 100644
--- a/src/OpenAC.Net.Devices.Blazor/OpenAC.Net.Devices.Blazor.csproj
+++ b/src/OpenAC.Net.Devices.Blazor/OpenAC.Net.Devices.Blazor.csproj
@@ -1,7 +1,7 @@
- net8.0;net9.0;net10.0
+ net8.0;net9.0;net10.0;net11.0
latest
enable
enable
@@ -10,12 +10,14 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/OpenAC.Net.Devices.Blazor/WebDevice.cs b/src/OpenAC.Net.Devices.Blazor/WebDevice.cs
index beab6f2..a98ad6f 100644
--- a/src/OpenAC.Net.Devices.Blazor/WebDevice.cs
+++ b/src/OpenAC.Net.Devices.Blazor/WebDevice.cs
@@ -42,9 +42,11 @@ internal async Task WriteAsync(byte[] data, CancellationToken cancellationToken)
if (receiverReference == null)
throw new InvalidOperationException("Abra o dispositivo com OpenAsync antes de escrever.");
// Mantém as mensagens abaixo do limite padrão de 32 KiB do SignalR.
+#pragma warning disable BL0016 // O stream trata as falhas de escrita segundo sua política de retry.
for (var offset = 0; offset < data.Length; offset += 8192)
await manager.InvokeVoidAsync("write", cancellationToken, Info.Id,
data.AsSpan(offset, Math.Min(8192, data.Length - offset)).ToArray());
+#pragma warning restore BL0016
}
internal async Task CloseAsync(CancellationToken cancellationToken)
@@ -52,7 +54,9 @@ internal async Task CloseAsync(CancellationToken cancellationToken)
if (receiverReference == null) return;
try
{
+#pragma warning disable BL0016 // O chamador recebe a falha após a liberação da referência no finally.
await manager.InvokeVoidAsync("close", cancellationToken, Info.Id);
+#pragma warning restore BL0016
}
finally
{
diff --git a/src/OpenAC.Net.Devices.Blazor/WebDeviceButtonBinding.cs b/src/OpenAC.Net.Devices.Blazor/WebDeviceButtonBinding.cs
index c431931..59ceecd 100644
--- a/src/OpenAC.Net.Devices.Blazor/WebDeviceButtonBinding.cs
+++ b/src/OpenAC.Net.Devices.Blazor/WebDeviceButtonBinding.cs
@@ -19,8 +19,10 @@ internal WebDeviceButtonBinding(Func onSelected, Func
binding = await manager.InvokeAsync("bind", button, kind, options, reference);
+#pragma warning restore BL0016
[JSInvokable]
public Task Selected(WebDeviceInfo info) => disposed ? Task.CompletedTask : onSelected(info);
diff --git a/src/OpenAC.Net.Devices.Blazor/WebDeviceService.cs b/src/OpenAC.Net.Devices.Blazor/WebDeviceService.cs
index d65a940..75135b1 100644
--- a/src/OpenAC.Net.Devices.Blazor/WebDeviceService.cs
+++ b/src/OpenAC.Net.Devices.Blazor/WebDeviceService.cs
@@ -19,9 +19,11 @@ private async Task GetManagerAsync()
try
{
ObjectDisposedException.ThrowIf(disposed, this);
+#pragma warning disable BL0016 // A inicialização propaga falhas ao chamador e libera o semáforo no finally.
module ??= await js.InvokeAsync("import",
"./_content/OpenAC.Net.Devices.Blazor/openac-devices.js");
manager ??= await module.InvokeAsync("createManager");
+#pragma warning restore BL0016
return manager;
}
finally { initialization.Release(); }
@@ -37,6 +39,7 @@ private WebDevice Wrap(IJSObjectReference owner, WebDeviceInfo info)
}
}
+#pragma warning disable BL0016 // As operações de consulta e seleção propagam falhas de interop ao chamador.
public async Task GetSupportAsync() =>
await (await GetManagerAsync()).InvokeAsync("support");
@@ -63,6 +66,7 @@ public async Task GetAuthorizedDevicesAsync(string kind)
var infos = await owner.InvokeAsync("getDevices", kind);
return infos.Select(info => Wrap(owner, info)).ToArray();
}
+#pragma warning restore BL0016
public Task BindSerialButtonAsync(ElementReference button,
Func onSelected, Func? onError = null, WebSerialRequestOptions? options = null) =>
@@ -108,7 +112,9 @@ async Task Cleanup(Func action)
}
foreach (var device in selected) await Cleanup(device.DisposeAsync);
+#pragma warning disable BL0016 // Cleanup aguarda a chamada e trata suas exceções.
if (manager != null) await Cleanup(() => manager.InvokeVoidAsync("dispose"));
+#pragma warning restore BL0016
if (manager != null) await Cleanup(manager.DisposeAsync);
if (module != null) await Cleanup(module.DisposeAsync);
lock (devices) devices.Clear();
diff --git a/src/OpenAC.Net.Devices.Tests/OpenAC.Net.Devices.Tests.csproj b/src/OpenAC.Net.Devices.Tests/OpenAC.Net.Devices.Tests.csproj
index 0d8cff8..1ab5edd 100644
--- a/src/OpenAC.Net.Devices.Tests/OpenAC.Net.Devices.Tests.csproj
+++ b/src/OpenAC.Net.Devices.Tests/OpenAC.Net.Devices.Tests.csproj
@@ -1,7 +1,7 @@
- net9.0
+ net9.0;net11.0
enable
enable
Exe
@@ -11,7 +11,7 @@
-
+
diff --git a/src/OpenAC.Net.Devices.Tests/OpenTcpStreamTests.cs b/src/OpenAC.Net.Devices.Tests/OpenTcpStreamTests.cs
index 8be57e2..c7f0b2d 100644
--- a/src/OpenAC.Net.Devices.Tests/OpenTcpStreamTests.cs
+++ b/src/OpenAC.Net.Devices.Tests/OpenTcpStreamTests.cs
@@ -9,7 +9,10 @@ public class OpenTcpStreamTests
[Test]
public async Task WriteRead_ComHostnameLocalhost_DeveEnviarEReceberDados()
{
- using var listener = new TcpListener(IPAddress.Loopback, 0);
+ const string host = "localhost";
+ // A ordem de resolução do loopback pode variar entre IPv4 e IPv6.
+ var loopback = (await Dns.GetHostAddressesAsync(host)).First(IPAddress.IsLoopback);
+ using var listener = new TcpListener(loopback, 0);
listener.Start();
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
@@ -26,7 +29,7 @@ public async Task WriteRead_ComHostnameLocalhost_DeveEnviarEReceberDados()
await Task.Delay(100);
});
- var config = new TCPConfig("localhost", port)
+ var config = new TCPConfig(host, port)
{
ControlePorta = false,
TimeOut = 2
diff --git a/src/OpenAC.Net.Devices.Tests/WebDeviceTests.cs b/src/OpenAC.Net.Devices.Tests/WebDeviceTests.cs
index cd4af0c..4704efc 100644
--- a/src/OpenAC.Net.Devices.Tests/WebDeviceTests.cs
+++ b/src/OpenAC.Net.Devices.Tests/WebDeviceTests.cs
@@ -19,8 +19,10 @@ private sealed class FakeInterop : IJSRuntime, IJSObjectReference
public int WriteFailures { get; set; }
public WebDeviceReadStream? Receiver { get; private set; }
+#pragma warning disable BL0016 // O fake simula falhas sem executar JavaScript.
public ValueTask InvokeAsync(string identifier, object?[]? args) =>
InvokeAsync(identifier, CancellationToken.None, args);
+#pragma warning restore BL0016
public ValueTask InvokeAsync(string identifier, CancellationToken cancellationToken, object?[]? args)
{
diff --git a/src/OpenAC.Net.Devices/OpenAC.Net.Devices.csproj b/src/OpenAC.Net.Devices/OpenAC.Net.Devices.csproj
index 6c6dd0c..d5ea769 100644
--- a/src/OpenAC.Net.Devices/OpenAC.Net.Devices.csproj
+++ b/src/OpenAC.Net.Devices/OpenAC.Net.Devices.csproj
@@ -1,7 +1,7 @@
- net462;net48;netstandard2.0;net8.0;net9.0;net10.0
+ net462;net48;netstandard2.0;net8.0;net9.0;net10.0;net11.0
latest
OpenAC.Net.Devices
OpenAC.Net.Devices
@@ -17,9 +17,9 @@
OpenAC.Net.Devices
Biblioteca para comunicação com dispositivos usada pelo Projeto OpenAC .Net
pt-BR
- 1.7.0.0
- 1.7.0.0
- 1.7.0.0
+ 1.7.1.0
+ 1.7.1.0
+ 1.7.1.0
true
nuget.png
LICENSE
@@ -46,27 +46,31 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
\ No newline at end of file
+