Skip to content

Commit 073cfda

Browse files
committed
- Update dependencies to resolve issues with Vulnerabilities and Deprecated versions.
- Breaking Change: Updated to use System.Text.Json instead of Newtonsoft.Json which mainly impacts the ApacheFOPServerlessApiException class and client code that may attempt to use the raw Json for interrogation of errors.
1 parent c902bbf commit 073cfda

126 files changed

Lines changed: 80667 additions & 43543 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PdfTemplating.Common/PdfTemplating.XslFO.Common.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,22 @@
66
<Authors>BBernard / CajunCoding</Authors>
77
<Company>CajunCoding.com</Company>
88
<Description>This project contains the common interfaces and shared foundational classes for the PdfTemplating.XslFO projects. The PdfTemplating.XslFO projects are It is based on the Xsl-FO standard for rendering robust paged media outputs as PDF Documents from using a templating approach. They enable the use of Xslt or Razor Mvc templates combined with ApacheFOP.Serverless or Fonet rendering into Binary Pdf documents; and any combination between as well as custom implementations using these Common interfaces.</Description>
9-
<Version>3.1</Version>
9+
<Version>3.2</Version>
1010
<Copyright>Copyright © 2020</Copyright>
1111
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1212
<PackageProjectUrl>https://github.com/cajuncoding/PdfTemplating.XslFO</PackageProjectUrl>
1313
<RepositoryUrl>https://github.com/cajuncoding/PdfTemplating.XslFO</RepositoryUrl>
1414
<PackageTags>adobe acrobat pdf template razor xslt xslfo xsl-fo xsl fo portrait landscape fluid width apache fop apache-fop formatting objects itext itextsharp pdfsharp evopdf ironpdf spire freespire expertpdf</PackageTags>
1515
<PackageReleaseNotes>
16-
- Breaking Namespace changes for CustomExtensions to reduce risk of conflicts.
16+
- Update minimize depdency footprint moving non-critical extension code that are unnecessary for the libraries; now moved to separate project for example Apps to use.
1717

1818
Prior Release Notes:
19+
- Breaking Change: Namespace changes for CustomExtensions to reduce risk of conflicts.
1920
- Refactored Interfaces to better support Dependency Injection; some small breaking changes to method signatures.
2021
- Enhancements to enable the new Asp.NET Core Razor Renderer implementation.
2122
- Initial relase of the common interfaces.
2223
- Initial support for fully de-coupling the Templating and Rendering processes thereby enabling the new ApacheFOP.Serverless rendering approach without any dependency on the legacy Fonet (in-memory) rendering.
2324
</PackageReleaseNotes>
2425
</PropertyGroup>
2526

26-
<ItemGroup>
27-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
28-
</ItemGroup>
29-
3027
</Project>

PdfTemplating.Common/System.ExtensionMethods/PdfTemplating.SystemCustomExtensions.cs

Lines changed: 0 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ limitations under the License.
2929
using PdfTemplating.SystemCustomExtensions;
3030
using System.Globalization;
3131
using PdfTemplating.SystemXmlLinqCustomExtensions;
32-
using Newtonsoft.Json.Linq;
3332

3433
namespace PdfTemplating.SystemCustomExtensions
3534
{
@@ -218,115 +217,6 @@ public static object GetDefault(this Type type)
218217
}
219218
}
220219

