Skip to content

Commit

Permalink
Removed Annotations. Implicit Using. v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaben committed Aug 10, 2024
1 parent ea062f5 commit eda6e96
Show file tree
Hide file tree
Showing 66 changed files with 394 additions and 753 deletions.
74 changes: 74 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,77 @@

# IDE0042: Deconstruct variable declaration
dotnet_diagnostic.IDE0042.severity = none
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_indent_labels = one_less_than_current

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
2 changes: 2 additions & 0 deletions GotenbergSharpApiClient.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
limitations under the License.</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECodeCleanup_002EFileHeader_002EFileHeaderSettingsMigrate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Backoff/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cargman/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Consts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=deliverables/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=epub/@EntryIndexedValue">True</s:Boolean>
Expand All @@ -24,6 +25,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=fodt/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gotenberg/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gotenberg_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Jaben/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Libre/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pdfs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=potm/@EntryIndexedValue">True</s:Boolean>
Expand Down
24 changes: 2 additions & 22 deletions lib/Domain/Builders/BaseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
using Gotenberg.Sharp.API.Client.Domain.Requests;
using Gotenberg.Sharp.API.Client.Domain.Requests.Facets;

using JetBrains.Annotations;

namespace Gotenberg.Sharp.API.Client.Domain.Builders;

