Browse Source

Sealed uninherited `internal` classes (2) (#657)

Co-authored-by: Lehonti Ramos <lehonti@ramos>
Lehonti Ramos 2 years ago
parent
commit
f46ea0df6a
41 changed files with 57 additions and 79 deletions
  1. 4 5
      Source/QuestPDF/Elements/Inlined.cs
  2. 4 5
      Source/QuestPDF/Elements/Layers.cs
  3. 2 2
      Source/QuestPDF/Elements/Line.cs
  4. 1 1
      Source/QuestPDF/Elements/MinimalBox.cs
  5. 1 1
      Source/QuestPDF/Elements/Padding.cs
  6. 1 2
      Source/QuestPDF/Elements/Page.cs
  7. 1 1
      Source/QuestPDF/Elements/PageBreak.cs
  8. 1 1
      Source/QuestPDF/Elements/Placeholder.cs
  9. 1 1
      Source/QuestPDF/Elements/Rotate.cs
  10. 5 6
      Source/QuestPDF/Elements/Row.cs
  11. 1 1
      Source/QuestPDF/Elements/Scale.cs
  12. 2 3
      Source/QuestPDF/Elements/ScaleToFit.cs
  13. 1 1
      Source/QuestPDF/Elements/Section.cs
  14. 1 1
      Source/QuestPDF/Elements/SectionLink.cs
  15. 1 1
      Source/QuestPDF/Elements/ShowEntire.cs
  16. 1 1
      Source/QuestPDF/Elements/ShowOnce.cs
  17. 1 1
      Source/QuestPDF/Elements/SimpleRotate.cs
  18. 1 1
      Source/QuestPDF/Elements/SkipOnce.cs
  19. 1 1
      Source/QuestPDF/Elements/StopPaging.cs
  20. 1 1
      Source/QuestPDF/Elements/Table/DynamicDictionary.cs
  21. 1 4
      Source/QuestPDF/Elements/Table/Table.cs
  22. 1 1
      Source/QuestPDF/Elements/Table/TableCell.cs
  23. 1 1
      Source/QuestPDF/Elements/Table/TableCellRenderingCommand.cs
  24. 1 1
      Source/QuestPDF/Elements/Table/TableColumnDefinition.cs
  25. 2 3
      Source/QuestPDF/Elements/Text/Calculation/TextDrawingRequest.cs
  26. 2 4
      Source/QuestPDF/Elements/Text/Calculation/TextLine.cs
  27. 1 1
      Source/QuestPDF/Elements/Text/Calculation/TextLineElement.cs
  28. 1 1
      Source/QuestPDF/Elements/Text/Calculation/TextMeasurementRequest.cs
  29. 1 2
      Source/QuestPDF/Elements/Text/Calculation/TextMeasurementResult.cs
  30. 1 1
      Source/QuestPDF/Elements/Text/Items/TextBlockElement.cs
  31. 1 1
      Source/QuestPDF/Elements/Text/Items/TextBlockHyperlink.cs
  32. 1 1
      Source/QuestPDF/Elements/Text/Items/TextBlockPageNumber.cs
  33. 1 1
      Source/QuestPDF/Elements/Text/Items/TextBlockSectionLink.cs
  34. 0 3
      Source/QuestPDF/Elements/Text/Items/TextBlockSpan.cs
  35. 2 3
      Source/QuestPDF/Elements/Text/TextBlock.cs
  36. 2 3
      Source/QuestPDF/Elements/Translate.cs
  37. 1 1
      Source/QuestPDF/Elements/Unconstrained.cs
  38. 1 2
      Source/QuestPDF/Infrastructure/IDynamicComponent.cs
  39. 2 4
      Source/QuestPDF/Infrastructure/IPageContext.cs
  40. 1 2
      Source/QuestPDF/Infrastructure/PageContext.cs
  41. 1 2
      Source/QuestPDF/Previewer/ExceptionDocument.cs

+ 4 - 5
Source/QuestPDF/Elements/Inlined.cs

@@ -1,12 +1,11 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
 using QuestPDF.Drawing;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class InlinedElement : Container
+    internal sealed class InlinedElement : Container
     {
 
     }
@@ -25,8 +24,8 @@ namespace QuestPDF.Elements
         public Element Element { get; set; }
         public SpacePlan Size { get; set; }
     }