221-
public static class SystemExceptionCustomExtensions
222-
{
223-
private const string _nestedExceptionFormatString = "[{0}] {1}";
224-
225-
/// <summary>
226-
/// Retrieve a string containing ALL descendent Exception Messages using the specified format string; traversing all nested exceptions as necessary.
227-
/// </summary>
228-
/// <param name="thisException"></param>
229-
/// <returns></returns>
230-
public static String GetMessagesRecursively(this Exception thisException)
231-
{
232-
StringBuilder stringBuilder = new StringBuilder();
233-
string exceptionMessage = String.Empty;
234-
235-
if (thisException != null)
236-
{
237-
exceptionMessage = TerminateMessageHelper(thisException.Message);
238-
stringBuilder.AppendFormat(_nestedExceptionFormatString, thisException.GetType().Name, exceptionMessage);
239-
240-
//Traverse all InnerExceptions
241-
Exception innerException = thisException.InnerException;
242-
while (innerException != null)
243-
{
244-
exceptionMessage = TerminateMessageHelper(innerException.Message);
245-
stringBuilder.AppendFormat(_nestedExceptionFormatString, innerException.GetType().Name, exceptionMessage);
246-
innerException = innerException.InnerException;
247-
}
248-
249-
//Handle New .Net 4.0 Aggregate Exception Type as a special Case because
250-
//AggregateExceptions contain a list of Exceptions thrown by background threads.
251-
if (thisException is AggregateException aggregateExc)
252-
{
253-
foreach (var exc in aggregateExc.InnerExceptions)
254-
{
255-
//exceptionMessage = TerminateMessageHelper(exc.Message);
256-
exceptionMessage = TerminateMessageHelper(exc.GetMessagesRecursively());
257-
stringBuilder.AppendFormat(_nestedExceptionFormatString, exc.GetType().Name, exceptionMessage);
258-
}
259-
}
260-
}
261-
262-
return stringBuilder.ToString();
263-
}
264-
265-
private static string TerminateMessageHelper(string message)
266-
{
267-
if (!string.IsNullOrEmpty(message) && !message.EndsWith(".") && !message.EndsWith(";"))
268-
{
269-
return string.Concat(message, ";");
270-
}
271-
272-
return message;
273-
}
274-
275-
/// <summary>
276-
/// Provides a simplified Json object model that can be safely used and serialized with no risk of
277-
/// recursive reference errors that the Exception class.
278-
/// </summary>
279-
/// <param name="exc"></param>
280-
/// <param name="includeStackTrace"></param>
281-
/// <returns></returns>
282-
public static JObject ToSimplifiedJObjectModel(this Exception exc, bool includeStackTrace = false)
283-
{
284-
var type = exc.GetType();
285-
var exceptionJson = JObject.FromObject(new
286-
{
287-
ExceptionType = type.FullName,
288-
ExceptionTypeName = type.Name,
289-
AllMessages = exc.GetMessagesRecursively(),
290-
Data = exc.Data,
291-
HResult = exc.HResult,
292-
Source = exc.Source,
293-
});
294-
295-
if (includeStackTrace)
296-
exceptionJson[nameof(exc.StackTrace)] = exc.StackTrace;
297-
298-
return exceptionJson;
299-
}
300-
301-
/// <summary>
302-
/// Safely convert the Exception to Json without issues relating to recursive references;
303-
/// handles all nested inner exceptions and ensures that we get all relevant data and messages with
304-
/// optional StackTraces included.
305-
/// </summary>
306-
/// <param name="exc"></param>
307-
/// <param name="includeStackTrace"></param>
308-
/// <returns></returns>
309-
public static string ToJson(this Exception exc, bool includeStackTrace = false)
310-
{
311-
//Simplify and map the Exception Model for Serialization...
312-
var exceptionJson = ToSimplifiedJObjectModel(exc, includeStackTrace);
313-
314-
var innerException = exc.InnerException;
315-
var parentExceptionJson = exceptionJson;
316-
while (innerException != null)
317-
{
318-
var newInnerException = ToSimplifiedJObjectModel(innerException, includeStackTrace);
319-
//Set the Inner Exception into the Parent...
320-
parentExceptionJson[nameof(exc.InnerException)] = newInnerException;
321-
//Now Re-set the Parent to the new Inner Exception, and see if there are any further Inner Exceptions to handle; so we keep crawling the tree...
322-
parentExceptionJson = newInnerException;
323-
innerException = innerException.InnerException;
324-
}
325-
326-
return exceptionJson.ToString();
327-
}
328-
}
329-
330220
public static class SystemStringCustomExtensions
331221
{
332222
/// <summary>
@@ -1667,81 +1557,6 @@ public static T[] Slice<T>(this T[] source, int start, int end)
16671557

16681558
#endregion
16691559
}
1670-
1671-
public static class SystemEventHandlerDelegateCustomExtensions
1672-
{
1673-
1674-
//Note: We do not implement overloads that take in only an Object param as teh sender because this lends to easy bugs since
1675-
// mistaking the EventHandler<T> as the sender object is easy and yields Runtime errors.
1676-
public static bool Raise(this EventHandler _this, object sender)
1677-
{
1678-
return _this.Raise(sender, null);
1679-
}
1680-
1681-
//Note: We do not implement overloads that take in only an Object param as teh sender because this lends to easy bugs since
1682-
// mistaking the EventHandler<T> as the sender object is easy and yields Runtime errors.
1683-
public static bool Raise(this EventHandler _this, object sender, EventArgs eventArgs)
1684-
{
1685-
if (_this != null)
1686-
{
1687-
_this(sender, eventArgs ?? EventArgs.Empty);
1688-
return true;
1689-
}
1690-
return false;
1691-
}
1692-
1693-
//Note: We do not implement overloads that take in only an Object param as teh sender because this lends to easy bugs since
1694-
// mistaking the EventHandler<T> as the sender object is easy and yields Runtime errors.
1695-
public static bool Raise(this EventHandler<EventArgs> _this, object sender)
1696-
{
1697-
return _this.Raise(sender, EventArgs.Empty);
1698-
}
1699-
1700-
//Note: We do not implement overloads that take in only an Object param as teh sender because this lends to easy bugs since
1701-
// mistaking the EventHandler<T> as the sender object is easy and yields Runtime errors.
1702-
public static bool Raise<TEventArgs>(this EventHandler<TEventArgs> _this, object sender) where TEventArgs : EventArgs
1703-
{
1704-
return _this.Raise<TEventArgs>(sender, null);
1705-
}
1706-
1707-
//Note: We do not implement overloads that take in only an Object param as teh sender because this lends to easy bugs since
1708-
// mistaking the EventHandler<T> as the sender object is easy and yields Runtime errors.
1709-
public static bool Raise<TEventArgs>(this EventHandler<TEventArgs> _this, object sender, TEventArgs eventArgs) where TEventArgs : EventArgs
1710-
{
1711-
try
1712-
{
1713-
if (_this != null)
1714-
{
1715-
_this(sender, eventArgs);
1716-
return true;
1717-
}
1718-
}
1719-
catch(Exception exc)
1720-
{
1721-
Debug.Write(exc.GetMessagesRecursively());
1722-
}
1723-
return false;
1724-
}
1725-
1726-
//public static EventHandler<TEventArgs> AddHandler<TEventArgs>(this EventHandler<TEventArgs> _this, EventHandler<TEventArgs> fnNewHandler) where TEventArgs : EventArgs
1727-
//{
1728-
// if (fnNewHandler != null)
1729-
// {
1730-
// _this += fnNewHandler;
1731-
// }
1732-
// return _this;
1733-
//}
1734-
1735-
//public static EventHandler<TEventArgs> RemoveHandler<TEventArgs>(this EventHandler<TEventArgs> _this, EventHandler<TEventArgs> fnNewHandler) where TEventArgs : EventArgs
1736-
//{
1737-
// if (fnNewHandler != null)
1738-
// {
1739-
// _this -= fnNewHandler;
1740-
// }
1741-
// return _this;
1742-
//}
1743-
}
1744-
17451560
}
17461561

