Skip to content

Commit

Permalink
chore: refactore based on new .editorconfig rules
Browse files Browse the repository at this point in the history
  • Loading branch information
bielu committed Sep 22, 2024
1 parent 34bdb86 commit 42444f6
Show file tree
Hide file tree
Showing 38 changed files with 765 additions and 190 deletions.
535 changes: 535 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .github/workflows/buildAndPublishPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
branches: [ $default-branch ]
pull_request:
branches:
- master
- main
- */main

workflow_dispatch:

Expand Down
33 changes: 17 additions & 16 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project>
<Import Project="../version.props"/>
<PropertyGroup>
<Title>$(MSBuildProjectName)</Title>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<AssemblyVersion>$(Version)</AssemblyVersion>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<Import Project="../version.props"/>
<PropertyGroup>
<Title>$(MSBuildProjectName)</Title>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<AssemblyVersion>$(Version)</AssemblyVersion>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
<WarningsNotAsErrors>$(WarningsNotAsErrors);CA1848;CA2254</WarningsNotAsErrors>
</PropertyGroup>

<PropertyGroup>
<Authors>Arkadiusz Biel</Authors>
<PackageOutputPath>$(MSBuildProjectDirectory)/../../dist</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<Content Include="buildTransitive\**" PackagePath="buildTransitive" />
<Content Include="Schema\appsettings-schema.*.json" PackagePath="Schema" />
</ItemGroup>
<PropertyGroup>
<Authors>Arkadiusz Biel</Authors>
<PackageOutputPath>$(MSBuildProjectDirectory)/../../dist</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<Content Include="buildTransitive\**" PackagePath="buildTransitive"/>
<Content Include="Schema\appsettings-schema.*.json" PackagePath="Schema"/>
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AWSSDK.CloudFront" Version="3.7.301.21" />
<PackageVersion Include="Azure.Identity" Version="1.10.4" />
<PackageVersion Include="Azure.ResourceManager" Version="1.9.0" />
<PackageVersion Include="Azure.ResourceManager.Cdn" Version="1.2.0" />
<PackageVersion Include="Azure.ResourceManager.FrontDoor" Version="1.2.0" />
<PackageVersion Include="bielu.SchemaGenerator.Build" Version="1.0.0-alpha.50" />
<PackageVersion Include="bielu.SchemaGenerator.Core" Version="1.0.0-alpha.50" />
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="NJsonSchema" Version="10.9.0" />
<PackageVersion Include="NSwag.AspNetCore" Version="13.20.0" />
<PackageVersion Include="NSwag.CodeGeneration" Version="13.20.0" />
<PackageVersion Include="NSwag.MSBuild" Version="13.20.0" />
<PackageVersion Include="Scrutor" Version="4.2.2" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="Umbraco.Cms" Version="10.7.0" />
<PackageVersion Include="Umbraco.Cms.Core" Version="10.7.0" />
<PackageVersion Include="Umbraco.Cms.Infrastructure" Version="10.7.0" />
<PackageVersion Include="Umbraco.Cms.Web.BackOffice" Version="10.7.0" />
<PackageVersion Include="Umbraco.Cms.Web.Common" Version="10.7.0" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions src/SchemaGenerator/SchemaGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="bielu.SchemaGenerator.Build" Version="1.0.0-alpha.50" />
<PackageReference Include="NJsonSchema" Version="10.9.0" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="bielu.SchemaGenerator.Build" />
<PackageReference Include="NJsonSchema" />
<PackageReference Include="CommandLineParser" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/bielu.Umbraco.Cdn.Abstraction/Services/ICdnManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace bielu.Umbraco.Cdn.Services;

