Browse Source

Fixed compatibility with .NET Standard 2.0.

Marcin Ziąbek 1 year ago
parent
commit
df8045a04b

+ 0 - 16
Source/QuestPDF/CompatibilitySuppressions.xml

@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
-<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-  <Suppression>
-    <DiagnosticId>CP0002</DiagnosticId>
-    <Target>M:QuestPDF.Fluent.ElementExtensions.Element(QuestPDF.Infrastructure.IContainer,System.Action{QuestPDF.Infrastructure.IContainer},System.String,System.String,System.Int32)</Target>
-    <Left>lib/netstandard2.0/QuestPDF.dll</Left>
-    <Right>lib/net6.0/QuestPDF.dll</Right>
-  </Suppression>
-  <Suppression>
-    <DiagnosticId>CP0002</DiagnosticId>
-    <Target>M:QuestPDF.Fluent.ElementExtensions.Element(QuestPDF.Infrastructure.IContainer,System.Func{QuestPDF.Infrastructure.IContainer,QuestPDF.Infrastructure.IContainer},System.String,System.String,System.Int32)</Target>
-    <Left>lib/netstandard2.0/QuestPDF.dll</Left>
-    <Right>lib/net6.0/QuestPDF.dll</Right>
-  </Suppression>
-</Suppressions>

+ 1 - 14
Source/QuestPDF/Fluent/ElementExtensions.cs

@@ -1,5 +1,4 @@
 using System;
 using System;
-using System.Net.Mime;
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using QuestPDF.Drawing.Exceptions;
 using QuestPDF.Drawing.Exceptions;
 using QuestPDF.Elements;
 using QuestPDF.Elements;
@@ -50,18 +49,12 @@ namespace QuestPDF.Fluent
         /// <param name="handler">A delegate that takes the current container and populates it with content.</param>
         /// <param name="handler">A delegate that takes the current container and populates it with content.</param>
         public static void Element(
         public static void Element(
             this IContainer parent, 
             this IContainer parent, 
-            Action<IContainer> handler, 
-#if NETCOREAPP3_0_OR_GREATER
+            Action<IContainer> handler,
             [CallerArgumentExpression("handler")] string handlerName = null,
             [CallerArgumentExpression("handler")] string handlerName = null,
-#endif
             [CallerMemberName] string parentName = "",
             [CallerMemberName] string parentName = "",
             [CallerFilePath] string sourceFilePath = "",
             [CallerFilePath] string sourceFilePath = "",
             [CallerLineNumber] int sourceLineNumber = 0)
             [CallerLineNumber] int sourceLineNumber = 0)
         {
         {
-#if !NETCOREAPP3_0_OR_GREATER
-            const string handlerName = "Unknown function";
-#endif
-            
             var handlerContainer = parent
             var handlerContainer = parent
                 .Container()
                 .Container()
                 .Element(new SourceCodePointer
                 .Element(new SourceCodePointer
@@ -88,17 +81,11 @@ namespace QuestPDF.Fluent
         public static IContainer Element(
         public static IContainer Element(
             this IContainer parent, 
             this IContainer parent, 
             Func<IContainer, IContainer> handler,
             Func<IContainer, IContainer> handler,
-#if NETCOREAPP3_0_OR_GREATER
             [CallerArgumentExpression("handler")] string handlerName = null,
             [CallerArgumentExpression("handler")] string handlerName = null,
-#endif
             [CallerMemberName] string parentName = "",
             [CallerMemberName] string parentName = "",
             [CallerFilePath] string sourceFilePath = "",
             [CallerFilePath] string sourceFilePath = "",
             [CallerLineNumber] int sourceLineNumber = 0)
             [CallerLineNumber] int sourceLineNumber = 0)
         {
         {
-#if !NETCOREAPP3_0_OR_GREATER
-            const string handlerName = "Unknown function";
-#endif
-            
             var handlerContainer = parent
             var handlerContainer = parent
                 .Element(new SourceCodePointer
                 .Element(new SourceCodePointer
                 {
                 {

+ 17 - 0
Source/QuestPDF/Helpers/CallerArgumentExpression.cs

@@ -0,0 +1,17 @@
+#if !NET6_0_OR_GREATER
+
+namespace System.Runtime.CompilerServices
+{
+    [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
+    internal sealed class CallerArgumentExpressionAttribute : Attribute
+    {
+        public CallerArgumentExpressionAttribute(string parameterName)
+        {
+            ParameterName = parameterName;
+        }
+
+        public string ParameterName { get; }
+    }
+}
+
+#endif

+ 1 - 0
Source/QuestPDF/Resources/ReleaseNotes.txt

@@ -24,3 +24,4 @@ Bug Fixes:
 
 
 Version 2024.6.1
 Version 2024.6.1
 - Text element: improved the default sizing behavior for the Text element. Now, when the text is empty, it works more consistently by taking up zero width while still reserving vertical space based on the font size.
 - Text element: improved the default sizing behavior for the Text element. Now, when the text is empty, it works more consistently by taking up zero width while still reserving vertical space based on the font size.
+- Fixed compatibility with .NET Standard 2.0.