From e6c0c388a66f27cc32d7b3a0b5815657b2f2b55a Mon Sep 17 00:00:00 2001 From: gurustron Date: Fri, 18 Sep 2020 17:00:38 +0300 Subject: [PATCH] small QoL improvements - XML docs generation. --- Wkhtmltopdf.NetCore.Test/SmokeTest.cs | 12 ++++++------ .../Configuration/ExactPathProvider.cs | 2 +- .../Interfaces/IWkhtmltopdfPathProvider.cs | 3 +++ .../Configuration/LegacyPathProvider.cs | 4 ++-- .../RotativaPathAsPrefixPathProvider.cs | 4 ++-- .../Configuration/WkhtmltopdfConfiguration.cs | 9 +++++++-- .../Implementation/Interfaces/IWkhtmlDriver.cs | 3 +++ Wkhtmltopdf.NetCore/Implementation/WkhtmlDriver.cs | 10 ++++++++-- Wkhtmltopdf.NetCore/WkhtmlDriverException.cs | 6 ++++++ Wkhtmltopdf.NetCore/Wkhtmltopdf.NetCore.csproj | 2 ++ 10 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Wkhtmltopdf.NetCore.Test/SmokeTest.cs b/Wkhtmltopdf.NetCore.Test/SmokeTest.cs index c75c45e..44de718 100644 --- a/Wkhtmltopdf.NetCore.Test/SmokeTest.cs +++ b/Wkhtmltopdf.NetCore.Test/SmokeTest.cs @@ -13,17 +13,17 @@ public class SmokeTest [SetUp] public void SetRotativaPath() { -#pragma warning disable 612 +#pragma warning disable 618 WkhtmltopdfConfiguration.RotativaPath = AppDomain.CurrentDomain.BaseDirectory + "Rotativa"; -#pragma warning restore 612 +#pragma warning restore 618 } [TearDown] public void ClearRotativaPath() { -#pragma warning disable 612 +#pragma warning disable 618 WkhtmltopdfConfiguration.RotativaPath = null; -#pragma warning restore 612 +#pragma warning restore 618 } [Test] @@ -55,9 +55,9 @@ public void LegacyResolutionWorks() using var host = Host.CreateDefaultBuilder() .ConfigureWebHostDefaults(webBuilder => { -#pragma warning disable 612 +#pragma warning disable 618 webBuilder.ConfigureServices(services => services.AddWkhtmltopdf()); -#pragma warning restore 612 +#pragma warning restore 618 }) .Build(); diff --git a/Wkhtmltopdf.NetCore/Configuration/ExactPathProvider.cs b/Wkhtmltopdf.NetCore/Configuration/ExactPathProvider.cs index b658c10..28a3c07 100644 --- a/Wkhtmltopdf.NetCore/Configuration/ExactPathProvider.cs +++ b/Wkhtmltopdf.NetCore/Configuration/ExactPathProvider.cs @@ -16,7 +16,7 @@ public ExactPathProvider(string path = "wkhtmltopdf") _path = path; } - /* */ + /** */ public string GetPath() => _path; } } diff --git a/Wkhtmltopdf.NetCore/Configuration/Interfaces/IWkhtmltopdfPathProvider.cs b/Wkhtmltopdf.NetCore/Configuration/Interfaces/IWkhtmltopdfPathProvider.cs index 6316f0c..ea01534 100644 --- a/Wkhtmltopdf.NetCore/Configuration/Interfaces/IWkhtmltopdfPathProvider.cs +++ b/Wkhtmltopdf.NetCore/Configuration/Interfaces/IWkhtmltopdfPathProvider.cs @@ -1,5 +1,8 @@ namespace Wkhtmltopdf.NetCore { + /// + /// Provides path to wkhtmltopdf. + /// public interface IWkhtmltopdfPathProvider { /// diff --git a/Wkhtmltopdf.NetCore/Configuration/LegacyPathProvider.cs b/Wkhtmltopdf.NetCore/Configuration/LegacyPathProvider.cs index d38b109..4c6dc55 100644 --- a/Wkhtmltopdf.NetCore/Configuration/LegacyPathProvider.cs +++ b/Wkhtmltopdf.NetCore/Configuration/LegacyPathProvider.cs @@ -12,7 +12,7 @@ public class LegacyPathProvider : IWkhtmltopdfPathProvider private readonly string _rotativaLocation; /// - /// Constructs path from 's base directory, , + /// Constructs path from 's base directory, />, /// /// OS dependent folder and executable name. /// @@ -45,7 +45,7 @@ public LegacyPathProvider(string wkhtmltopdfRelativePath = "Rotativa") } } - /* */ + /** */ public string GetPath() => _rotativaLocation; } } diff --git a/Wkhtmltopdf.NetCore/Configuration/RotativaPathAsPrefixPathProvider.cs b/Wkhtmltopdf.NetCore/Configuration/RotativaPathAsPrefixPathProvider.cs index cf54d72..66a07fb 100644 --- a/Wkhtmltopdf.NetCore/Configuration/RotativaPathAsPrefixPathProvider.cs +++ b/Wkhtmltopdf.NetCore/Configuration/RotativaPathAsPrefixPathProvider.cs @@ -16,9 +16,9 @@ internal class RotativaPathAsPrefixPathProvider : IWkhtmltopdfPathProvider /* */ public string GetPath() { -#pragma warning disable 612 +#pragma warning disable 618 var wkhtmlPath = WkhtmltopdfConfiguration.RotativaPath; -#pragma warning restore 612 +#pragma warning restore 618 string rotativaLocation; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) diff --git a/Wkhtmltopdf.NetCore/Configuration/WkhtmltopdfConfiguration.cs b/Wkhtmltopdf.NetCore/Configuration/WkhtmltopdfConfiguration.cs index 7700eca..156ab03 100644 --- a/Wkhtmltopdf.NetCore/Configuration/WkhtmltopdfConfiguration.cs +++ b/Wkhtmltopdf.NetCore/Configuration/WkhtmltopdfConfiguration.cs @@ -8,9 +8,14 @@ namespace Wkhtmltopdf.NetCore { + /// + /// Extension methods for setting up Wkhtmltopdf.NetCore services. + /// public static class WkhtmltopdfConfiguration { - [Obsolete] public static string RotativaPath { get; set; } + [Obsolete("Use " + nameof(AddWkhtmltopdf) + " accepting " + nameof(IMvcBuilder) + + " with suitable " + nameof(IWkhtmltopdfPathProvider) + ".")] + public static string RotativaPath { get; set; } /// /// Setup Rotativa library @@ -20,7 +25,7 @@ public static class WkhtmltopdfConfiguration /// Optional. Relative path to the directory containing wkhtmltopdf. /// Default is "Rotativa". Download at https://wkhtmltopdf.org/downloads.html /// - [Obsolete] + [Obsolete("Use " + nameof(AddWkhtmltopdf) + " accepting " + nameof(IMvcBuilder) + ".")] public static IServiceCollection AddWkhtmltopdf(this IServiceCollection services, string wkhtmltopdfRelativePath = "Rotativa") { diff --git a/Wkhtmltopdf.NetCore/Implementation/Interfaces/IWkhtmlDriver.cs b/Wkhtmltopdf.NetCore/Implementation/Interfaces/IWkhtmlDriver.cs index e62329c..6049674 100644 --- a/Wkhtmltopdf.NetCore/Implementation/Interfaces/IWkhtmlDriver.cs +++ b/Wkhtmltopdf.NetCore/Implementation/Interfaces/IWkhtmlDriver.cs @@ -2,6 +2,9 @@ namespace Wkhtmltopdf.NetCore { + /// + /// Invokes the wkhtmltopdf. + /// public interface IWkhtmlDriver { /// diff --git a/Wkhtmltopdf.NetCore/Implementation/WkhtmlDriver.cs b/Wkhtmltopdf.NetCore/Implementation/WkhtmlDriver.cs index 48f6854..476297b 100644 --- a/Wkhtmltopdf.NetCore/Implementation/WkhtmlDriver.cs +++ b/Wkhtmltopdf.NetCore/Implementation/WkhtmlDriver.cs @@ -7,16 +7,22 @@ namespace Wkhtmltopdf.NetCore { + /// + /// Invokes the wkhtmltopdf. + /// public class WkhtmlDriver : IWkhtmlDriver { private readonly IWkhtmltopdfPathProvider _pathProvider; + /// + /// Constructs new instance of . + /// public WkhtmlDriver(IWkhtmltopdfPathProvider pathProvider = null) { _pathProvider = pathProvider ?? RotativaPathAsPrefixPathProvider.Default; } - /* */ + /** */ public byte[] Convert(IConvertOptions options, string html) => Convert(_pathProvider, options.GetConvertOptions(), html); /// @@ -26,7 +32,7 @@ public WkhtmlDriver(IWkhtmltopdfPathProvider pathProvider = null) /// Switches that will be passed to wkhtmltopdf binary. /// String containing HTML code that should be converted to PDF. /// PDF as byte array. - [Obsolete] + [Obsolete("Use injected " + nameof(IWkhtmlDriver) + ".")] public static byte[] Convert(string wkhtmlPath, string switches, string html) { string rotativaLocation; diff --git a/Wkhtmltopdf.NetCore/WkhtmlDriverException.cs b/Wkhtmltopdf.NetCore/WkhtmlDriverException.cs index a5b218f..88c8dfd 100644 --- a/Wkhtmltopdf.NetCore/WkhtmlDriverException.cs +++ b/Wkhtmltopdf.NetCore/WkhtmlDriverException.cs @@ -2,9 +2,15 @@ namespace Wkhtmltopdf.NetCore { + /// + /// Custom Wkhtmltopdf.NetCore exception. + /// [Serializable] public class WkhtmlDriverException : Exception { + /// + /// Constructs new instance of + /// public WkhtmlDriverException(string message, Exception e) : base(message, e) { } diff --git a/Wkhtmltopdf.NetCore/Wkhtmltopdf.NetCore.csproj b/Wkhtmltopdf.NetCore/Wkhtmltopdf.NetCore.csproj index 6f1e011..58f82a5 100644 --- a/Wkhtmltopdf.NetCore/Wkhtmltopdf.NetCore.csproj +++ b/Wkhtmltopdf.NetCore/Wkhtmltopdf.NetCore.csproj @@ -5,6 +5,8 @@ 3.0.2.0 3.0.2.0 3.0.2 + true + $(NoWarn);1591 This project implements the library wkhtmltopdf for asp net core and a view engine, working in windows, macos, linux and docker. For more information about how to use it, go to https://github.com/fpanaccia/Wkhtmltopdf.NetCore.Example