public interface ICdnManager
{
Task<IEnumerable<Provider>> GetProviders(int guid);
Task<IEnumerable<Provider>> GetProviders(int id);
Task<Provider> GetProvider(string id);
Task<ICdnService> GetService(string id);
Task<IEnumerable<ICdnService>> GetServices();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<EmbedRazorGenerateSources>true</EmbedRazorGenerateSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Umbraco.Cms.Core" Version="10.7.0" />
<PackageReference Include="Umbraco.Cms.Core" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/bielu.Umbraco.Cdn.Akamai/Configuration/AkamaiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class AkamaiOptions : ConfigurationBaseOptions
{
[SchemaPrefix]
[JsonIgnore]
public static string SectionName = $"{CdnConstants.CdnConfigSectionName}:Akamai";
public static readonly string SectionName = $"{CdnConstants.CdnConfigSectionName}:Akamai";
public string BaseUrl { get; set; } ="https://api.ccu.akamai.com/ccu/v3";
public Network6 Network { get; set; } = Network6.Production;
public List<string> SupportedHosts { get; set; } = new List<string>();
public string SwitchKey { get; set; }
}
}
6 changes: 3 additions & 3 deletions src/bielu.Umbraco.Cdn.Akamai/Services/AkamaiCdnService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<IEnumerable<Status>> PurgePages(IEnumerable<string> urls)
return await ParseStatus(response);
}

private async Task<IEnumerable<Status>> ParseStatus(Response6 response)
private static async Task<IEnumerable<Status>> ParseStatus(Response6 response)
{
var finalResponse = new Status();
finalResponse.Success = response.HttpStatus == 201 || response.HttpStatus == 200;
Expand Down Expand Up @@ -97,7 +97,7 @@ public async Task<IEnumerable<Status>> PurgeByAssignedHostnames(IEnumerable<stri
}
}

private async Task<Status> ParseStatus(Response3 response)
private static async Task<Status> ParseStatus(Response3 response)
{
var finalResponse = new Status();
finalResponse.Success = response.Status == Response3Status.SUCCEEDED ;
Expand All @@ -112,4 +112,4 @@ public async Task<IList<string>> GetSupportedHostnames()
return _options.SupportedHosts; // Akamai does not return a list of supported hosts, so we use configuration instead
}
}
}
}
10 changes: 5 additions & 5 deletions src/bielu.Umbraco.Cdn.Akamai/bielu.Umbraco.Cdn.Akamai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<PackageTags>umbraco-marketplace;umbraco;akamai;</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="bielu.SchemaGenerator.Core" Version="1.0.0-alpha.50" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSwag.MSBuild" Version="13.20.0">
<PackageReference Include="bielu.SchemaGenerator.Core" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NSwag.MSBuild">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Scrutor" Version="4.2.2" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="Scrutor" />
<PackageReference Include="System.ComponentModel.Annotations" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bielu.Umbraco.Cdn.Core\bielu.Umbraco.Cdn.Core.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace bielu.Umbraco.Cdn.Aws.Configuration;
public class CloudFrontOptions : ConfigurationBaseOptions
{
[SchemaPrefix] [JsonIgnore]
public static string SectionName = $"{CdnConstants.CdnConfigSectionName}:AWS:CloudFront";
public static readonly string SectionName = $"{CdnConstants.CdnConfigSectionName}:AWS:CloudFront";

[JsonIgnore]
public RegionEndpoint Region
Expand All @@ -21,4 +21,4 @@ public RegionEndpoint Region

public string SecretKey { get; set; }
public string AccessKey { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using bielu.Umbraco.Cdn.Aws.Configuration;
using bielu.Umbraco.Cdn.Aws.Services;
using bielu.Umbraco.Cdn.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.DependencyInjection;

Expand All @@ -21,8 +23,9 @@ public static IUmbracoBuilder AddAwsCloudFrontCdnProvider(
.AsImplementedInterfaces()
.WithTransientLifetime());
builder.Services.AddSingleton<IAmazonCloudFrontClientFactory, AmazonCloudFrontClientFactory>();

var positionOptions = new CloudFrontOptions();
builder.Config.GetSection(CloudFrontOptions.SectionName).Bind(positionOptions);
return builder;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Amazon.CloudFront;
Expand Down Expand Up @@ -53,7 +54,7 @@ public async Task<IEnumerable<Status>> PurgePages(IEnumerable<string> urls)
oRequest.DistributionId = domain.Id;
oRequest.InvalidationBatch = new InvalidationBatch
{
CallerReference = DateTime.Now.Ticks.ToString(),
CallerReference = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture),
Paths = new Paths
{
Items = urls.ToList<string>(),
Expand All @@ -79,7 +80,7 @@ public async Task<IEnumerable<Status>> PurgePages(IEnumerable<string> urls)
}
catch (Exception e)
{
_logger.LogError(e, "Error purging cache for zone(id: {id}): {name}", domain.Id, domain.Name);
_logger.LogError(e, "Error purging cache for zone(id: {Id}): {Name}", domain.Id, domain.Name);
statuses.Add(new Status()
{
Success = false,
Expand Down Expand Up @@ -120,10 +121,10 @@ public async Task<IEnumerable<Status>> PurgeAll()
Items = new List<string> { "/*" },
Quantity = 1
},
CallerReference = DateTime.Now.Ticks.ToString()
CallerReference = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture)
}
});
_logger.LogInformation("Cache refreshed, domains for zone(id: {id}): {name}", domain.Id, domain.Name);
_logger.LogInformation("Cache refreshed, domains for zone(id: {Id}): {Name}", domain.Id, domain.Name);
var isError = oResponse.HttpStatusCode == System.Net.HttpStatusCode.OK;
var status = oResponse.ResponseMetadata;