17471562

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<RootNamespace>PdfTemplating.WebApp.Common</RootNamespace>
6+
<Authors>BBernard / CajunCoding</Authors>
7+
<Company>CajunCoding.com</Company>
8+
<Description>This project contains the common interfaces and shared foundational classes for the Example Web Apps to use that are not dependencies for the libraries published to Nuget.</Description>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="System.Text.Json" Version="9.0.7" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
using System;
2+
using System.Text;
3+
using System.Text.Json;
4+
using System.Text.Json.Nodes;
5+
6+
namespace PdfTemplating.WebApp.Common
7+
{
8+
public static class SystemExceptionCustomExtensions
9+
{
10+
private const string _nestedExceptionFormatString = "[{0}] {1}";
11+
12+
/// <summary>
13+
/// Retrieve a string containing ALL descendent Exception Messages using the specified format string; traversing all nested exceptions as necessary.
14+
/// </summary>
15+
/// <param name="thisException"></param>
16+
/// <returns></returns>
17+
public static String GetMessagesRecursively(this Exception thisException)
18+
{
19+
StringBuilder stringBuilder = new StringBuilder();
20+
string exceptionMessage = String.Empty;
21+
22+
if (thisException != null)
23+
{
24+
exceptionMessage = TerminateMessageHelper(thisException.Message);
25+
stringBuilder.AppendFormat(_nestedExceptionFormatString, thisException.GetType().Name, exceptionMessage);
26+
27+
//Traverse all InnerExceptions
28+
Exception innerException = thisException.InnerException;
29+
while (innerException != null)
30+
{
31+
exceptionMessage = TerminateMessageHelper(innerException.Message);
32+
stringBuilder.AppendFormat(_nestedExceptionFormatString, innerException.GetType().Name, exceptionMessage);
33+
innerException = innerException.InnerException;
34+
}
35+
36+
//Handle New .Net 4.0 Aggregate Exception Type as a special Case because
37+
//AggregateExceptions contain a list of Exceptions thrown by background threads.
38+
if (thisException is AggregateException aggregateExc)
39+
{
40+
foreach (var exc in aggregateExc.InnerExceptions)
41+
{
42+
//exceptionMessage = TerminateMessageHelper(exc.Message);
43+
exceptionMessage = TerminateMessageHelper(exc.GetMessagesRecursively());
44+
stringBuilder.AppendFormat(_nestedExceptionFormatString, exc.GetType().Name, exceptionMessage);
45+
}
46+
}
47+
}
48+
49+
return stringBuilder.ToString();
50+
}
51+
52+
private static string TerminateMessageHelper(string message)
53+
{
54+
if (!string.IsNullOrEmpty(message) && !message.EndsWith(".") && !message.EndsWith(";"))
55+
{
56+
return string.Concat(message, ";");
57+
}
58+
59+
return message;
60+
}
61+
62+
/// <summary>
63+
/// Provides a simplified Json object model that can be safely used and serialized with no risk of
64+
/// recursive reference errors that the Exception class.
65+
/// </summary>
66+
/// <param name="exc"></param>
67+
/// <param name="includeStackTrace"></param>
68+
/// <returns></returns>
69+
public static JsonObject ToSimplifiedJsonObjectModel(this Exception exc, bool includeStackTrace = false)
70+
{
71+
var type = exc.GetType();
72+
var exceptionJson = JsonSerializer.SerializeToNode(new
73+
{
74+
ExceptionType = type.FullName,
75+
ExceptionTypeName = type.Name,
76+
AllMessages = exc.GetMessagesRecursively(),
77+
Data = exc.Data,
78+
HResult = exc.HResult,
79+
Source = exc.Source,
80+
});
81+
82+
if (includeStackTrace)
83+
exceptionJson[nameof(exc.StackTrace)] = exc.StackTrace;
84+
85+
return (JsonObject)exceptionJson;
86+
}
87+
88+
/// <summary>
89+
/// Safely convert the Exception to Json without issues relating to recursive references;
90+
/// handles all nested inner exceptions and ensures that we get all relevant data and messages with
91+
/// optional StackTraces included.
92+
/// </summary>
93+
/// <param name="exc"></param>
94+
/// <param name="includeStackTrace"></param>
95+
/// <returns></returns>
96+
public static string ToJson(this Exception exc, bool includeStackTrace = false)
97+
{
98+
//Simplify and map the Exception Model for Serialization...
99+
var exceptionJson = ToSimplifiedJsonObjectModel(exc, includeStackTrace);
100+
101+
var innerException = exc.InnerException;
102+
var parentExceptionJson = exceptionJson;
103+
while (innerException != null)
104+
{
105+
var newInnerException = ToSimplifiedJsonObjectModel(innerException, includeStackTrace);
106+
//Set the Inner Exception into the Parent...
107+
parentExceptionJson[nameof(exc.InnerException)] = newInnerException;
108+
//Now Re-set the Parent to the new Inner Exception, and see if there are any further Inner Exceptions to handle; so we keep crawling the tree...
109+
parentExceptionJson = newInnerException;
110+
innerException = innerException.InnerException;
111+
}
112+
113+
return exceptionJson.ToString();
114+
}
115+
}
116+
}

