From bf7d3868da8b64dbd93beac7303cc9ee8dbcfb68 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Mon, 8 Jan 2018 22:08:58 +0000 Subject: [PATCH] check public api through reflection --- .../PublicApiScannerTests.cs | 43 +++++++++++++++++++ src/UglyToad.Pdf/Filters/IPngPredictor.cs | 7 +++ src/UglyToad.Pdf/Filters/PngPredictor.cs | 5 --- src/UglyToad.Pdf/Util/Hex.cs | 2 +- 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 src/UglyToad.Pdf.Tests/PublicApiScannerTests.cs create mode 100644 src/UglyToad.Pdf/Filters/IPngPredictor.cs diff --git a/src/UglyToad.Pdf.Tests/PublicApiScannerTests.cs b/src/UglyToad.Pdf.Tests/PublicApiScannerTests.cs new file mode 100644 index 00000000..008d5af1 --- /dev/null +++ b/src/UglyToad.Pdf.Tests/PublicApiScannerTests.cs @@ -0,0 +1,43 @@ +namespace UglyToad.Pdf.Tests +{ + using System.Collections.Generic; + using System.Linq; + using Xunit; + + public class PublicApiScannerTests + { + [Fact] + public void OnlyExposedApiIsPublic() + { + var assembly = typeof(PdfDocument).Assembly; + + var types = assembly.GetTypes(); + + var publicTypeNames = new List(); + + foreach (var type in types) + { + if (type.IsPublic) + { + publicTypeNames.Add(type.FullName); + } + } + + var expected = new List + { + "UglyToad.Pdf.PdfDocument", + "UglyToad.Pdf.ParsingOptions", + "UglyToad.Pdf.Logging.ILog", + "UglyToad.Pdf.Geometry.PdfPoint", + "UglyToad.Pdf.Fonts.Exceptions.InvalidFontFormatException", + "UglyToad.Pdf.Exceptions.PdfDocumentFormatException", + "UglyToad.Pdf.Content.Letter", + "UglyToad.Pdf.Content.Page", + "UglyToad.Pdf.Content.PageSize", + "UglyToad.Pdf.Content.DocumentInformation" + }; + + Assert.Equal(expected.OrderBy(x => x), publicTypeNames.OrderBy(x => x)); + } + } +} diff --git a/src/UglyToad.Pdf/Filters/IPngPredictor.cs b/src/UglyToad.Pdf/Filters/IPngPredictor.cs new file mode 100644 index 00000000..8f662e89 --- /dev/null +++ b/src/UglyToad.Pdf/Filters/IPngPredictor.cs @@ -0,0 +1,7 @@ +namespace UglyToad.Pdf.Filters +{ + internal interface IPngPredictor + { + byte[] Decode(byte[] input, int predictor, int colors, int bitsPerComponent, int columns); + } +} \ No newline at end of file diff --git a/src/UglyToad.Pdf/Filters/PngPredictor.cs b/src/UglyToad.Pdf/Filters/PngPredictor.cs index c54bfb3a..951d2144 100644 --- a/src/UglyToad.Pdf/Filters/PngPredictor.cs +++ b/src/UglyToad.Pdf/Filters/PngPredictor.cs @@ -231,9 +231,4 @@ return (by & mask) | (truncatedVal << startBit); } } - - public interface IPngPredictor - { - byte[] Decode(byte[] input, int predictor, int colors, int bitsPerComponent, int columns); - } } diff --git a/src/UglyToad.Pdf/Util/Hex.cs b/src/UglyToad.Pdf/Util/Hex.cs index 8737d549..46145a63 100644 --- a/src/UglyToad.Pdf/Util/Hex.cs +++ b/src/UglyToad.Pdf/Util/Hex.cs @@ -7,7 +7,7 @@ * * @author John Hewson */ - public class Hex + internal class Hex { /** * for hex conversion.