public abstract class BaseBuilder<TRequest, TBuilder>
public abstract class BaseBuilder<TRequest, TBuilder>(TRequest request)
where TRequest : BuildRequestBase
where TBuilder : BaseBuilder<TRequest, TBuilder>
{
protected BaseBuilder(TRequest request)
{
this.Request = request;
}

protected const string CallBuildAsyncErrorMessage =
"Request has asynchronous items. Call BuildAsync instead.";

protected readonly List<Task> BuildTasks = new();

protected virtual TRequest Request { get; }
protected virtual TRequest Request { get; } = request;

[PublicAPI]
public TBuilder ConfigureRequest(Action<ConfigBuilder> action)
{
if (action == null) throw new ArgumentNullException(nameof(action));
Expand All @@ -54,23 +37,20 @@ public TBuilder ConfigureRequest(Action<ConfigBuilder> action)
return (TBuilder)this;
}

[PublicAPI]
public TBuilder ConfigureRequest(RequestConfig config)
{
this.Request.Config = config ?? throw new ArgumentNullException(nameof(config));

return (TBuilder)this;
}

[PublicAPI]
public virtual TRequest Build()
{
if (this.BuildTasks.Any()) throw new InvalidOperationException(CallBuildAsyncErrorMessage);

return this.Request;
}

[PublicAPI]
public virtual async Task<TRequest> BuildAsync()
{
if (this.BuildTasks.Any()) await Task.WhenAll(this.BuildTasks).ConfigureAwait(false);
Expand Down
26 changes: 4 additions & 22 deletions lib/Domain/Builders/BaseChromiumBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;

using Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
using Gotenberg.Sharp.API.Client.Domain.Requests;
using Gotenberg.Sharp.API.Client.Domain.Requests.Facets;

using JetBrains.Annotations;

namespace Gotenberg.Sharp.API.Client.Domain.Builders;

public abstract class BaseChromiumBuilder<TRequest, TBuilder> : BaseBuilder<TRequest, TBuilder>
public abstract class BaseChromiumBuilder<TRequest, TBuilder>(TRequest request)
: BaseBuilder<TRequest, TBuilder>(request)
where TRequest : ChromeRequest
where TBuilder : BaseChromiumBuilder<TRequest, TBuilder>
{
protected BaseChromiumBuilder([NotNull] TRequest request)
: base(request)
{
}

[PublicAPI]
public TBuilder WithDimensions(Action<DimensionBuilder> action)
{
if (action == null) throw new ArgumentNullException(nameof(action));
Expand All @@ -47,38 +33,34 @@ public TBuilder WithDimensions(Action<DimensionBuilder> action)
return (TBuilder)this;
}

[PublicAPI]
public TBuilder WithDimensions(Dimensions dimensions)
{
this.Request.Dimensions = dimensions ?? throw new ArgumentNullException(nameof(dimensions));
return (TBuilder)this;
}

[PublicAPI]
public TBuilder WithAssets(Action<AssetBuilder> action)
{
if (action == null) throw new ArgumentNullException(nameof(action));
action(new AssetBuilder(this.Request.Assets ??= new AssetDictionary()));
return (TBuilder)this;
}

[PublicAPI]
public TBuilder WithAsyncAssets(Func<AssetBuilder, Task> asyncAction)
{
if (asyncAction == null) throw new ArgumentNullException(nameof(asyncAction));
this.BuildTasks.Add(asyncAction(new AssetBuilder(this.Request.Assets ??= new AssetDictionary())));
this.BuildTasks.Add(
asyncAction(new AssetBuilder(this.Request.Assets ??= new AssetDictionary())));
return (TBuilder)this;
}

[PublicAPI]
public TBuilder SetConversionBehaviors(Action<HtmlConversionBehaviorBuilder> action)
{
if (action == null) throw new ArgumentNullException(nameof(action));
action(new HtmlConversionBehaviorBuilder(this.Request.ConversionBehaviors));
return (TBuilder)this;
}

[PublicAPI]
public TBuilder SetConversionBehaviors(HtmlConversionBehaviors behaviors)
{
this.Request.ConversionBehaviors =
Expand Down
21 changes: 5 additions & 16 deletions lib/Domain/Builders/BaseMergeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;

using Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
using Gotenberg.Sharp.API.Client.Domain.Requests;
using Gotenberg.Sharp.API.Client.Domain.Requests.Facets;

using JetBrains.Annotations;

namespace Gotenberg.Sharp.API.Client.Domain.Builders;

public abstract class BaseMergeBuilder<TRequest, TBuilder> : BaseBuilder<TRequest, TBuilder>
public abstract class BaseMergeBuilder<TRequest, TBuilder>(TRequest request)
: BaseBuilder<TRequest, TBuilder>(request)
where TRequest : BuildRequestBase
where TBuilder : BaseMergeBuilder<TRequest, TBuilder>
{
protected BaseMergeBuilder(TRequest request)
: base(request)
{
}

/// <summary>
/// This tells gotenberg to have OfficeLibre perform the conversion.
/// If you set <see cref="MergeOfficeRequest.UseNativePdfFormat" /> to true
/// then gotenberg will hand the work off to unoconv to do the work
/// </summary>
[PublicAPI]

public TBuilder SetPdfFormat(PdfFormats format)
{
this.Request.Format = format;
return (TBuilder)this;
}

[PublicAPI]

public TBuilder WithAssets(Action<AssetBuilder> action)
{
if (action == null) throw new ArgumentNullException(nameof(action));
Expand All @@ -55,7 +44,7 @@ public TBuilder WithAssets(Action<AssetBuilder> action)
return (TBuilder)this;
}

[PublicAPI]

public TBuilder WithAsyncAssets(Func<AssetBuilder, Task> asyncAction)
{
if (asyncAction == null) throw new ArgumentNullException(nameof(asyncAction));
Expand Down
33 changes: 12 additions & 21 deletions lib/Domain/Builders/Faceted/AssetBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

using Gotenberg.Sharp.API.Client.Domain.Requests;
using Gotenberg.Sharp.API.Client.Domain.Requests.Facets;
using Gotenberg.Sharp.API.Client.Extensions;

using JetBrains.Annotations;

namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted
{
Expand All @@ -35,7 +26,7 @@ internal AssetBuilder(AssetDictionary assets)
this._assets = assets;
}

[PublicAPI]

public AssetBuilder AddItem(string name, ContentItem value)
{
// ReSharper disable once ComplexConditionExpression
Expand All @@ -52,23 +43,23 @@ public AssetBuilder AddItem(string name, ContentItem value)
return this;
}

[PublicAPI]

public AssetBuilder AddItem(string name, string value) =>
AddItem(name, new ContentItem(value));

[PublicAPI]

public AssetBuilder AddItem(string name, byte[] value) =>
AddItem(name, new ContentItem(value));

[PublicAPI]

public AssetBuilder AddItem(string name, Stream value) =>
AddItem(name, new ContentItem(value));

#region 'n' assets

#region from dictionaries

[PublicAPI]

public AssetBuilder AddItems(Dictionary<string, ContentItem>? items)
{
foreach (var item in items.IfNullEmpty())
Expand All @@ -79,43 +70,43 @@ public AssetBuilder AddItems(Dictionary<string, ContentItem>? items)
return this;
}

[PublicAPI]

public AssetBuilder AddItems(Dictionary<string, string>? assets) =>
AddItems(assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)));

[PublicAPI]

public AssetBuilder AddItems(Dictionary<string, byte[]>? assets) =>
AddItems(assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)));

[PublicAPI]

public AssetBuilder AddItems(Dictionary<string, Stream>? assets) =>
AddItems(assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)));

#endregion

#region from KVP enumerables

[PublicAPI]

public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, ContentItem>> assets) =>
AddItems(
new Dictionary<string, ContentItem>(
assets?.ToDictionary(a => a.Key, a => a.Value) ??
throw new ArgumentNullException(nameof(assets))));

[PublicAPI]

public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, string>> assets) =>
AddItems(
new Dictionary<string, ContentItem>(
assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)) ??
throw new ArgumentNullException(nameof(assets))));

[PublicAPI]

public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, byte[]>> assets) =>
AddItems(
assets?.ToDictionary(a => a.Key, a => new ContentItem(a.Value)) ??
throw new ArgumentNullException(nameof(assets)));

[PublicAPI]

public AssetBuilder AddItems(IEnumerable<KeyValuePair<string, Stream>> assets) =>
AddItems(
assets?.ToDictionary(s => s.Key, a => new ContentItem(a.Value)) ??
Expand Down
Loading

0 comments on commit eda6e96

Please sign in to comment.