Преглед на файлове

Refactor classes to be sealed/static for better encapsulation and performance

Marcin Ziąbek преди 9 месеца
родител
ревизия
3d31821164
променени са 53 файла, в които са добавени 90 реда и са изтрити 90 реда
  1. 16 16
      Source/QuestPDF/Companion/CompanionModels.cs
  2. 1 1
      Source/QuestPDF/Companion/CompanionService.cs
  3. 3 3
      Source/QuestPDF/Drawing/CompanionCanvas.cs
  4. 1 1
      Source/QuestPDF/Drawing/Exceptions/DocumentComposeException.cs
  5. 1 1
      Source/QuestPDF/Drawing/Exceptions/DocumentDrawingException.cs
  6. 1 1
      Source/QuestPDF/Drawing/Exceptions/DocumentLayoutException.cs
  7. 1 1
      Source/QuestPDF/Drawing/Exceptions/InitializationException.cs
  8. 1 1
      Source/QuestPDF/Drawing/Proxy/LayoutOverflowVisualization.cs
  9. 1 1
      Source/QuestPDF/Drawing/Proxy/LayoutProxy.cs
  10. 1 1
      Source/QuestPDF/Drawing/Proxy/OverflowDebuggingProxy.cs
  11. 1 1
      Source/QuestPDF/Drawing/Proxy/SnapshotRecorder.cs
  12. 1 1
      Source/QuestPDF/Drawing/Proxy/TreeTraversal.cs
  13. 1 1
      Source/QuestPDF/Drawing/ProxyCanvas.cs
  14. 1 1
      Source/QuestPDF/Drawing/SnapshotRecorderCanvas.cs
  15. 1 1
      Source/QuestPDF/Elements/Decoration.cs
  16. 1 1
      Source/QuestPDF/Elements/Dynamic.cs
  17. 1 1
      Source/QuestPDF/Elements/DynamicImage.cs
  18. 1 1
      Source/QuestPDF/Elements/DynamicSvgImage.cs
  19. 2 2
      Source/QuestPDF/Elements/MultiColumn.cs
  20. 2 2
      Source/QuestPDF/Elements/ShowIf.cs
  21. 1 1
      Source/QuestPDF/Elements/Shrink.cs
  22. 1 1
      Source/QuestPDF/Elements/SourceCodePointer.cs
  23. 1 1
      Source/QuestPDF/Elements/SvgImage.cs
  24. 1 1
      Source/QuestPDF/Elements/SvgPath.cs
  25. 1 1
      Source/QuestPDF/Elements/Text/Items/TextBlockParagraphSpacing.cs
  26. 1 1
      Source/QuestPDF/Fluent/ColumnExtensions.cs
  27. 1 1
      Source/QuestPDF/Fluent/DecorationExtensions.cs
  28. 6 6
      Source/QuestPDF/Fluent/DocumentOperation.cs
  29. 1 1
      Source/QuestPDF/Fluent/GridExtensions.cs
  30. 2 2
      Source/QuestPDF/Fluent/ImageExtensions.cs
  31. 1 1
      Source/QuestPDF/Fluent/InlinedExtensions.cs
  32. 1 1
      Source/QuestPDF/Fluent/LayerExtensions.cs
  33. 1 1
      Source/QuestPDF/Fluent/MinimalApi.cs
  34. 1 1
      Source/QuestPDF/Fluent/MultiColumnExtensions.cs
  35. 1 1
      Source/QuestPDF/Fluent/PageExtensions.cs
  36. 1 1
      Source/QuestPDF/Fluent/RowExtensions.cs
  37. 1 1
      Source/QuestPDF/Fluent/SvgExtensions.cs
  38. 3 3
      Source/QuestPDF/Fluent/TableExtensions.cs
  39. 3 3
      Source/QuestPDF/Fluent/TextExtensions.cs
  40. 1 1
      Source/QuestPDF/Helpers/Fonts.cs
  41. 1 1
      Source/QuestPDF/Helpers/NativeDependencyCompatibilityChecker.cs
  42. 1 1
      Source/QuestPDF/Helpers/PageSizes.cs
  43. 1 1
      Source/QuestPDF/Infrastructure/DocumentMetadata.cs
  44. 1 1
      Source/QuestPDF/Infrastructure/DocumentSettings.cs
  45. 1 1
      Source/QuestPDF/Infrastructure/IDynamicComponent.cs
  46. 1 1
      Source/QuestPDF/Infrastructure/Image.cs
  47. 1 1
      Source/QuestPDF/Infrastructure/ImageGenerationSettings.cs
  48. 1 1
      Source/QuestPDF/Infrastructure/SvgImage.cs
  49. 8 8
      Source/QuestPDF/Qpdf/JobConfiguration.cs
  50. 1 1
      Source/QuestPDF/Qpdf/MimeHelper.cs
  51. 1 1
      Source/QuestPDF/Qpdf/QpdfAPI.cs
  52. 2 2
      Source/QuestPDF/Qpdf/SimpleJsonSerializer.cs
  53. 1 1
      Source/QuestPDF/Skia/SkText.cs