Expand Down Expand Up @@ -153,4 +154,4 @@ public async Task<IList<string>> GetSupportedHostnames()
return (await _client.ListDistributionsAsync()).DistributionList.Items.Select(x => x.DomainName).Distinct()
.ToList();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.CloudFront" Version="3.7.301.21" />
<PackageReference Include="bielu.SchemaGenerator.Core" Version="1.0.0-alpha.50" />
<PackageReference Include="Scrutor" Version="3.3.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0"/>
<PackageReference Include="Umbraco.Cms.Core" Version="10.7.0" />
<PackageReference Include="AWSSDK.CloudFront" />
<PackageReference Include="bielu.SchemaGenerator.Core" />
<PackageReference Include="Scrutor" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Umbraco.Cms.Core" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bielu.Umbraco.Cdn.Abstraction\bielu.Umbraco.Cdn.Abstraction.csproj"/>
<ProjectReference Include="..\bielu.Umbraco.Cdn.Abstraction\bielu.Umbraco.Cdn.Abstraction.csproj" />
<ProjectReference Include="..\bielu.Umbraco.Cdn.Core\bielu.Umbraco.Cdn.Core.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class AzureCdnOptions : AzureBaseOptions
{
[SchemaPrefix]
[JsonIgnore]
public static string SectionName = $"{CdnConstants.CdnConfigSectionName}:Azure:Cdn";
public static readonly string SectionName = $"{CdnConstants.CdnConfigSectionName}:Azure:Cdn";
public string FrontDoorName { get; set; }
}
}
8 changes: 4 additions & 4 deletions src/bielu.Umbraco.Cdn.Azure.Cdn/Services/AzureCdnService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public async Task<IEnumerable<Status>> PurgePages(IEnumerable<string> urls)
foreach (var endpoint in endpoints)
{
var requestUrls = urls
.Where(x => Uri.TryCreate(x, UriKind.Absolute, out var targetUri) &&
.Where(x => Uri.TryCreate(x, UriKind.Absolute, out var targetUri) &&
targetUri.Host.Equals(endpoint.Data.HostName, StringComparison.OrdinalIgnoreCase))
.Select(x => new Uri(x, UriKind.Absolute).AbsolutePath)
.Distinct();
if(!requestUrls.Any()) continue;
var request =
await endpoint.PurgeContentAsync(WaitUntil.Started, new FrontDoorPurgeContent(requestUrls));
_logger.LogInformation("Cache refreshed, domains: {urls} for endpoint(id: {id}): {name}",
_logger.LogInformation("Cache refreshed, domains: {Urls} for endpoint(id: {Id}): {Name}",
string.Join(",", requestUrls), endpoint.Id, endpoint.Data.Name);
var status = await request.UpdateStatusAsync();
statuses.Add(new Status()
Expand Down Expand Up @@ -71,7 +71,7 @@ public async Task<IEnumerable<Status>> PurgeAll()
{
var request = await endpoint.PurgeContentAsync(WaitUntil.Started,
new FrontDoorPurgeContent(new List<string>() { "/*" }));
_logger.LogInformation("Cache refreshed, domains for zone(id: {id}): {name}", endpoint.Id, endpoint.Data.Name);
_logger.LogInformation("Cache refreshed, domains for zone(id: {Id}): {Name}", endpoint.Id, endpoint.Data.Name);
var status = await request.UpdateStatusAsync();
statuses.Add(new Status()
{
Expand Down Expand Up @@ -108,4 +108,4 @@ private async Task<List<FrontDoorEndpointResource>> GetEndpoints()
.ToListAsync();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.ResourceManager.Cdn" Version="1.2.0" />
<PackageReference Include="bielu.SchemaGenerator.Core" Version="1.0.0-alpha.50" />
<PackageReference Include="Scrutor" Version="3.3.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0"/>
<PackageReference Include="Umbraco.Cms.Core" Version="10.7.0" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.ResourceManager.Cdn" />
<PackageReference Include="bielu.SchemaGenerator.Core" />
<PackageReference Include="Scrutor" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Umbraco.Cms.Core" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bielu.Umbraco.Cdn.Abstraction\bielu.Umbraco.Cdn.Abstraction.csproj"/>
<ProjectReference Include="..\bielu.Umbraco.Cdn.Abstraction\bielu.Umbraco.Cdn.Abstraction.csproj" />
<ProjectReference Include="..\bielu.Umbraco.Cdn.Azure.Common\bielu.Umbraco.Cdn.Azure.Common.csproj" />
<ProjectReference Include="..\bielu.Umbraco.Cdn.Core\bielu.Umbraco.Cdn.Core.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.ResourceManager" Version="1.9.0" />
<PackageReference Include="Scrutor" Version="3.3.0"/>
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.ResourceManager" />
<PackageReference Include="Scrutor" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class FrontDoorOptions : AzureBaseOptions
{
[SchemaPrefix]
[JsonIgnore]
public static string SectionName = $"{CdnConstants.CdnConfigSectionName}:Azure:FrontDoor";
public static readonly string SectionName = $"{CdnConstants.CdnConfigSectionName}:Azure:FrontDoor";
public string FrontDoorName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task<IEnumerable<Status>> PurgePages(IEnumerable<string> urls)
if(!requestUrls.Any()) continue;
var request =
await _client.PurgeContentAsync(WaitUntil.Started, new FrontDoorEndpointPurgeContent(requestUrls));
_logger.LogInformation("Cache refreshed, domains: {urls} for zone(id: {id}): {name}",
_logger.LogInformation("Cache refreshed, domains: {Urls} for zone(id: {Id}): {Name}",
string.Join(",", requestUrls), domain.Id, domain.Name);
var status = await request.UpdateStatusAsync();
statuses.Add(new Status()
Expand Down Expand Up @@ -79,7 +79,7 @@ public async Task<IEnumerable<Status>> PurgeAll()

var request = await _client.PurgeContentAsync(WaitUntil.Started,
new FrontDoorEndpointPurgeContent(new List<string>() { "/*" }));
_logger.LogInformation("Cache refreshed, domains for zone(id: {id}): {name}", domain.Id, domain.Name);
_logger.LogInformation("Cache refreshed, domains for zone(id: {Id}): {Name}", domain.Id, domain.Name);
var status = await request.UpdateStatusAsync();
statuses.Add(new Status()
{
Expand Down Expand Up @@ -120,7 +120,7 @@ private async Task<IEnumerable<Status>> PurgeAll(params string[] paths)

var request = await _client.PurgeContentAsync(WaitUntil.Started,
new FrontDoorEndpointPurgeContent(new List<string>() { "/*" }));
_logger.LogInformation("Cache refreshed, domains for zone(id: {id}): {name}", domain.Id, domain.Name);
_logger.LogInformation("Cache refreshed, domains for zone(id: {Id}): {Name}", domain.Id, domain.Name);
var status = await request.UpdateStatusAsync();
statuses.Add(new Status()
{
Expand All @@ -138,4 +138,4 @@ private async Task<IEnumerable<Status>> PurgeAll(params string[] paths)
return statuses;
}
}
}
}
Loading

0 comments on commit 42444f6

Please sign in to comment.