Skip to content
Merged
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
17 changes: 8 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ jobs:
with:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer

- name: Setup NuGet
uses: nuget/setup-nuget@v2

- name: Restore NuGet packages
run: nuget restore OpenAC.Net.NFSe.sln
working-directory: src

# Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
8.x
9.x
10.x
11.x

- name: Restore NuGet packages
run: dotnet restore OpenAC.Net.NFSe.sln
working-directory: src

- run: dotnet msbuild OpenAC.Net.NFSe.sln -property:Configuration=Release -property:platform="Any CPU"
working-directory: src
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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.NFSe.sln --configuration Release -p:GeneratePackageOnBuild=false

- name: Run tests on .NET 8
run: >-
dotnet test OpenAC.Net.NFSe.sln --configuration Release --framework net8.0 --no-build
--filter "FullyQualifiedName!~.TestProvider&FullyQualifiedName!~.TestAbrasfV1&FullyQualifiedName!~.TestConsultaRpsISSSaoPaulo"

- name: Run tests on .NET 11
run: >-
dotnet test OpenAC.Net.NFSe.sln --configuration Release --framework net11.0 --no-build
--filter "FullyQualifiedName!~.TestProvider&FullyQualifiedName!~.TestAbrasfV1&FullyQualifiedName!~.TestConsultaRpsISSSaoPaulo"

- name: Pack NuGet packages
run: dotnet pack OpenAC.Net.NFSe.sln --configuration Release --no-build --output ../nuget