+ 16 - 16
Source/QuestPDF/Companion/CompanionModels.cs

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Companion
 {
-    class PageSnapshotIndex
+    sealed class PageSnapshotIndex
     {
         public int PageIndex { get; set; }
         public int ZoomLevel { get; set; }
@@ -15,7 +15,7 @@ namespace QuestPDF.Companion
     
     static internal class CompanionCommands
     {
-        internal class Notify
+        internal sealed class Notify
         {
             private static readonly string CurrentClientId = Guid.NewGuid().ToString();
             
@@ -23,19 +23,19 @@ namespace QuestPDF.Companion
             public LicenseType License => Settings.License ?? LicenseType.Community;
         }
         
-        internal class UpdateDocumentStructure
+        internal sealed class UpdateDocumentStructure
         {
             public bool IsDocumentHotReloaded { get; set; }
             public ICollection<PageSize> Pages { get; set; }
             public DocumentHierarchyElement Hierarchy { get; set; }
     
-            public class PageSize
+            public sealed class PageSize
             {
                 public float Width { get; set; }
                 public float Height { get; set; }
             }
             
-            internal class DocumentHierarchyElement
+            internal sealed class DocumentHierarchyElement
             {
                 internal Element Element { get; set; }
                 
@@ -50,7 +50,7 @@ namespace QuestPDF.Companion
                 public ICollection<DocumentHierarchyElement> Children { get; set; }
             }
 
-            internal class PageLocation
+            internal sealed class PageLocation
             {
                 public int PageNumber { get; init; }
                 public float Left { get; init; }
@@ -59,7 +59,7 @@ namespace QuestPDF.Companion
                 public float Bottom { get; init; }
             }
 
-            internal class LayoutErrorMeasurement
+            internal sealed class LayoutErrorMeasurement
             {
                 public int PageNumber { get; set; }
                 public ElementSize? AvailableSpace { get; set; }
@@ -69,18 +69,18 @@ namespace QuestPDF.Companion
                 public bool IsLayoutErrorRootCause { get; set; }
             }
             
-            internal class SourceCodePath
+            internal sealed class SourceCodePath
             {
                 public string FilePath { get; set; }
                 public int LineNumber { get; set; }
             }
         }
         
-        internal class ProvideRenderedDocumentPage
+        internal sealed class ProvideRenderedDocumentPage
         {
             public ICollection<RenderedPage> Pages { get; set; }
 
-            internal class RenderedPage
+            internal sealed class RenderedPage
             {
                 public int PageIndex { get; set; }
                 public int ZoomLevel { get; set; }
@@ -88,11 +88,11 @@ namespace QuestPDF.Companion
             }
         }
         
-        internal class ShowGenericException
+        internal sealed class ShowGenericException
         {
             public GenericExceptionDetails Exception { get; set; }
             
-            internal class GenericExceptionDetails
+            internal sealed class GenericExceptionDetails
             {
                 public string Type { get; set; }
                 public string Message { get; set; }
@@ -100,7 +100,7 @@ namespace QuestPDF.Companion
                 public GenericExceptionDetails? InnerException { get; set; }
             }
             
-            internal class StackFrame
+            internal sealed class StackFrame
             {
                 public string CodeLocation { get; set; }
                 public string? FileName { get; set; }
@@ -108,19 +108,19 @@ namespace QuestPDF.Companion
             }
         }
 
-        internal class ElementSize
+        internal sealed class ElementSize
         {
             public float Width { get; set; }
             public float Height { get; set; }
         }
         
-        internal class ElementProperty
+        internal sealed class ElementProperty
         {
             public string Label { get; set; }
             public string Value { get; set; }
         }
 
-        internal class GetVersionCommandResponse
+        internal sealed class GetVersionCommandResponse
         {
             public ICollection<int> SupportedVersions { get; set; }
         }

+ 1 - 1
Source/QuestPDF/Companion/CompanionService.cs

@@ -14,7 +14,7 @@ using QuestPDF.Drawing;
 
 namespace QuestPDF.Companion
 {
-    internal class CompanionService
+    internal sealed class CompanionService
     {
         private int Port { get; }
         private HttpClient HttpClient { get; }

+ 3 - 3
Source/QuestPDF/Drawing/CompanionCanvas.cs

@@ -6,7 +6,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Drawing
 {
-    internal class CompanionPageSnapshot
+    internal sealed class CompanionPageSnapshot
     {
         public SkPicture Picture { get; set; }
         public Size Size { get; set; }
@@ -29,14 +29,14 @@ namespace QuestPDF.Drawing
         }
     }
     
-    internal class CompanionDocumentSnapshot
+    internal sealed class CompanionDocumentSnapshot
     {
         public ICollection<CompanionPageSnapshot> Pictures { get; set; }
         public bool DocumentContentHasLayoutOverflowIssues { get; set; }
         public CompanionCommands.UpdateDocumentStructure.DocumentHierarchyElement Hierarchy { get; set; }
     }
     
-    internal class CompanionCanvas : SkiaCanvasBase, IDisposable
+    internal sealed class CompanionCanvas : SkiaCanvasBase, IDisposable
     {
         private SkPictureRecorder? PictureRecorder { get; set; }
         private Size? CurrentPageSize { get; set; }

+ 1 - 1
Source/QuestPDF/Drawing/Exceptions/DocumentComposeException.cs

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Drawing.Exceptions
 {
-    public class DocumentComposeException : Exception
+    public sealed class DocumentComposeException : Exception
     {
         internal DocumentComposeException(string message) : base(message)
         {

+ 1 - 1
Source/QuestPDF/Drawing/Exceptions/DocumentDrawingException.cs

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Drawing.Exceptions
 {
-    public class DocumentDrawingException : Exception
+    public sealed class DocumentDrawingException : Exception
     {
         internal DocumentDrawingException(string message) : base(message)
         {

+ 1 - 1
Source/QuestPDF/Drawing/Exceptions/DocumentLayoutException.cs

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Drawing.Exceptions
 {
-    public class DocumentLayoutException : Exception
+    public sealed class DocumentLayoutException : Exception
     {
         internal DocumentLayoutException(string message) : base(message)
         {

+ 1 - 1
Source/QuestPDF/Drawing/Exceptions/InitializationException.cs

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Drawing.Exceptions
 {
-    public class InitializationException : Exception
+    public sealed class InitializationException : Exception
     {
         internal InitializationException(string message) : base(message)
         {

+ 1 - 1
Source/QuestPDF/Drawing/Proxy/LayoutOverflowVisualization.cs

@@ -5,7 +5,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Drawing.Proxy;
 
-internal class LayoutOverflowVisualization : ElementProxy, IContentDirectionAware
+internal sealed class LayoutOverflowVisualization : ElementProxy, IContentDirectionAware
 {
     private const float BorderThickness = 1.5f;
     private readonly Color LineColor = Colors.Red.Medium;

+ 1 - 1
Source/QuestPDF/Drawing/Proxy/LayoutProxy.cs

@@ -8,7 +8,7 @@ using SvgImage = QuestPDF.Elements.SvgImage;
 
 namespace QuestPDF.Drawing.Proxy;
 
-internal class LayoutProxy : ElementProxy
+internal sealed class LayoutProxy : ElementProxy
 {
     public List<CompanionCommands.UpdateDocumentStructure.PageLocation> Snapshots { get; } = new();
     public List<CompanionCommands.UpdateDocumentStructure.LayoutErrorMeasurement> LayoutErrorMeasurements { get; } = new();

+ 1 - 1
Source/QuestPDF/Drawing/Proxy/OverflowDebuggingProxy.cs

@@ -2,7 +2,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Drawing.Proxy;
 
-internal class OverflowDebuggingProxy : ElementProxy
+internal sealed class OverflowDebuggingProxy : ElementProxy
 {
     public bool IsMeasuring { get; private set; } = true;
     

+ 1 - 1
Source/QuestPDF/Drawing/Proxy/SnapshotRecorder.cs

@@ -6,7 +6,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Drawing.Proxy;
 
-internal class SnapshotRecorder : ElementProxy, IDisposable
+internal sealed class SnapshotRecorder : ElementProxy, IDisposable
 {
     SnapshotRecorderCanvas RecorderCanvas { get; } = new();
     Dictionary<(int pageNumber, float availableWidth, float availableHeight), SpacePlan> MeasureCache { get; } = new();

+ 1 - 1
Source/QuestPDF/Drawing/Proxy/TreeTraversal.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Drawing.Proxy;
 
-internal class TreeNode<T>
+internal sealed class TreeNode<T>
 {
     public T Value { get; }
     public TreeNode<T>? Parent { get; set; }

+ 1 - 1
Source/QuestPDF/Drawing/ProxyCanvas.cs

@@ -4,7 +4,7 @@ using QuestPDF.Skia.Text;
 
 namespace QuestPDF.Drawing;
 
-internal class ProxyCanvas : ICanvas
+internal sealed class ProxyCanvas : ICanvas
 {
     public ICanvas Target { get; set; }
 

+ 1 - 1
Source/QuestPDF/Drawing/SnapshotRecorderCanvas.cs

@@ -1,6 +1,6 @@
 namespace QuestPDF.Drawing;
 
-internal class SnapshotRecorderCanvas : SkiaCanvasBase
+internal sealed class SnapshotRecorderCanvas : SkiaCanvasBase
 {
     public override void BeginDocument()
     {

+ 1 - 1
Source/QuestPDF/Elements/Decoration.cs

@@ -6,7 +6,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class DecorationElementLayout
+    internal sealed class DecorationElementLayout
     {
         public ItemCommand Before { get; set; }
         public ItemCommand Content { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/Dynamic.cs

@@ -102,7 +102,7 @@ namespace QuestPDF.Elements
     /// <summary>
     /// Stores all contextual information available for the dynamic component.
     /// </summary>
-    public class DynamicContext
+    public sealed class DynamicContext
     {
         internal IPageContext PageContext { get; set; }
         internal ICanvas Canvas { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/DynamicImage.cs

@@ -9,7 +9,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Elements
 {
-    public class GenerateDynamicImageDelegatePayload
+    public sealed class GenerateDynamicImageDelegatePayload
     {
         public Size AvailableSpace { get; set; }
         public ImageSize ImageSize { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/DynamicSvgImage.cs

@@ -9,7 +9,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Elements;
 
-internal class DynamicSvgImage : Element, IStateful, IDisposable
+internal sealed class DynamicSvgImage : Element, IStateful, IDisposable
 {
     public GenerateDynamicSvgDelegate SvgSource { get; set; }
 

+ 2 - 2
Source/QuestPDF/Elements/MultiColumn.cs

@@ -10,7 +10,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements;
 
-internal class MultiColumnChildDrawingObserver : ElementProxy
+internal sealed class MultiColumnChildDrawingObserver : ElementProxy
 {
     public bool HasBeenDrawn => ChildStateBeforeDrawingOperation != null;
     public object? ChildStateBeforeDrawingOperation { get; private set; }
@@ -42,7 +42,7 @@ internal class MultiColumnChildDrawingObserver : ElementProxy
     }
 }
 
-internal class MultiColumn : Element, IContentDirectionAware
+internal sealed class MultiColumn : Element, IContentDirectionAware
 {
     // items
     internal Element Content { get; set; } = Empty.Instance;

+ 2 - 2
Source/QuestPDF/Elements/ShowIf.cs

@@ -4,13 +4,13 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements;
 
-public class ShowIfContext
+public sealed class ShowIfContext
 {
     public int PageNumber { get; internal set; }
     public int TotalPages { get; internal set; }
 }
 
-internal class ShowIf : ContainerElement
+internal sealed class ShowIf : ContainerElement
 {
     public Predicate<ShowIfContext> VisibilityPredicate { get; set; }
     

+ 1 - 1
Source/QuestPDF/Elements/Shrink.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Shrink : ContainerElement, IContentDirectionAware
+    internal sealed class Shrink : ContainerElement, IContentDirectionAware
     {
         public bool Vertical { get; set; }
         public bool Horizontal { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/SourceCodePointer.cs

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements;
 
-internal class SourceCodePointer : ContainerElement
+internal sealed class SourceCodePointer : ContainerElement
 {
     public string MethodName { get; set; }
     public string CalledFrom { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/SvgImage.cs

@@ -6,7 +6,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Elements;
 
-internal class SvgImage : Element, IStateful, IDisposable
+internal sealed class SvgImage : Element, IStateful, IDisposable
 {
     public Infrastructure.SvgImage Image { get; set; }
     

+ 1 - 1
Source/QuestPDF/Elements/SvgPath.cs

@@ -5,7 +5,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Elements;
 
-internal class SvgPath : Element, IStateful
+internal sealed class SvgPath : Element, IStateful
 {
     public string Path { get; set; } = string.Empty;
     public Color FillColor { get; set; } = Colors.Black;

+ 1 - 1
Source/QuestPDF/Elements/Text/Items/TextBlockParagraphSpacing.cs

@@ -1,6 +1,6 @@
 namespace QuestPDF.Elements.Text.Items;
 
-internal class TextBlockParagraphSpacing : ITextBlockItem
+internal sealed class TextBlockParagraphSpacing : ITextBlockItem
 {
     public float Width { get; }
     public float Height { get; }

+ 1 - 1
Source/QuestPDF/Fluent/ColumnExtensions.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class ColumnDescriptor
+    public sealed class ColumnDescriptor
     {
         internal Column Column { get; } = new();
 

+ 1 - 1
Source/QuestPDF/Fluent/DecorationExtensions.cs

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class DecorationDescriptor
+    public sealed class DecorationDescriptor
     {
         internal Decoration Decoration { get; } = new Decoration();
         

+ 6 - 6
Source/QuestPDF/Fluent/DocumentOperation.cs

@@ -8,12 +8,12 @@ namespace QuestPDF.Fluent;
 /// <summary>
 /// Provides functionality for performing various operations on PDF documents, including loading, merging, overlaying, underlaying, selecting specific pages, adding attachments, and applying encryption settings.
 /// </summary>
-public class DocumentOperation
+public sealed class DocumentOperation
 {
     /// <summary>
     /// Represents configuration options for applying an overlay or underlay to a PDF document using qpdf.
     /// </summary>
-    public class LayerConfiguration
+    public sealed class LayerConfiguration
     {
         /// <summary>
         /// The file path of the overlay or underlay PDF file to be used.
@@ -70,7 +70,7 @@ public class DocumentOperation
         Unspecified
     }
     
-    public class DocumentAttachment
+    public sealed class DocumentAttachment
     {
         /// <summary>
         /// Sets the key for the attachment, specific to the PDF format.
@@ -139,7 +139,7 @@ public class DocumentOperation
         public string OwnerPassword { get; set; }
     }
     
-    public class Encryption40Bit : EncryptionBase
+    public sealed class Encryption40Bit : EncryptionBase
     {
         /// <include file='../Resources/Documentation.xml' path='documentation/doc[@for="documentOperation.encryption.allow.annotation"]/*' />
         public bool AllowAnnotation { get; set; } = true;
@@ -154,7 +154,7 @@ public class DocumentOperation
         public bool AllowPrinting { get; set; } = true;
     }
 
-    public class Encryption128Bit : EncryptionBase
+    public sealed class Encryption128Bit : EncryptionBase
     {
         /// <include file='../Resources/Documentation.xml' path='documentation/doc[@for="documentOperation.encryption.allow.annotation"]/*' />
         public bool AllowAnnotation { get; set; } = true;
@@ -175,7 +175,7 @@ public class DocumentOperation
         public bool EncryptMetadata { get; set; } = true;
     }
 
-    public class Encryption256Bit : EncryptionBase
+    public sealed class Encryption256Bit : EncryptionBase
     {
         /// <include file='../Resources/Documentation.xml' path='documentation/doc[@for="documentOperation.encryption.allow.annotation"]/*' />
         public bool AllowAnnotation { get; set; } = true;

+ 1 - 1
Source/QuestPDF/Fluent/GridExtensions.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class GridDescriptor
+    public sealed class GridDescriptor
     {
         internal Grid Grid { get; } = new Grid();
         

+ 2 - 2
Source/QuestPDF/Fluent/ImageExtensions.cs

@@ -6,7 +6,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class DynamicImageDescriptor
+    public sealed class DynamicImageDescriptor
     {
         private Elements.DynamicImage ImageElement { get; }
         
@@ -37,7 +37,7 @@ namespace QuestPDF.Fluent
         }
     }
     
-    public class ImageDescriptor
+    public sealed class ImageDescriptor
     {
         private Elements.Image ImageElement { get; }
         private AspectRatio AspectRatioElement { get; }

+ 1 - 1
Source/QuestPDF/Fluent/InlinedExtensions.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class InlinedDescriptor
+    public sealed class InlinedDescriptor
     {
         internal Inlined Inlined { get; } = new Inlined();
         

+ 1 - 1
Source/QuestPDF/Fluent/LayerExtensions.cs

@@ -6,7 +6,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class LayersDescriptor
+    public sealed class LayersDescriptor
     {
         internal Layers Layers { get; } = new Layers();
         

+ 1 - 1
Source/QuestPDF/Fluent/MinimalApi.cs

@@ -5,7 +5,7 @@ using QuestPDF.Skia;
 
 namespace QuestPDF.Fluent
 {
-    public class Document : IDocument
+    public sealed class Document : IDocument
     {
         static Document()
         {

+ 1 - 1
Source/QuestPDF/Fluent/MultiColumnExtensions.cs

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent;
 
-public class MultiColumnDescriptor
+public sealed class MultiColumnDescriptor
 {
     internal MultiColumn MultiColumn { get; } = new MultiColumn();
         

+ 1 - 1
Source/QuestPDF/Fluent/PageExtensions.cs

@@ -7,7 +7,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class PageDescriptor
+    public sealed class PageDescriptor
     {
         internal Page Page { get; } = new Page();
 

+ 1 - 1
Source/QuestPDF/Fluent/RowExtensions.cs

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class RowDescriptor
+    public sealed class RowDescriptor
     {
         internal Row Row { get; } = new();
 

+ 1 - 1
Source/QuestPDF/Fluent/SvgExtensions.cs

@@ -14,7 +14,7 @@ namespace QuestPDF.Fluent;
 /// <returns>An SVG format compatible text.</returns>
 public delegate string? GenerateDynamicSvgDelegate(Size size);
 
-public class SvgImageDescriptor
+public sealed class SvgImageDescriptor
 {
     private Elements.SvgImage ImageElement { get; }
     private AspectRatio AspectRatioElement { get; }

+ 3 - 3
Source/QuestPDF/Fluent/TableExtensions.cs

@@ -8,7 +8,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Fluent
 {
-    public class TableColumnsDefinitionDescriptor
+    public sealed class TableColumnsDefinitionDescriptor
     {
         internal List<TableColumnDefinition> Columns { get; } = new();
         
@@ -41,7 +41,7 @@ namespace QuestPDF.Fluent
         }
     }
 
-    public class TableCellDescriptor
+    public sealed class TableCellDescriptor
     {
         private ICollection<TableCell> Cells { get; }
 
@@ -62,7 +62,7 @@ namespace QuestPDF.Fluent
         }
     }
     
-    public class TableDescriptor
+    public sealed class TableDescriptor
     {
         private Table HeaderTable { get; } = new();
         private Table ContentTable { get; } = new();

+ 3 - 3
Source/QuestPDF/Fluent/TextExtensions.cs

@@ -37,7 +37,7 @@ namespace QuestPDF.Fluent
     /// </remarks>
     public delegate string PageNumberFormatter(int? pageNumber);
     
-    public class TextPageNumberDescriptor : TextSpanDescriptor
+    public sealed class TextPageNumberDescriptor : TextSpanDescriptor
     {
         internal Action<PageNumberFormatter> AssignFormatFunction { get; }
         
@@ -59,7 +59,7 @@ namespace QuestPDF.Fluent
         }
     }
     
-    public class TextBlockDescriptor : TextSpanDescriptor
+    public sealed class TextBlockDescriptor : TextSpanDescriptor
     {
         private TextBlock TextBlock;
 
@@ -139,7 +139,7 @@ namespace QuestPDF.Fluent
         }
     }
     
-    public class TextDescriptor
+    public sealed class TextDescriptor
     {
         internal TextBlock TextBlock { get; } = new();
         private TextStyle? DefaultStyle { get; set; }

+ 1 - 1
Source/QuestPDF/Helpers/Fonts.cs

@@ -5,7 +5,7 @@ namespace QuestPDF.Helpers
     /// <summary>
     /// Contains a collection of fonts defined by the PDF standard.
     /// </summary>
-    public class Fonts
+    public static class Fonts
     {
         public const string Arial = "Arial";
         public const string Calibri = "Calibri";

+ 1 - 1
Source/QuestPDF/Helpers/NativeDependencyCompatibilityChecker.cs

@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
 
 namespace QuestPDF.Helpers
 {
-    internal class NativeDependencyCompatibilityChecker
+    internal sealed class NativeDependencyCompatibilityChecker
     {
         private static readonly Version RequiredGlibcVersionOnLinux = Version.Parse("2.29");
         

+ 1 - 1
Source/QuestPDF/Helpers/PageSizes.cs

@@ -15,7 +15,7 @@ namespace QuestPDF.Helpers
     /// <example>
     /// <c>PageSizes.A4.Landscape();</c>
     /// </example>
-    public class PageSize
+    public sealed class PageSize
     {
         public readonly float Width;
         public readonly float Height;

+ 1 - 1
Source/QuestPDF/Infrastructure/DocumentMetadata.cs

@@ -2,7 +2,7 @@ using System;
 
 namespace QuestPDF.Infrastructure
 {
-    public class DocumentMetadata
+    public sealed class DocumentMetadata
     {
         /// <summary>
         /// Represents the main heading or name of the document, often displayed as a prominent identifier or label in PDF metadata.

+ 1 - 1
Source/QuestPDF/Infrastructure/DocumentSettings.cs

@@ -1,6 +1,6 @@
 namespace QuestPDF.Infrastructure
 {
-    public class DocumentSettings
+    public sealed class DocumentSettings
     {
         public const int DefaultRasterDpi = 72;
         

+ 1 - 1
Source/QuestPDF/Infrastructure/IDynamicComponent.cs

@@ -33,7 +33,7 @@ namespace QuestPDF.Infrastructure
     /// <summary>
     /// Represents the output from the DynamicComponent describing what should be rendered on the current page.
     /// </summary>
-    public class DynamicComponentComposeResult
+    public sealed class DynamicComponentComposeResult
     {
         /// <summary>
         /// Any content created with the <see cref="DynamicContext.CreateElement" /> method that should be drawn on the currently rendered page.

+ 1 - 1
Source/QuestPDF/Infrastructure/Image.cs

@@ -22,7 +22,7 @@ namespace QuestPDF.Infrastructure
     /// <remarks>
     /// This class is thread safe.
     /// </remarks>
-    public class Image : IDisposable
+    public sealed class Image : IDisposable
     {
         static Image()
         {

+ 1 - 1
Source/QuestPDF/Infrastructure/ImageGenerationSettings.cs

@@ -1,6 +1,6 @@
 namespace QuestPDF.Infrastructure
 {
-    public class ImageGenerationSettings
+    public sealed class ImageGenerationSettings
     {
         /// <summary>
         /// The file format used to encode the image(s).

+ 1 - 1
Source/QuestPDF/Infrastructure/SvgImage.cs

@@ -12,7 +12,7 @@ namespace QuestPDF.Infrastructure;
 /// <remarks>
 /// This class is thread safe.
 /// </remarks>
-public class SvgImage : IDisposable
+public sealed class SvgImage : IDisposable
 {
     internal SkSvgImage SkSvgImage { get; }
     internal bool IsShared { get; set; } = true;

+ 8 - 8
Source/QuestPDF/Qpdf/JobConfiguration.cs

@@ -4,7 +4,7 @@ namespace QuestPDF.Qpdf;
 
 using Name = SimpleJsonPropertyNameAttribute;
 
-class JobConfiguration
+sealed class JobConfiguration
 {
     [Name("inputFile")] public string InputFile { get; set; }
     [Name("password")] public string? Password { get; set; }
@@ -22,13 +22,13 @@ class JobConfiguration
     [Name("linearize")] public string? Linearize { get; set; }
     [Name("newlineBeforeEndstream")] public string? NewlineBeforeEndstream { get; set; } = string.Empty;
     
-    internal class PageConfiguration
+    internal sealed class PageConfiguration
     {
         [Name("file")] public string File { get; set; }
         [Name("range")] public string Range { get; set; }
     }
     
-    internal class LayerConfiguration
+    internal sealed class LayerConfiguration
     {
         [Name("file")] public string File { get; set; }
         [Name("to")] public string? To { get; set; }
@@ -36,7 +36,7 @@ class JobConfiguration
         [Name("repeat")] public string? Repeat { get; set; }
     }
     
-    public class AddDocumentAttachment
+    public sealed class AddDocumentAttachment
     {
         [Name("key")] public string Key { get; set; }
         [Name("file")] public string File { get; set; }
@@ -49,7 +49,7 @@ class JobConfiguration
         [Name("relationship")] public string? Relationship { get; set; }
     }
 
-    public class EncryptionSettings
+    public sealed class EncryptionSettings
     {
         [Name("userPassword")] public string? UserPassword { get; set; }
         [Name("ownerPassword")] public string OwnerPassword { get; set; }
@@ -59,7 +59,7 @@ class JobConfiguration
         [Name("256bit")] public Encryption256Bit? Options256Bit { get; set; }
     }
     
-    public class Encryption40Bit
+    public sealed class Encryption40Bit
     {
         [Name("annotate")] public string Annotate { get; set; }
         [Name("extract")] public string Extract { get; set; }
@@ -67,7 +67,7 @@ class JobConfiguration
         [Name("print")] public string Print { get; set; }
     }
 
-    public class Encryption128Bit
+    public sealed class Encryption128Bit
     {
         [Name("annotate")] public string Annotate { get; set; }
         [Name("assemble")] public string Assemble { get; set; }
@@ -77,7 +77,7 @@ class JobConfiguration
         [Name("cleartextMetadata")] public string? CleartextMetadata { get; set; }
     }
 
-    public class Encryption256Bit
+    public sealed class Encryption256Bit
     {
         [Name("annotate")] public string Annotate { get; set; }
         [Name("assemble")] public string Assemble { get; set; }

+ 1 - 1
Source/QuestPDF/Qpdf/MimeHelper.cs

@@ -2,7 +2,7 @@ using System.Collections.Generic;
 
 namespace QuestPDF.Qpdf;
 
-class MimeHelper
+static class MimeHelper
 {
     public static readonly IReadOnlyDictionary<string, string> FileExtensionToMimeConversionTable = new Dictionary<string, string>
     {

+ 1 - 1
Source/QuestPDF/Qpdf/QpdfAPI.cs

@@ -4,7 +4,7 @@ using System.Text;
 
 namespace QuestPDF.Qpdf;
 
-class QpdfAPI
+static class QpdfAPI
 {
     public static string? GetQpdfVersion()
     {

+ 2 - 2
Source/QuestPDF/Qpdf/SimpleJsonSerializer.cs

@@ -6,7 +6,7 @@ using System.Text;
 
 namespace QuestPDF.Qpdf;
 
-class SimpleJsonPropertyNameAttribute(string name) : Attribute
+sealed class SimpleJsonPropertyNameAttribute(string name) : Attribute
 {
     public string Name { get; } = name;
 }
@@ -14,7 +14,7 @@ class SimpleJsonPropertyNameAttribute(string name) : Attribute
 /// <summary>
 /// Never use in performance critical scenarios!
 /// </summary>
-class SimpleJsonSerializer
+static class SimpleJsonSerializer
 {
     public static string Serialize(object obj)
     {

+ 1 - 1
Source/QuestPDF/Skia/SkText.cs

@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
 
 namespace QuestPDF.Skia;
 
-internal class SkText : IDisposable
+internal sealed class SkText : IDisposable
 {
     public IntPtr Instance { get; private set; }