PdfTemplating.XslFO.Razor.AspNetCoreMvc/PdfTemplating.XslFO.Razor.AspNetCoreMvc.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
<Authors>BBernard / CajunCoding</Authors>
88
<Company>CajunCoding.com</Company>
99
<Description>This is a C#.Net solution that provides the capability to easily generate PDF documents with a templating approach using Razor MVC templates; as opposed to extremely complex code based approaches most libraries provide. It's based on the Xsl-FO standard for rendering robust paged media outputs as PDF Documents.</Description>
10-
<Version>3.1</Version>
10+
<Version>3.2</Version>
1111
<Copyright>Copyright © 2022</Copyright>
1212
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1313
<PackageProjectUrl>https://github.com/cajuncoding/PdfTemplating.XslFO</PackageProjectUrl>
1414
<RepositoryUrl>https://github.com/cajuncoding/PdfTemplating.XslFO</RepositoryUrl>
1515
<PackageTags>adobe acrobat pdf template razor xslt xslfo xsl-fo xsl fo portrait landscape fluid width apache fop apache-fop formatting objects itext itextsharp pdfsharp evopdf ironpdf spire freespire expertpdf</PackageTags>
1616
<PackageReleaseNotes>
17-
- Breaking Namespace changes for CustomExtensions to reduce risk of conflicts.
17+
- Update dependencies to resolve issues with Vulnerabilities and Deprecated versions.
1818

1919
Prior Release Notes
20+
- Breaking Change: Namespace changes for CustomExtensions to reduce risk of conflicts.
2021
- Updated to sync with new v3.0 Common and new v3 due to breaking changes.
2122
- Code cleanup and simplifcation; small breaking change to no longer need Generic type.
2223
- Initial relase of fully functioning Razor Template Renderer for Asp.NET Core; generally mirroring functionality fo the original Asp.NET MVC (legacy) version but now fully Async along with a few deviations necessiated by .NET Core best practices.
@@ -25,7 +26,8 @@
2526
</PropertyGroup>
2627

2728
<ItemGroup>
28-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
29+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.0" />
30+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
2931
</ItemGroup>
3032

3133
<ItemGroup>

0 commit comments

Comments
 (0)