-    
-    internal class Inlined : Element, IStateResettable, IContentDirectionAware
+
+    internal sealed class Inlined : Element, IStateResettable, IContentDirectionAware
     {
         public ContentDirection ContentDirection { get; set; }
         

+ 4 - 5
Source/QuestPDF/Elements/Layers.cs

@@ -1,17 +1,16 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
 using QuestPDF.Drawing;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Layer : ContainerElement
+    internal sealed class Layer : ContainerElement
     {
         public bool IsPrimary { get; set; }
     }
-    
-    internal class Layers : Element, ICacheable
+
+    internal sealed class Layers : Element, ICacheable
     {
         public List<Layer> Children { get; set; } = new List<Layer>();
         

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

@@ -14,8 +14,8 @@ namespace QuestPDF.Elements
         Vertical,
         Horizontal
     }
-    
-    internal class Line : Element, ILine, ICacheable
+
+    internal sealed class Line : Element, ILine, ICacheable
     {
         public LineType Type { get; set; } = LineType.Vertical;
         public string Color { get; set; } = Colors.Black;

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

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

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Padding : ContainerElement, ICacheable
+    internal sealed class Padding : ContainerElement, ICacheable
     {
         public float Top { get; set; }
         public float Right { get; set; }

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

@@ -1,12 +1,11 @@
 using System;
-using QuestPDF.Drawing;
 using QuestPDF.Fluent;
 using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Page : IComponent
+    internal sealed class Page : IComponent
     {
         public ContentDirection ContentDirection { get; set; }
         public TextStyle DefaultTextStyle { get; set; } = TextStyle.Default;

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class PageBreak : Element, IStateResettable
+    internal sealed class PageBreak : Element, IStateResettable
     {
         private bool IsRendered { get; set; }
         

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Placeholder : IComponent
+    internal sealed class Placeholder : IComponent
     {
         public string Text { get; set; }
         private static readonly byte[] ImageData;

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

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Elements
 {
-    internal class Rotate : ContainerElement
+    internal sealed class Rotate : ContainerElement
     {
         public float Angle { get; set; } = 0;
 

+ 5 - 6
Source/QuestPDF/Elements/Row.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using QuestPDF.Drawing;
@@ -13,8 +12,8 @@ namespace QuestPDF.Elements
         Constant,
         Relative
     }
-    
-    internal class RowItem : Container
+
+    internal sealed class RowItem : Container
     {
         public bool IsRendered { get; set; }
         public float Width { get; set; }
@@ -23,15 +22,15 @@ namespace QuestPDF.Elements
         public float Size { get; set; }
     }
 
-    internal class RowItemRenderingCommand
+    internal sealed class RowItemRenderingCommand
     {
         public RowItem RowItem { get; set; }
         public SpacePlan Measurement { get; set; }
         public Size Size { get; set; }
         public Position Offset { get; set; }
     }
-    
-    internal class Row : Element, ICacheable, IStateResettable, IContentDirectionAware
+
+    internal sealed class Row : Element, ICacheable, IStateResettable, IContentDirectionAware
     {
         public ContentDirection ContentDirection { get; set; }
         

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Scale : ContainerElement, ICacheable
+    internal sealed class Scale : ContainerElement, ICacheable
     {
         public float ScaleX { get; set; } = 1;
         public float ScaleY { get; set; } = 1;

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

@@ -1,11 +1,10 @@
-using System;
-using System.Linq;
+using System.Linq;
 using QuestPDF.Drawing;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class ScaleToFit : ContainerElement
+    internal sealed class ScaleToFit : ContainerElement
     {
         internal override SpacePlan Measure(Size availableSpace)
         {

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

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Elements
 {
-    internal class Section : ContainerElement, IStateResettable
+    internal sealed class Section : ContainerElement, IStateResettable
     {
         public string SectionName { get; set; }
         private bool IsRendered { get; set; }

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

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

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class ShowEntire : ContainerElement, ICacheable
+    internal sealed class ShowEntire : ContainerElement, ICacheable
     {
         internal override SpacePlan Measure(Size availableSpace)
         {

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class ShowOnce : ContainerElement, IStateResettable, ICacheable
+    internal sealed class ShowOnce : ContainerElement, IStateResettable, ICacheable
     {
         private bool IsRendered { get; set; }
 

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class SimpleRotate : ContainerElement, ICacheable
+    internal sealed class SimpleRotate : ContainerElement, ICacheable
     {
         public int TurnCount { get; set; }
         public int NormalizedTurnCount => (TurnCount % 4 + 4) % 4;

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class SkipOnce : ContainerElement, IStateResettable
+    internal sealed class SkipOnce : ContainerElement, IStateResettable
     {
         private bool FirstPageWasSkipped { get; set; }
 

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class StopPaging : ContainerElement
+    internal sealed class StopPaging : ContainerElement
     {
         internal override SpacePlan Measure(Size availableSpace)
         {

+ 1 - 1
Source/QuestPDF/Elements/Table/DynamicDictionary.cs

@@ -7,7 +7,7 @@ namespace QuestPDF.Elements.Table
     /// This dictionary allows to access key that does not exist.
     /// Instead of throwing an exception, it returns a default value.
     /// </summary>
-    internal class DynamicDictionary<TKey, TValue>
+    internal sealed class DynamicDictionary<TKey, TValue>
     {
         private TValue Default { get; }
         private IDictionary<TKey, TValue> Dictionary { get; } = new Dictionary<TKey, TValue>();

+ 1 - 4
Source/QuestPDF/Elements/Table/Table.cs

@@ -1,15 +1,12 @@
 using System;
-using System.Collections.Concurrent;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.Linq;
 using QuestPDF.Drawing;
-using QuestPDF.Fluent;
 using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Table
 {
-    internal class Table : Element, IStateResettable, IContentDirectionAware
+    internal sealed class Table : Element, IStateResettable, IContentDirectionAware
     {
         public ContentDirection ContentDirection { get; set; }
         

+ 1 - 1
Source/QuestPDF/Elements/Table/TableCell.cs

@@ -1,6 +1,6 @@
 namespace QuestPDF.Elements.Table
 {
-    internal class TableCell : Container, ITableCellContainer
+    internal sealed class TableCell : Container, ITableCellContainer
     {
         public int Row { get; set; } = 0;
         public int RowSpan { get; set; } = 1;

+ 1 - 1
Source/QuestPDF/Elements/Table/TableCellRenderingCommand.cs

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Table
 {
-    internal class TableCellRenderingCommand
+    internal sealed class TableCellRenderingCommand
     {
         public TableCell Cell { get; set; }
         public SpacePlan Measurement { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/Table/TableColumnDefinition.cs

@@ -1,6 +1,6 @@
 namespace QuestPDF.Elements.Table
 {
-    internal class TableColumnDefinition
+    internal sealed class TableColumnDefinition
     {
         public float ConstantSize { get; }
         public float RelativeSize { get; }

+ 2 - 3
Source/QuestPDF/Elements/Text/Calculation/TextDrawingRequest.cs

@@ -1,9 +1,8 @@
-using QuestPDF.Drawing;
-using QuestPDF.Infrastructure;
+using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Text.Calculation
 {
-    internal class TextDrawingRequest
+    internal sealed class TextDrawingRequest
     {
         public ICanvas Canvas { get; set; }
         public IPageContext PageContext { get; set; }

+ 2 - 4
Source/QuestPDF/Elements/Text/Calculation/TextLine.cs

@@ -1,11 +1,9 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
-using QuestPDF.Elements.Text.Items;
 
 namespace QuestPDF.Elements.Text.Calculation
 {
-    internal class TextLine
+    internal sealed class TextLine
     {
         public ICollection<TextLineElement> Elements { get; private set; }
 

+ 1 - 1
Source/QuestPDF/Elements/Text/Calculation/TextLineElement.cs

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Elements.Text.Calculation
 {
-    internal class TextLineElement
+    internal sealed class TextLineElement
     {
         public ITextBlockItem Item { get; set; }
         public TextMeasurementResult Measurement { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/Text/Calculation/TextMeasurementRequest.cs

@@ -2,7 +2,7 @@
 
 namespace QuestPDF.Elements.Text.Calculation
 {
-    internal class TextMeasurementRequest
+    internal sealed class TextMeasurementRequest
     {
         public ICanvas Canvas { get; set; }
         public IPageContext PageContext { get; set; }

+ 1 - 2
Source/QuestPDF/Elements/Text/Calculation/TextMeasurementResult.cs

@@ -1,9 +1,8 @@
 using System;
-using QuestPDF.Drawing;
 
 namespace QuestPDF.Elements.Text.Calculation
 {
-    internal class TextMeasurementResult
+    internal sealed class TextMeasurementResult
     {
         public float Width { get; set; }
         public float Height => Math.Abs(Descent) + Math.Abs(Ascent);

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

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Text.Items
 {
-    internal class TextBlockElement : ITextBlockItem
+    internal sealed class TextBlockElement : ITextBlockItem
     {
         public Element Element { get; set; } = Empty.Instance;
         

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Text.Items
 {
-    internal class TextBlockHyperlink : TextBlockSpan
+    internal sealed class TextBlockHyperlink : TextBlockSpan
     {
         public string Url { get; set; }
         

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

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Text.Items
 {
-    internal class TextBlockPageNumber : TextBlockSpan
+    internal sealed class TextBlockPageNumber : TextBlockSpan
     {
         public const string PageNumberPlaceholder = "123";
         public Func<IPageContext, string> Source { get; set; } = _ => PageNumberPlaceholder;

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

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Text.Items
 {
-    internal class TextBlockSectionLink : TextBlockSpan
+    internal sealed class TextBlockSectionLink : TextBlockSpan
     {
         public string SectionName { get; set; }
         

+ 0 - 3
Source/QuestPDF/Elements/Text/Items/TextBlockSpan.cs

@@ -1,12 +1,9 @@
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using QuestPDF.Drawing;
 using QuestPDF.Elements.Text.Calculation;
 using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
-using SkiaSharp;
-using SkiaSharp.HarfBuzz;
 using Size = QuestPDF.Infrastructure.Size;
 
 namespace QuestPDF.Elements.Text.Items

+ 2 - 3
Source/QuestPDF/Elements/Text/TextBlock.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
 using QuestPDF.Drawing;
 using QuestPDF.Elements.Text.Calculation;
@@ -8,7 +7,7 @@ using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements.Text
 {
-    internal class TextBlock : Element, IStateResettable, IContentDirectionAware
+    internal sealed class TextBlock : Element, IStateResettable, IContentDirectionAware
     {
         public ContentDirection ContentDirection { get; set; }
         

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

@@ -1,9 +1,8 @@
-
-using QuestPDF.Infrastructure;
+using QuestPDF.Infrastructure;
 
 namespace QuestPDF.Elements
 {
-    internal class Translate : ContainerElement
+    internal sealed class Translate : ContainerElement
     {
         public float TranslateX { get; set; } = 0;
         public float TranslateY { get; set; } = 0;

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

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

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

@@ -1,10 +1,9 @@
 using System;
 using QuestPDF.Elements;
-using QuestPDF.Helpers;
 
 namespace QuestPDF.Infrastructure
 {
-    internal class DynamicComponentProxy
+    internal sealed class DynamicComponentProxy
     {
         internal Action<object> SetState { get; private set; }
         internal Func<object> GetState { get; private set; }

+ 2 - 4
Source/QuestPDF/Infrastructure/IPageContext.cs

@@ -1,8 +1,6 @@
-using System.Collections.Generic;
-
-namespace QuestPDF.Infrastructure
+namespace QuestPDF.Infrastructure
 {
-    internal class DocumentLocation
+    internal sealed class DocumentLocation
     {
         public int DocumentId { get; set; }
         public string Name { get; set; }

+ 1 - 2
Source/QuestPDF/Infrastructure/PageContext.cs

@@ -1,10 +1,9 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 
 namespace QuestPDF.Infrastructure
 {
-    internal class PageContext : IPageContext
+    internal sealed class PageContext : IPageContext
     {
         public int DocumentLength { get; private set; }
         private List<DocumentLocation> Locations { get; } = new();

+ 1 - 2
Source/QuestPDF/Previewer/ExceptionDocument.cs

@@ -1,5 +1,4 @@
 using System;
-using QuestPDF.Drawing;
 using QuestPDF.Fluent;
 using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
@@ -7,7 +6,7 @@ using SkiaSharp;
 
 namespace QuestPDF.Previewer
 {
-    internal class ExceptionDocument : IDocument
+    internal sealed class ExceptionDocument : IDocument
     {
         private Exception Exception { get; }