Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .azure/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"value": "norwayeast"
}
}
}
}
64 changes: 64 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# EditorConfig is awesome: https://EditorConfig.org

# See also Directory.Build.Props for additional analyzer settings

root = true

[*]
# Enforce line endings to be LF
end_of_line = lf
# Enforce indentation to be 4 spaces
indent_style = spaces
indent_size = 4
# Insert a final new line at the end of the file
insert_final_newline = true

[*.cs]

# CA1848: Use the LoggerMessage delegates
# TODO: Possible performance improvement
dotnet_diagnostic.CA1848.severity = none

# Identifiers should not match keywords
dotnet_diagnostic.CA1716.severity = none

# Style faults should be warnings
dotnet_analyzer_diagnostic.category-Style.severity = warning

#
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity

# Enforce file scoped namespaces
csharp_style_namespace_declarations = file_scoped:suggestion
# Place 'using' directives outside of namespaces
csharp_using_directive_placement = outside_namespace:true

# Disabling this because of https://github.com/dotnet/roslyn/issues/41640
dotnet_diagnostic.IDE0005.severity = none
#
# # Disabling this because of https://github.com/dotnet/roslyn/issues/70826
# dotnet_diagnostic.IDE0028.severity = none
#
# # Primary constructors
# dotnet_diagnostic.IDE0290.severity = none

# Order 'using' directives with System.* appearing first
dotnet_sort_system_directives_first = true
# Suggest the use of var when the type is apparent
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
# Suggest using expression bodies
csharp_style_expression_bodied_methods = when_on_single_line
dotnet_diagnostic.IDE0022.severity = suggestion
# Don't mix non-braces and braces for ifs
csharp_prefer_braces = when_multiline

# "Expression body is never used"
dotnet_diagnostic.IDE0058.severity = none
# "'if' statement can be simplified"
dotnet_diagnostic.IDE0046.severity = suggestion
# "Do not declare static members on generic types"
dotnet_diagnostic.CA1000.severity = none
# "Instantiate argument exceptions correctly"
dotnet_diagnostic.CA2208.severity = suggestion
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
*.sh text eol=lf
**/all-tests.js eol=lf
* text eol=lf

###############################################################################
# Set default behavior for command prompt diff.
Expand Down
84 changes: 42 additions & 42 deletions .github/workflows/main_latidafunction.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy dotnet core app to Azure Function App - LatidaFunction
on:
push:
branches:
- main
workflow_dispatch:
env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '7.0.x' # set this to the dotnet version to use
jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 'Resolve Project Dependencies Using Dotnet'
shell: pwsh
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
dotnet build --configuration Release --output ./output
popd
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'LatidaFunction'
slot-name: 'Production'
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_5B804973F87844089C37A81BF22B1261 }}
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy dotnet core app to Azure Function App - LatidaFunction

on:
push:
branches:
- main
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '7.0.x' # set this to the dotnet version to use

jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: 'Resolve Project Dependencies Using Dotnet'
shell: pwsh
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
dotnet build --configuration Release --output ./output
popd

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'LatidaFunction'
slot-name: 'Production'
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_5B804973F87844089C37A81BF22B1261 }}
2 changes: 2 additions & 0 deletions Digdir.Domain.Dialogporten.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Digdir.Domain.Dialogporten.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{33E486B1-3279-4645-B536-AB640D560C45}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
docker-compose.yml = docker-compose.yml
README.md = README.md
EndProjectSection
Expand Down
14 changes: 14 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisMode>Recommended</AnalysisMode>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ public static IServiceCollection AddApplication(this IServiceCollection services
.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>))
.AddTransient(typeof(IPipelineBehavior<,>), typeof(DomainContextBehaviour<,>));

if (environment.IsDevelopment())
{
var localDeveloperSettings = configuration.GetLocalDevelopmentSettings();
services.Decorate<IUserService, LocalDevelopmentUserServiceDecorator>(
predicate:
localDeveloperSettings.UseLocalDevelopmentUser ||
localDeveloperSettings.UseLocalDevelopmentResourceRegister);
}
if (!environment.IsDevelopment()) return services;

var localDeveloperSettings = configuration.GetLocalDevelopmentSettings();
services.Decorate<IUserService, LocalDevelopmentUserServiceDecorator>(
predicate:
localDeveloperSettings.UseLocalDevelopmentUser ||
localDeveloperSettings.UseLocalDevelopmentResourceRegister);

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Digdir.Domain.Dialogporten.Application;
public sealed class ApplicationSettings
{
public const string ConfigurationSectionName = "Application";

public required DialogportenSettings Dialogporten { get; init; }
}