- name: Upload NuGet packages
uses: actions/upload-artifact@v7
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: nuget/*.nupkg
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Discord](https://img.shields.io/badge/Chat%20on-Discord-purple.svg)](https://discord.com/invite/brdmJ7Yv6w)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Target Frameworks](https://img.shields.io/badge/.NET%20Framework-4.6.2%20%7C%204.7.0%20%7C%204.8-blue.svg)](https://dotnet.microsoft.com/)
[![Target Frameworks](https://img.shields.io/badge/.NET%20Core%20%2F%20Standard-netstandard2.0%20%7C%20net6.0%20%7C%20net7.0%20%7C%20net8.0%20%7C%20net9.0%20%7C%20net10.0-blue.svg)](https://dotnet.microsoft.com/)
[![Target Frameworks](https://img.shields.io/badge/.NET%20Core%20%2F%20Standard-netstandard2.0%20%7C%20net6.0%20%7C%20net7.0%20%7C%20net8.0%20%7C%20net9.0%20%7C%20net10.0%20%7C%20net11.0-blue.svg)](https://dotnet.microsoft.com/)

Biblioteca .NET multiplataforma para geração, assinatura, transmissão, consulta e impressão de **NFS-e (Nota Fiscal de Serviço Eletrônica)** para centenas de municípios brasileiros.

Expand Down Expand Up @@ -41,7 +41,7 @@ Desenvolvida pelo time **OpenAC .Net**, a biblioteca abstrai as particularidades
- Métodos `Async` com `CancellationToken`, preservando a API síncrona existente.
- **Integração ASP.NET Core**:
- Registro por escopo com `AddOpenNFSeWeb` e clientes independentes por empresa.
- `IHttpClientFactory`, timeouts por operação, retentativas para métodos HTTP seguros e circuit breaker.
- Pool HTTP do DFe.Core por tenant, timeouts por operação, retentativas para métodos HTTP seguros e circuit breaker.
- Logs, rastreamento e métricas de operações.
- DANFSe em memória e respostas HTTP para Minimal APIs.
- **Demo Avalonia**:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Web;
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Web.Configuration;
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Web.Service;
using OpenAC.Net.NFSe.Web;
using OpenAC.Net.NFSe.Web.Provider;

// ReSharper disable once CheckNamespace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0;net11.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down Expand Up @@ -46,8 +46,4 @@
<None Include="README.md" Pack="true" PackagePath="/" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenAC.Net.DFe.Core" Version="1.7.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Http;
using OpenAC.Net.NFSe.Nota;
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Web.Document;
using OpenAC.Net.NFSe.Web;
using OpenAC.Net.NFSe.Web.Common;

namespace OpenAC.Net.NFSe.DANFSe.PDFSharp.Web.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

using System;
using System.IO;
using System.Linq;
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Configuracao;

namespace OpenAC.Net.NFSe.DANFSe.PDFSharp.Extensions;
Expand Down Expand Up @@ -52,7 +51,8 @@ public static void ImprimirPDF(this OpenNFSe nfse, Action<DANFSePDFSharpOptions>
/// <param name="nfse">Instância do componente OpenNFSe.</param>
/// <param name="caminhoArquivo">Caminho do arquivo de destino.</param>
/// <param name="options">Ação para customização das opções de impressão.</param>
public static void ImprimirPDF(this OpenNFSe nfse, string caminhoArquivo, Action<DANFSePDFSharpOptions>? options = null)
public static void ImprimirPDF(this OpenNFSe nfse, string caminhoArquivo,
Action<DANFSePDFSharpOptions>? options = null)
{
var danfse = new OpenDANFSePDFSharp(nfse.Configuracoes);
options?.Invoke(danfse.Configuracoes);
Expand Down Expand Up @@ -84,4 +84,4 @@ public static byte[] GerarPDF(this OpenNFSe nfse, Action<DANFSePDFSharpOptions>?
options?.Invoke(danfse.Configuracoes);
return danfse.GerarPDF(nfse.NotasServico.ToArray());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net48;netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
<TargetFrameworks>net462;net48;netstandard2.0;net8.0;net9.0;net10.0;net11.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<AssemblyName>OpenAC.Net.NFSe.DANFSe.PDFSharp</AssemblyName>
<RootNamespace>OpenAC.Net.NFSe.DANFSe.PDFSharp</RootNamespace>
Expand Down Expand Up @@ -39,10 +39,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.13" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="11.0.0" Condition="'$(TargetFramework)' != 'net9.0'" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="11.0.0" Condition="'$(TargetFramework)' == 'net9.0'" />
<PackageReference Include="PDFsharp" Version="6.2.4" />
<PackageReference Include="QRCoder" Version="1.8.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.400">
<PackageReference Include="QRCoder" Version="1.9.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="11.0.100">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
1 change: 0 additions & 1 deletion src/OpenAC.Net.NFSe.DANFSe.PDFSharp/OpenDANFSePDFSharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Configuracao;
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Layout;
using OpenAC.Net.NFSe.Nota;
using PdfSharp;
using PdfSharp.Pdf;

namespace OpenAC.Net.NFSe.DANFSe.PDFSharp;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenAC.Net.NFSe.DANFSe.PDFSharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Discord](https://img.shields.io/badge/Chat%20on-Discord-purple.svg)](https://discord.com/invite/brdmJ7Yv6w)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Target Frameworks](https://img.shields.io/badge/.NET%20Framework-4.6.2%20%7C%204.8-blue.svg)](https://dotnet.microsoft.com/)
[![Target Frameworks](https://img.shields.io/badge/.NET%20Core%20%2F%20Standard-netstandard2.0%20%7C%20net8.0%20%7C%20net9.0%20%7C%20net10.0-blue.svg)](https://dotnet.microsoft.com/)
[![Target Frameworks](https://img.shields.io/badge/.NET%20Core%20%2F%20Standard-netstandard2.0%20%7C%20net8.0%20%7C%20net9.0%20%7C%20net10.0%20%7C%20net11.0-blue.svg)](https://dotnet.microsoft.com/)

Biblioteca .NET para geração, visualização e exportação do **DANFSe (Documento Auxiliar da NFS-e)** em PDF utilizando **PDFsharp 6.x** e **QRCoder**.

Expand Down
1 change: 0 additions & 1 deletion src/OpenAC.Net.NFSe.Demo/MainWindow.Operations.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Globalization;
using Avalonia.Platform.Storage;
using OpenAC.Net.NFSe.Commom.Model;
using OpenAC.Net.NFSe.DANFSe.PDFSharp;
using OpenAC.Net.NFSe.Nota;

Expand Down
1 change: 0 additions & 1 deletion src/OpenAC.Net.NFSe.Demo/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using NLog.Config;
using NLog.Targets;
using OpenAC.Net.NFSe.Commom.Model;
using OpenAC.Net.NFSe.Nota;

namespace OpenAC.Net.NFSe.Demo;

Expand Down
8 changes: 4 additions & 4 deletions src/OpenAC.Net.NFSe.Demo/OpenAC.Net.NFSe.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets/**" />
<PackageReference Include="Avalonia.Desktop" Version="12.1.4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.1.4" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="12.1.4" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="10.0.11" />
<PackageReference Include="Avalonia.Desktop" Version="12.2.0" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.2.0" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="12.2.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="11.0.0" />
<PackageReference Include="NLog" Version="6.2.2" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions src/OpenAC.Net.NFSe.Demo/OpenConfig.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Configuration;
using System.Globalization;
using System.IO;
using OpenAC.Net.Core.Extensions;

namespace OpenAC.Net.NFSe.Demo;

Expand Down
10 changes: 5 additions & 5 deletions src/OpenAC.Net.NFSe.Test/OpenAC.Net.NFSe.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net11.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -10,14 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenAC.Net.DFe.Core" Version="1.7.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="OpenAC.Net.DFe.Core" Version="1.8.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.0">
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="10.0.1">
<PackageReference Include="coverlet.collector" Version="10.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
25 changes: 14 additions & 11 deletions src/OpenAC.Net.NFSe.Test/TestCommunication.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenAC.Net.DFe.Core.Storage;
using OpenAC.Net.DFe.Core.Http;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using OpenAC.Net.NFSe.Commom.Client;
using OpenAC.Net.NFSe.Commom.Types;
Expand Down Expand Up @@ -74,8 +74,10 @@ public async Task ConcurrentFileNamesPreserveAllDocuments()
var directory = Path.Combine(Path.GetTempPath(), "nfse-store-" + Guid.NewGuid().ToString("N"));
try
{
var document = new NFSeDocument(NFSeTipoDocumento.NFSe, "documento", "NFSe.xml", "", DateTime.Today);
await Task.WhenAll(Enumerable.Range(0, 12).Select(_ => DesktopNFSeDocumentStore.SaveToDirectoryAsync(document, directory)));
var config = new ConfigNFSe();
config.Arquivos.PathNFSe = directory;
var document = new NFSeDocument(config, NFSeCategorias.NFSe, "documento", "NFSe.xml", "", DateTime.Today);
await Task.WhenAll(Enumerable.Range(0, 12).Select(_ => config.DocumentStore.SaveAsync(document)));
Assert.Equal(12, Directory.GetFiles(directory).Length);
Assert.All(Directory.GetFiles(directory), file => Assert.Equal("documento", File.ReadAllText(file)));
}
Expand All @@ -88,8 +90,10 @@ public async Task InvalidStorageDestinationDoesNotLoopForever()
var filename = Path.GetTempFileName();
try
{
var document = new NFSeDocument(NFSeTipoDocumento.NFSe, "xml", "NFSe.xml", "", DateTime.Today);
await Assert.ThrowsAsync<IOException>(() => DesktopNFSeDocumentStore.SaveToDirectoryAsync(document, filename));
var config = new ConfigNFSe();
config.Arquivos.PathNFSe = filename;
var document = new NFSeDocument(config, NFSeCategorias.NFSe, "xml", "NFSe.xml", "", DateTime.Today);
await Assert.ThrowsAsync<IOException>(() => config.DocumentStore.SaveAsync(document));
}
finally { File.Delete(filename); }
}
Expand Down Expand Up @@ -122,14 +126,13 @@ private sealed class ProbeClient(ProviderBase provider) : NFSeHttpServiceClient(
public void Post() { AuthenticationScheme = AuthScheme.Basic; ExecutePost(new StringContent("<xml/>")); }
protected override string Authentication() => Convert.ToBase64String(Encoding.UTF8.GetBytes("user:password"));
}
internal sealed class CallbackTransport(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> callback) : INFSeHttpTransport
internal sealed class CallbackTransport(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> callback) : IDFeHttpTransport
{
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, ConfigNFSe configuration,
X509Certificate2? certificate, bool validateServerCertificate, CancellationToken cancellationToken = default) => callback(request, cancellationToken);
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, DFeHttpTransportOptions options, CancellationToken cancellationToken = default) => callback(request, cancellationToken);
}
internal sealed class NullStore : INFSeDocumentStore
internal sealed class NullStore : IDFeDocumentStore
{
public Task SaveAsync(NFSeDocument document, ConfigNFSe configuration, CancellationToken cancellationToken = default) => Task.CompletedTask;
public Task SaveAsync(IDFeDocument document, CancellationToken cancellationToken = default) => Task.CompletedTask;
}
private sealed class TrackedContent(byte[] bytes) : ByteArrayContent(bytes)
{
Expand Down
6 changes: 1 addition & 5 deletions src/OpenAC.Net.NFSe.Test/TestDANFSePDFSharp.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.IO;
using OpenAC.Net.NFSe.DANFSe.PDFSharp;
using OpenAC.Net.NFSe.DANFSe.PDFSharp.Extensions;
using OpenAC.Net.NFSe.Nota;
using Xunit;

namespace OpenAC.Net.NFSe.Test;

public class TestDANFSePDFSharp
{
private const string OutDir = "/mnt/e/Programacao/OpenAC .Net/OpenAC.Net.NFSe/exemplos";
private static readonly string OutDir = Path.Combine(AppContext.BaseDirectory, "exemplos");

[Fact]
public void TestGerarPDFSimples()
Expand Down
2 changes: 0 additions & 2 deletions src/OpenAC.Net.NFSe.Test/TestProviderISSSaoPaulo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using OpenAC.Net.DFe.Core;
using OpenAC.Net.DFe.Core.Serializer;
using OpenAC.Net.NFSe.Commom.Types;
using OpenAC.Net.NFSe.Configuracao;
using OpenAC.Net.NFSe.Nota;
Expand Down
1 change: 0 additions & 1 deletion src/OpenAC.Net.NFSe.Test/TestProviderTiplan203.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using OpenAC.Net.NFSe.Configuracao;
using OpenAC.Net.NFSe.Nota;
using Xunit;
Expand Down
Loading