Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,888 changes: 1,888 additions & 0 deletions dotnet-install.sh

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/Refitter.Core/ApizrRegistrationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static string Generate(
.CapitalizeFirstCharacter()
: string.Empty;

if(isDependencyInjectionExtension)
if (isDependencyInjectionExtension)
methodName = hasManyApis ? $"Configure{formatedTitle}ApizrManagers" : $"Configure{formatedTitle}ApizrManager";
else
methodName = hasManyApis ? $"Build{formatedTitle}ApizrManagers" : $"Build{formatedTitle}ApizrManager";
Expand Down Expand Up @@ -209,7 +209,7 @@ public static string Generate(
$$"""
using Mapster;
""");
if(isDependencyInjectionExtension)
if (isDependencyInjectionExtension)
usingsCodeBuilder.AppendLine(
$$"""
using MapsterMapper;
Expand All @@ -225,7 +225,7 @@ public static string Generate(
break;
}

if(settings.ApizrSettings.WithPriority)
if (settings.ApizrSettings.WithPriority)
{
apizrPackages.Add(ApizrPackages.Apizr_Integrations_Fusillade);
optionsCodeBuilder.AppendLine();
Expand Down Expand Up @@ -381,7 +381,7 @@ public static partial class IServiceCollectionExtensions
/// </summary>
/// <param name="optionsBuilder">Adjust common shared options</param>
/// <returns></returns>
""");
""");
}

code.AppendLine(
Expand Down Expand Up @@ -409,7 +409,7 @@ public static partial class IServiceCollectionExtensions
""");
for (int i = 0; i < interfaceNames.Length; i++)
{
if(i > 0)
if (i > 0)
code.AppendLine();

code.Append(
Expand Down Expand Up @@ -462,7 +462,7 @@ public static partial class IServiceCollectionExtensions
/// </summary>
/// <param name="optionsBuilder">Adjust common shared options</param>
/// <returns></returns>
""");
""");
}

code.AppendLine(
Expand All @@ -471,11 +471,11 @@ public static partial class IServiceCollectionExtensions
this IServiceCollection services,
""");

code.AppendLine(hasBaseUrl ?
code.AppendLine(hasBaseUrl ?
$$"""
Action<IApizrExtendedManagerOptionsBuilder>? optionsBuilder = null)
{
""" :
""" :
$$"""
Action<IApizrExtendedManagerOptionsBuilder> optionsBuilder)
{
Expand All @@ -491,7 +491,7 @@ public static partial class IServiceCollectionExtensions
#pragma warning disable RS1035
code.Remove(code.Length - Environment.NewLine.Length, Environment.NewLine.Length);
#pragma warning restore RS1035
}
}

#endregion
}
Expand Down Expand Up @@ -533,7 +533,7 @@ public static partial class ApizrRegistration
/// </summary>
/// <param name="optionsBuilder">Adjust common shared options</param>
/// <returns></returns>
""");
""");
}

code.AppendLine(
Expand Down Expand Up @@ -599,7 +599,7 @@ public static partial class ApizrRegistration
/// </summary>
/// <param name="optionsBuilder">Adjust common shared options</param>
/// <returns></returns>
""");
""");
}

code.AppendLine(
Expand All @@ -614,7 +614,7 @@ public static partial class ApizrRegistration
#pragma warning disable RS1035
code.Remove(code.Length - Environment.NewLine.Length, Environment.NewLine.Length);
#pragma warning restore RS1035
}
}

#endregion
}
Expand Down
14 changes: 7 additions & 7 deletions src/Refitter.Core/DependencyInjectionGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Globalization;
using System.Globalization;
using System.Text;

namespace Refitter.Core;
Expand Down Expand Up @@ -29,7 +29,7 @@ public static string Generate(
Action<IHttpClientBuilder>? builder = default,
RefitSettings? settings = default)
""";

