Skip to content

Commit 1e778e9

Browse files
Backport v3.3.2
2 parents 2112b57 + 1cb26de commit 1e778e9

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
## In Development
44

55
- hic sunt leones
6+
7+
v 3.3.2
8+
-------
9+
10+
Released on May 24, 2022
11+
12+
- Fix: `WriteHtml` crea un file temporaneo che non viene eliminato in seguito ([#371][371])
13+
14+
[371]: https://github.com/FatturaElettronica/FatturaElettronica.NET/issues/371
615

716
v 3.3.1
817
-------
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.IO;
3+
using System.Text;
34
using System.Xml;
5+
using System.Xml.XPath;
46
using System.Xml.Xsl;
57

68
namespace FatturaElettronica.Extensions
@@ -13,22 +15,31 @@ public static void WriteHtml(this FatturaBase fattura, string outPath, string xs
1315
{
1416
throw new ArgumentNullException(nameof(outPath));
1517
}
16-
18+
1719
if (xslPath == null)
1820
{
1921
throw new ArgumentNullException(nameof(xslPath));
2022
}
2123

22-
var tempXml = Path.GetTempFileName();
23-
24-
using (var w = XmlWriter.Create(tempXml, new() {Indent = true}))
25-
{
26-
fattura.WriteXml(w);
27-
}
28-
2924
var xt = new XslCompiledTransform();
3025
xt.Load(xslPath);
31-
xt.Transform(tempXml, outPath);
26+
27+
using (var memoryStream = new MemoryStream())
28+
{
29+
using (var w = new XmlTextWriter(memoryStream, Encoding.UTF8) {Formatting = Formatting.Indented})
30+
{
31+
fattura.WriteXml(w);
32+
w.Flush();
33+
34+
memoryStream.Seek(0, SeekOrigin.Begin);
35+
36+
var xPathDocument = new XPathDocument(memoryStream);
37+
using (var writer = File.OpenWrite(outPath))
38+
{
39+
xt.Transform(xPathDocument, null, writer);
40+
}
41+
}
42+
}
3243
}
3344
}
3445
}

src/PackageInfo.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project DefaultTargets="Build"
22
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<Version>3.3.1</Version>
4+
<Version>3.3.2</Version>
55
<PackageId>FatturaElettronica.NET35</PackageId>
66
<PackageIcon>fattura_elettronica.png</PackageIcon>
77
<RepositoryType>git</RepositoryType>

0 commit comments

Comments
 (0)