Expand All @@ -31,4 +31,4 @@ public DialogportenSettingsValidator()
{
RuleFor(x => x.BaseUri).NotEmpty().IsValidUri();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal sealed class DomainContextBehaviour<TRequest, TResponse> : IPipelineBeh

public DomainContextBehaviour(IDomainContext domainContext)
{

_domainContext = domainContext ?? throw new ArgumentNullException(nameof(domainContext));
}

Expand All @@ -38,7 +38,7 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
{
response = await next();
}
catch (DomainException ex)
catch (DomainException ex)
{
if (OneOfExtensions.TryConvertToOneOf(new DomainError(ex.Errors), out response))
{
Expand All @@ -55,11 +55,8 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe

var domainFailures = _domainContext.Pop();

if (OneOfExtensions.TryConvertToOneOf(new DomainError(domainFailures), out response))
{
return response;
}

throw new DomainException(domainFailures);
return OneOfExtensions.TryConvertToOneOf(new DomainError(domainFailures), out response)
? response
: throw new DomainException(domainFailures);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
.Where(x => x is not null)
.ToList();

if (!failures.Any())
if (failures.Count == 0)
{
return await next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static class Expressions
{
internal static Expression<Func<Localization, bool>> LocalizedSearchExpression(string? search, string? cultureCode)
{
return localization =>
(cultureCode == null || localization.CultureCode == cultureCode) &&
return localization =>
(cultureCode == null || localization.CultureCode == cultureCode) &&
EF.Functions.ILike(localization.Value, $"%{search}%");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public static IMappingExpression<TSource, TDest> IgnoreComplexDestinationPropert

private static bool IsSimple(this Type type)
{
if (type is null)
{
throw new ArgumentNullException(nameof(type));
}
ArgumentNullException.ThrowIfNull(type);

if (type.IsGenericType && type.GetGenericTypeDefinition() == GenericNullableType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static bool TryGetOrgNumber(this ClaimsPrincipal claimsPrincipal, [NotNul
}

if (!consumerClaimJson.TryGetValue(AuthorityClaim, out var authority) ||
!string.Equals(authority, AuthorityValue, StringComparison.InvariantCultureIgnoreCase))
!string.Equals(authority, AuthorityValue, StringComparison.OrdinalIgnoreCase))
{
return false;
}
Expand All @@ -54,4 +54,4 @@ public static bool TryGetOrgNumber(this ClaimsPrincipal claimsPrincipal, [NotNul

internal static bool TryGetOrgNumber(this IUser user, [NotNullWhen(true)] out string? orgNumber) =>
user.GetPrincipal().TryGetOrgNumber(out orgNumber);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ namespace Digdir.Domain.Dialogporten.Application.Common.Extensions.Enumerable;

internal static class DeleteDelegate
{
#pragma warning disable IDE0060
// ReSharper disable once MethodOverloadWithOptionalParameter
public static Task NoOp<TDestination>(IEnumerable<TDestination> deletables, CancellationToken cancellationToken = default) => Task.CompletedTask;
public static void NoOp<TDestination>(IEnumerable<TDestination> deletables) { /* No operation by design */ }
#pragma warning restore IDE0060

}

internal static class MergeExtensions
Expand Down Expand Up @@ -130,17 +134,17 @@ private static async Task DeleteAsync<TDestination, TSource>(
return;
}

var deleates = destinations
var delegates = destinations
.Except(updateSets.Select(x => x.Destination))
.ToList();

if (deleates.Count == 0)
if (delegates.Count == 0)
{
return;
}

await delete(deleates, cancellationToken);
foreach (var item in deleates)
await delete(delegates, cancellationToken);
foreach (var item in delegates)
{
destinations.Remove(item);
}
Expand Down Expand Up @@ -190,17 +194,17 @@ private static void Delete<TDestination, TSource>(
return;
}

var deleates = destinations
var delegates = destinations
.Except(updateSets.Select(x => x.Destination))
.ToList();

if (deleates.Count == 0)
if (delegates.Count == 0)
{
return;
}

delete(deleates);
foreach (var item in deleates)
delete(delegates);
foreach (var item in delegates)
{
destinations.Remove(item);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Digdir.Domain.Dialogporten.Application.Common.Extensions.Enumerable;

internal readonly struct UpdateSet<TDestination, TSource>
internal readonly struct UpdateSet<TDestination, TSource>
{
public TDestination Destination { get; init; }
public TSource Source { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static IRuleBuilderOptions<T, IEnumerable<TProperty>> UniqueBy<T, TProper
.Select(x => x.Key)
.ToArray();
ctx.MessageFormatter.AppendArgument("DuplicateKeys", string.Join(",", duplicateKeys));
return !duplicateKeys.Any();
return duplicateKeys.Length == 0;
}).WithMessage("Can not contain duplicate items: [{DuplicateKeys}].");
}

Expand Down
Loading