var configureRefitClient = string.IsNullOrEmpty(iocSettings.BaseUrl)
? ".ConfigureHttpClient(c => c.BaseAddress = baseUrl)"
: $".ConfigureHttpClient(c => c.BaseAddress = new Uri(\"{iocSettings.BaseUrl}\"))";
Expand Down Expand Up @@ -76,7 +76,7 @@ public static partial class IServiceCollectionExtensions
"""");
foreach (var interfaceName in interfaceNames)
{
var clientBuilderName = $"clientBuilder{interfaceName}";
var clientBuilderName = $"clientBuilder{interfaceName}";
code.Append(
$$"""
var {{clientBuilderName}} = services
Expand All @@ -89,7 +89,7 @@ public static partial class IServiceCollectionExtensions
code.AppendLine();
code.Append($" .AddHttpMessageHandler<{httpMessageHandler}>()");
}

code.Append(";");
code.AppendLine();

Expand All @@ -108,7 +108,7 @@ public static partial class IServiceCollectionExtensions
TimeSpan.FromSeconds({{durationString}}),
{{iocSettings.MaxRetryCount}})));
""");
}
}
else if (iocSettings.TransientErrorHandler == TransientErrorHandler.HttpResilience)
{
var durationString = iocSettings.FirstBackoffRetryInSeconds.ToString(CultureInfo.InvariantCulture);
Expand All @@ -132,7 +132,7 @@ public static partial class IServiceCollectionExtensions
code.AppendLine($" builder?.Invoke({clientBuilderName});");
code.AppendLine();
}

#pragma warning disable RS1035
code.Remove(code.Length - Environment.NewLine.Length, Environment.NewLine.Length);
#pragma warning restore RS1035
Expand All @@ -144,4 +144,4 @@ public static partial class IServiceCollectionExtensions
code.AppendLine();
return code.ToString();
}
}
}
2 changes: 1 addition & 1 deletion src/Refitter.Core/EnumExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Reflection;

Expand Down
4 changes: 2 additions & 2 deletions src/Refitter.Core/FilenameConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public static class TypenameConstants
/// The typename for Refit interfaces.
/// </summary>
public const string RefitInterfaces = "RefitInterfaces";

/// <summary>
/// The typename for contracts.
/// </summary>
public const string Contracts = "Contracts";

/// <summary>
/// The typename for dependency injection.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Refitter.Core/IdentifierUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Refitter.Core;
namespace Refitter.Core;

internal static class IdentifierUtils
{
Expand Down
14 changes: 7 additions & 7 deletions src/Refitter.Core/OpenApiDocumentFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net;
using System.Net;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Readers;
using NSwag;
Expand Down Expand Up @@ -37,7 +37,7 @@ public static async Task<OpenApiDocument> CreateAsync(string openApiPath)
return await OpenApiDocument.FromJsonAsync(json);
}
catch
{
{
return await CreateUsingNSwagAsync(openApiPath);
}
}
Expand All @@ -47,13 +47,13 @@ private static async Task<OpenApiDocument> CreateUsingNSwagAsync(string openApiP
if (IsHttp(openApiPath))
{
var content = await GetHttpContent(openApiPath);
return IsYaml(openApiPath)
? await OpenApiYamlDocument.FromYamlAsync(content)
return IsYaml(openApiPath)
? await OpenApiYamlDocument.FromYamlAsync(content)
: await OpenApiDocument.FromJsonAsync(content);
}

return IsYaml(openApiPath)
? await OpenApiYamlDocument.FromFileAsync(openApiPath)
return IsYaml(openApiPath)
? await OpenApiYamlDocument.FromFileAsync(openApiPath)
: await OpenApiDocument.FromFileAsync(openApiPath);
}

Expand Down Expand Up @@ -111,4 +111,4 @@ private static bool IsYaml(string path)
{
return path.EndsWith("yaml") || path.EndsWith("yml");
}
}
}
4 changes: 2 additions & 2 deletions src/Refitter.Core/OperationNameGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using NSwag;
using NSwag.CodeGeneration.OperationNameGenerators;
using GeneratorType = Refitter.Core.OperationNameGeneratorTypes;
Expand Down Expand Up @@ -93,4 +93,4 @@ private bool CheckForDuplicateOperationIds(

return operationNames.Distinct().Count() != operationNames.Count;
}
}
}
6 changes: 3 additions & 3 deletions src/Refitter.Core/ParameterExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ private static string GetQueryAttribute(CSharpParameterModel parameter, RefitGen
{ parameter.IsDate: true, settings.CodeGeneratorSettings.DateFormat: not null }
=> $"Query(Format = \"{settings.CodeGeneratorSettings?.DateFormat}\")",
{
parameter.IsDateOrDateTime: true, parameter.Schema.Format: "date-time",
settings.CodeGeneratorSettings.DateTimeFormat: not null
} => $"Query(Format = \"{settings.CodeGeneratorSettings?.DateTimeFormat}\")",
parameter.IsDateOrDateTime: true, parameter.Schema.Format: "date-time",
settings.CodeGeneratorSettings.DateTimeFormat: not null
} => $"Query(Format = \"{settings.CodeGeneratorSettings?.DateTimeFormat}\")",
_ => "Query",
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/Refitter.Core/RefitGeneratedCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public override string ToString()
{
return SourceCode;
}
}
}
2 changes: 1 addition & 1 deletion src/Refitter.Core/RefitInterfaceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private string GenerateInterfaceBody(out string? dynamicQuerystringParameters)
.AppendLine($"{Separator}{Separator}{returnType} {operationName}({parametersString});")
.AppendLine();

if (parametersString.Contains("?") && settings is {OptionalParameters: true, ApizrSettings: not null})
if (parametersString.Contains("?") && settings is { OptionalParameters: true, ApizrSettings: not null })
{
if (settings.GenerateXmlDocCodeComments)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Refitter.Core/SchemaCleaner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;
using NJsonSchema;
using NSwag;

Expand Down
14 changes: 7 additions & 7 deletions src/Refitter.Core/Settings/CacheProviderType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Refitter.Core
namespace Refitter.Core
{
/// <summary>
/// Enumeration of cache provider types.
Expand All @@ -9,30 +9,30 @@ public enum CacheProviderType
/// No cache provider.
/// </summary>
None,

/// <summary>
/// Akavache cache provider.
/// </summary>
Akavache,

/// <summary>
/// MonkeyCache cache provider.
/// </summary>
MonkeyCache,

/// <summary>
/// In-memory cache provider.
/// </summary>
InMemory,

/// <summary>
/// Distributed cache as string provider.
/// </summary>
DistributedAsString,

/// <summary>
/// Distributed cache as byte array provider.
/// </summary>
DistributedAsByteArray,
}
}
}
8 changes: 4 additions & 4 deletions src/Refitter.Core/Settings/MappingProviderType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Refitter.Core
namespace Refitter.Core
{
/// <summary>
/// Enumeration of mapping provider types.
Expand All @@ -9,15 +9,15 @@ public enum MappingProviderType
/// No mapping provider.
/// </summary>
None,

/// <summary>
/// AutoMapper mapping provider.
/// </summary>
AutoMapper,

/// <summary>
/// Mapster mapping provider.
/// </summary>
Mapster
}
}
}
2 changes: 1 addition & 1 deletion src/Refitter.Core/Settings/OperationNameGeneratorTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;

namespace Refitter.Core;

Expand Down
4 changes: 2 additions & 2 deletions src/Refitter.Core/Settings/RefitGeneratorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class RefitGeneratorSettings
/// Default output folder for generated files.
/// </summary>
public const string DefaultOutputFolder = "./Generated";

/// <summary>
/// Default namespace for generated code.
/// </summary>
Expand Down Expand Up @@ -365,7 +365,7 @@ payloads with (yet) unknown types are offered by newer versions of an API
/// <summary>
/// Gets or sets the parameter name generator for customizing parameter names.
/// </summary>
[JsonIgnore]
[JsonIgnore]
public IParameterNameGenerator? ParameterNameGenerator { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Refitter.Core/StringCasingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ public static string ConvertSnakeCaseToPascalCase(this string str)

return string.Join(string.Empty, parts);
}
}
}
2 changes: 1 addition & 1 deletion src/Refitter.Core/WellKnownNamesspaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public static string TrimImportedNamespaces(string returnTypeParameter) =>
.Select(s => returnTypeParameter.Replace(s + ".", string.Empty))
.FirstOrDefault() ??
returnTypeParameter;
}
}
Loading
Loading