Browse Source

Sealed uninherited `internal` classes (1) (#656)

Co-authored-by: Lehonti Ramos <lehonti@ramos>
Lehonti Ramos 2 years ago
parent
commit
47cef260a7
33 changed files with 51 additions and 65 deletions
  1. 1 1
      Source/QuestPDF/Drawing/DocumentContainer.cs
  2. 1 1
      Source/QuestPDF/Drawing/FontStyleSet.cs
  3. 1 1
      Source/QuestPDF/Drawing/FreeCanvas.cs
  4. 1 1
      Source/QuestPDF/Drawing/ImageCanvas.cs
  5. 1 1
      Source/QuestPDF/Drawing/PdfCanvas.cs
  6. 1 1
      Source/QuestPDF/Drawing/Proxy/CacheProxy.cs
  7. 1 1
      Source/QuestPDF/Drawing/Proxy/DebugStackItem.cs
  8. 1 1
      Source/QuestPDF/Drawing/Proxy/DebuggingProxy.cs
  9. 1 1
      Source/QuestPDF/Drawing/Proxy/DebuggingState.cs
  10. 1 2
      Source/QuestPDF/Drawing/SkiaDocumentCanvasBase.cs
  11. 3 6
      Source/QuestPDF/Drawing/SkiaPictureCanvas.cs
  12. 3 4
      Source/QuestPDF/Drawing/TextShaper.cs
  13. 1 2
      Source/QuestPDF/Drawing/XpsCanvas.cs
  14. 1 2
      Source/QuestPDF/Elements/Alignment.cs
  15. 1 1
      Source/QuestPDF/Elements/AspectRatio.cs
  16. 1 1
      Source/QuestPDF/Elements/Background.cs
  17. 1 1
      Source/QuestPDF/Elements/Border.cs
  18. 2 2
      Source/QuestPDF/Elements/Canvas.cs
  19. 5 5
      Source/QuestPDF/Elements/Column.cs
  20. 1 2
      Source/QuestPDF/Elements/Constrained.cs
  21. 1 1
      Source/QuestPDF/Elements/ContentDirectionSetter.cs
  22. 1 1
      Source/QuestPDF/Elements/DebugArea.cs
  23. 2 4
      Source/QuestPDF/Elements/DebugPointer.cs
  24. 3 4
      Source/QuestPDF/Elements/Decoration.cs
  25. 2 3
      Source/QuestPDF/Elements/DefaultTextStyle.cs
  26. 2 2
      Source/QuestPDF/Elements/Dynamic.cs
  27. 3 5
      Source/QuestPDF/Elements/DynamicImage.cs
  28. 1 1
      Source/QuestPDF/Elements/Empty.cs
  29. 1 1
      Source/QuestPDF/Elements/EnsureSpace.cs
  30. 1 1
      Source/QuestPDF/Elements/Extend.cs
  31. 3 3
      Source/QuestPDF/Elements/Grid.cs
  32. 1 1
      Source/QuestPDF/Elements/Hyperlink.cs
  33. 1 1
      Source/QuestPDF/Elements/Image.cs

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

@@ -7,7 +7,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Drawing
 {
-    internal class DocumentContainer : IDocumentContainer
+    internal sealed class DocumentContainer : IDocumentContainer
     {
         internal List<IComponent> Pages { get; set; } = new List<IComponent>();
         

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

@@ -5,7 +5,7 @@ using SkiaSharp;
 
 namespace QuestPDF.Drawing
 {
-    internal class FontStyleSet
+    internal sealed class FontStyleSet
     {
         private ConcurrentDictionary<SKFontStyle, SKTypeface> Styles { get; } = new();
 

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

@@ -3,7 +3,7 @@ using SkiaSharp;
 
 namespace QuestPDF.Drawing
 {
-    internal class FreeCanvas : ICanvas, IRenderingCanvas
+    internal sealed class FreeCanvas : ICanvas, IRenderingCanvas
     {
         #region IRenderingCanvas
 

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

@@ -5,7 +5,7 @@ using SkiaSharp;
 
 namespace QuestPDF.Drawing
 {
-    internal class ImageCanvas : SkiaCanvasBase
+    internal sealed class ImageCanvas : SkiaCanvasBase
     {
         private ImageGenerationSettings Settings { get; }
         private SKSurface Surface { get; set; }

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

@@ -7,7 +7,7 @@ using SkiaSharp;
 
 namespace QuestPDF.Drawing
 {
-    internal class PdfCanvas : SkiaDocumentCanvasBase
+    internal sealed class PdfCanvas : SkiaDocumentCanvasBase
     {
         public PdfCanvas(Stream stream, DocumentMetadata documentMetadata, DocumentSettings documentSettings) 
             : base(CreatePdf(stream, documentMetadata, documentSettings))

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Drawing.Proxy
 {
-    internal class CacheProxy : ElementProxy
+    internal sealed class CacheProxy : ElementProxy
     {
         public Size? AvailableSpace { get; set; }
         public SpacePlan? MeasurementResult { get; set; }

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Drawing.Proxy
 {
-    internal class DebugStackItem
+    internal sealed class DebugStackItem
     {
         public IElement Element { get; internal set; }
         public Size AvailableSpace { get; internal set; }

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

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Drawing.Proxy
 {
-    internal class DebuggingProxy : ElementProxy
+    internal sealed class DebuggingProxy : ElementProxy
     {
         private DebuggingState DebuggingState { get; }
 

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

@@ -9,7 +9,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Drawing.Proxy
 {
-    internal class DebuggingState
+    internal sealed class DebuggingState
     {
         private DebugStackItem? Root { get; set; }
         private Stack<DebugStackItem> Stack { get; set; }

+ 1 - 2
Source/QuestPDF/Drawing/SkiaDocumentCanvasBase.cs

@@ -1,5 +1,4 @@
-using System.IO;
-using QuestPDF.Infrastructure;
+using QuestPDF.Infrastructure;
 using SkiaSharp;
 
 namespace QuestPDF.Drawing

+ 3 - 6
Source/QuestPDF/Drawing/SkiaPictureCanvas.cs

@@ -1,13 +1,10 @@
 using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 using SkiaSharp;
 
 namespace QuestPDF.Drawing
 {
-    internal class PreviewerPicture
+    internal sealed class PreviewerPicture
     {
         public SKPicture Picture { get; set; }
         public Size Size { get; set; }
@@ -18,8 +15,8 @@ namespace QuestPDF.Drawing
             Size = size;
         }
     }
-    
-    internal class SkiaPictureCanvas : SkiaCanvasBase
+
+    internal sealed class SkiaPictureCanvas : SkiaCanvasBase
     {
         private SKPictureRecorder? PictureRecorder { get; set; }
         private Size? CurrentPageSize { get; set; }

+ 3 - 4
Source/QuestPDF/Drawing/TextShaper.cs

@@ -1,14 +1,13 @@
 using System;
 using System.Linq;
 using HarfBuzzSharp;
-using QuestPDF.Fluent;
 using QuestPDF.Infrastructure;
 using SkiaSharp;
 using Buffer = HarfBuzzSharp.Buffer;
 
 namespace QuestPDF.Drawing
 {
-    internal class TextShaper
+    internal sealed class TextShaper
     {
         public const int FontShapingScale = 512;
         
@@ -108,8 +107,8 @@ namespace QuestPDF.Drawing
         public SKTextBlob SkTextBlob;
         public float TextOffsetX;
     }
-    
-    internal class TextShapingResult
+
+    internal sealed class TextShapingResult
     {
         private Direction Direction { get; }
         private ShapedGlyph[] Glyphs { get; }

+ 1 - 2
Source/QuestPDF/Drawing/XpsCanvas.cs

@@ -1,13 +1,12 @@
 using System;
 using System.IO;
 using QuestPDF.Drawing.Exceptions;
-using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 using SkiaSharp;
 
 namespace QuestPDF.Drawing
 {
-    internal class XpsCanvas : SkiaDocumentCanvasBase
+    internal sealed class XpsCanvas : SkiaDocumentCanvasBase
     {
         public XpsCanvas(Stream stream, DocumentSettings documentSettings) 
             : base(CreateXps(stream, documentSettings))

+ 1 - 2
Source/QuestPDF/Elements/Alignment.cs

@@ -1,10 +1,9 @@
-using System;
 using QuestPDF.Drawing;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Alignment : ContainerElement
+    internal sealed class Alignment : ContainerElement
     {
         public VerticalAlignment? Vertical { get; set; }
         public HorizontalAlignment? Horizontal { get; set; }

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class AspectRatio : ContainerElement, ICacheable, IContentDirectionAware
+    internal sealed class AspectRatio : ContainerElement, ICacheable, IContentDirectionAware
     {
         public ContentDirection ContentDirection { get; set; }
         

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Background : ContainerElement
+    internal sealed class Background : ContainerElement
     {
         public string Color { get; set; } = Colors.Black;
         

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Border : ContainerElement
+    internal sealed class Border : ContainerElement
     {
         public string Color { get; set; } = Colors.Black;
 

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

@@ -6,8 +6,8 @@ using SkiaSharp;
 namespace QuestPDF.Elements
 {
     public delegate void DrawOnCanvas(SKCanvas canvas, Size availableSpace);
-    
-    internal class Canvas : Element, ICacheable
+
+    internal sealed class Canvas : Element, ICacheable
     {
         public DrawOnCanvas Handler { get; set; }
         

+ 5 - 5
Source/QuestPDF/Elements/Column.cs

@@ -6,20 +6,20 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class ColumnItem : Container
+    internal sealed class ColumnItem : Container
     {
         public bool IsRendered { get; set; }
     }
-    
-    internal class ColumnItemRenderingCommand
+
+    internal sealed class ColumnItemRenderingCommand
     {
         public ColumnItem ColumnItem { get; set; }
         public SpacePlan Measurement { get; set; }
         public Size Size { get; set; }
         public Position Offset { get; set; }
     }
-    
-    internal class Column : Element, ICacheable, IStateResettable
+
+    internal sealed class Column : Element, ICacheable, IStateResettable
     {
         internal List<ColumnItem> Items { get; } = new();
         internal float Spacing { get; set; }

+ 1 - 2
Source/QuestPDF/Elements/Constrained.cs

@@ -1,11 +1,10 @@
 using System;
-using System.Linq;
 using QuestPDF.Drawing;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Constrained : ContainerElement, ICacheable, IContentDirectionAware
+    internal sealed class Constrained : ContainerElement, ICacheable, IContentDirectionAware
     {
         public ContentDirection ContentDirection { get; set; }
         

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

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Elements
 {
-    internal class ContentDirectionSetter : ContainerElement
+    internal sealed class ContentDirectionSetter : ContainerElement
     {
         public ContentDirection ContentDirection { get; set; }
     }

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

@@ -5,7 +5,7 @@ using SkiaSharp;
 
 namespace QuestPDF.Elements
 {
-    internal class DebugArea : IComponent
+    internal sealed class DebugArea : IComponent
     {
         public IElement? Child { get; set; }
         

+ 2 - 4
Source/QuestPDF/Elements/DebugPointer.cs

@@ -1,8 +1,6 @@
-using System.ComponentModel;
-
-namespace QuestPDF.Elements
+namespace QuestPDF.Elements
 {
-    internal class DebugPointer : Container
+    internal sealed class DebugPointer : Container
     {
         public string Target { get; set; }
         public bool Highlight { get; set; }

+ 3 - 4
Source/QuestPDF/Elements/Decoration.cs

@@ -2,19 +2,18 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using QuestPDF.Drawing;
-using QuestPDF.Fluent;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class DecorationItemRenderingCommand
+    internal sealed class DecorationItemRenderingCommand
     {
         public Element Element { get; set; }
         public SpacePlan Measurement { get; set; }
         public Position Offset { get; set; }
     }
-    
-    internal class Decoration : Element, ICacheable, IContentDirectionAware
+
+    internal sealed class Decoration : Element, ICacheable, IContentDirectionAware
     {
         public ContentDirection ContentDirection { get; set; }
         

+ 2 - 3
Source/QuestPDF/Elements/DefaultTextStyle.cs

@@ -1,9 +1,8 @@
-using QuestPDF.Drawing;
-using QuestPDF.Infrastructure;
+using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class DefaultTextStyle : ContainerElement
+    internal sealed class DefaultTextStyle : ContainerElement
     {
         public TextStyle TextStyle { get; set; } = TextStyle.Default;
     }

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

@@ -6,7 +6,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class DynamicHost : Element, IStateResettable, IContentDirectionAware
+    internal sealed class DynamicHost : Element, IStateResettable, IContentDirectionAware
     {
         private DynamicComponentProxy Child { get; }
         private object InitialComponentState { get; set; }
@@ -148,7 +148,7 @@ namespace QuestPDF.Elements
         Size Size { get; }
     }
 
-    internal class DynamicElement : ContainerElement, IDynamicElement
+    internal sealed class DynamicElement : ContainerElement, IDynamicElement
     {
         public Size Size { get; internal set; }
     }

+ 3 - 5
Source/QuestPDF/Elements/DynamicImage.cs

@@ -1,6 +1,4 @@
-using System;
-using System.Security;
-using QuestPDF.Drawing;
+using QuestPDF.Drawing;
 using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 using SkiaSharp;
@@ -13,8 +11,8 @@ namespace QuestPDF.Elements
     /// <param name="size">Desired resolution of the image in pixels.</param>
     /// <returns>An image in PNG, JPEG, or WEBP image format returned as byte array.</returns>
     public delegate byte[] GenerateDynamicImageDelegate(ImageSize size);
-    
-    internal class DynamicImage : Element
+
+    internal sealed class DynamicImage : Element
     {
         internal int? TargetDpi { get; set; }
         internal ImageCompressionQuality? CompressionQuality { get; set; }

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Empty : Element
+    internal sealed class Empty : Element
     {
         internal static Empty Instance { get; } = new Empty();
         

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class EnsureSpace : ContainerElement, ICacheable
+    internal sealed class EnsureSpace : ContainerElement, ICacheable
     {
         public const float DefaultMinHeight = 150;
         public float MinHeight { get; set; } = DefaultMinHeight;

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Extend : ContainerElement, ICacheable
+    internal sealed class Extend : ContainerElement, ICacheable
     {
         public bool ExtendVertical { get; set; }
         public bool ExtendHorizontal { get; set; }

+ 3 - 3
Source/QuestPDF/Elements/Grid.cs

@@ -5,13 +5,13 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class GridElement
+    internal sealed class GridElement
     {
         public int Columns { get; set; } = 1;
         public Element? Child { get; set; }
     }
-    
-    internal class Grid : IComponent
+
+    internal sealed class Grid : IComponent
     {
         public const int DefaultColumnsCount = 12;
         

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Hyperlink : ContainerElement
+    internal sealed class Hyperlink : ContainerElement
     {
         public string Url { get; set; } = "https://www.questpdf.com";
         

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

@@ -5,7 +5,7 @@ using SkiaSharp;
 
 namespace QuestPDF.Elements
 {
-    internal class Image : Element, ICacheable
+    internal sealed class Image : Element, ICacheable
     {
         public Infrastructure.Image? DocumentImage { get; set; }