mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(services): 💄 add default .NET editorconfig & re-run code cleanup
This commit is contained in:
parent
ad98639508
commit
2637e2e387
65 changed files with 222 additions and 96 deletions
|
|
@ -1,12 +1,128 @@
|
|||
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
|
||||
|
||||
###############################
|
||||
# Core EditorConfig Options #
|
||||
###############################
|
||||
root = true
|
||||
# All files
|
||||
[*]
|
||||
indent_style = space
|
||||
# Code files
|
||||
[*.{cs,csx,vb,vbx}]
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
charset = utf-8-bom
|
||||
###############################
|
||||
# .NET Coding Conventions #
|
||||
###############################
|
||||
[*.{cs,vb}]
|
||||
# Organize usings
|
||||
dotnet_sort_system_directives_first = true
|
||||
# this. preferences
|
||||
dotnet_style_qualification_for_field = false:silent
|
||||
dotnet_style_qualification_for_property = false:silent
|
||||
dotnet_style_qualification_for_method = false:silent
|
||||
dotnet_style_qualification_for_event = false:silent
|
||||
# Language keywords vs BCL types preferences
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
|
||||
dotnet_style_predefined_type_for_member_access = true:silent
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||
dotnet_style_readonly_field = true:suggestion
|
||||
# Expression-level preferences
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
|
||||
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
dotnet_style_prefer_auto_properties = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:silent
|
||||
###############################
|
||||
# Naming Conventions #
|
||||
###############################
|
||||
# Style Definitions
|
||||
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
|
||||
# Use PascalCase for constant fields
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
|
||||
dotnet_naming_symbols.constant_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.constant_fields.required_modifiers = const
|
||||
###############################
|
||||
# C# Coding Conventions #
|
||||
###############################
|
||||
[*.cs]
|
||||
# var preferences
|
||||
csharp_style_var_for_built_in_types = true:silent
|
||||
csharp_style_var_when_type_is_apparent = true:silent
|
||||
csharp_style_var_elsewhere = true:silent
|
||||
# Expression-bodied members
|
||||
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
|
||||
# Pattern matching preferences
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||
# Null-checking preferences
|
||||
csharp_style_throw_expression = true:suggestion
|
||||
csharp_style_conditional_delegate_call = true:suggestion
|
||||
# Modifier preferences
|
||||
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
|
||||
# Expression-level preferences
|
||||
csharp_prefer_braces = true:silent
|
||||
csharp_style_deconstructed_variable_declaration = true:suggestion
|
||||
csharp_prefer_simple_default_expression = true:suggestion
|
||||
csharp_style_pattern_local_over_anonymous_function = true:suggestion
|
||||
csharp_style_inlined_variable_declaration = true:suggestion
|
||||
###############################
|
||||
# C# Formatting Rules #
|
||||
###############################
|
||||
# New line preferences
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
# Indentation preferences
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = flush_left
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_statements = true
|
||||
csharp_preserve_single_line_blocks = true
|
||||
###############################
|
||||
# VB Coding Conventions #
|
||||
###############################
|
||||
[*.vb]
|
||||
# Modifier preferences
|
||||
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
|
||||
|
||||
# Xml files
|
||||
[*.xml]
|
||||
indent_size = 2
|
||||
|
||||
# Code quality analysis
|
||||
[*.cs]
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ public static IHostBuilder CreateHostBuilder(string[] args)
|
|||
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"publishAllPorts": true
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
|
||||
"publishAllPorts": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,9 @@ public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|||
{
|
||||
app.UseApplication();
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ public static void UseApplication(this IApplicationBuilder app)
|
|||
app.UseInfrastructure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,4 @@ public static void UseInfrastructure(this IApplicationBuilder app)
|
|||
app.UseScheduling();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ internal class GitOptions
|
|||
public string UserName { get; set; } = null!;
|
||||
public string UserEmail { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ public static void AddPersistenceServices(this IServiceCollection services, ICon
|
|||
configuration.GetSection(GitOptions.Key).Bind(gitOptions);
|
||||
|
||||
if (!Repository.IsValid(gitOptions.RepositoryDirectory))
|
||||
{
|
||||
Repository.Init(gitOptions.RepositoryDirectory);
|
||||
}
|
||||
|
||||
return new Repository(gitOptions.RepositoryDirectory);
|
||||
});
|
||||
services.AddTransient<IArchiveFiles, GitFileArchiver>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,9 +54,14 @@ public void Commit()
|
|||
public void Dispose()
|
||||
{
|
||||
foreach (var file in _filePaths)
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
|
||||
_repository.CheckoutPaths("HEAD", _filePaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ Task ArchiveFileAsync(
|
|||
string filePath,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ public interface IUnitOfWork : IDisposable
|
|||
{
|
||||
void Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ public static void UseScheduling(this IApplicationBuilder app)
|
|||
app.UseHangfireServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ protected async Task<IActionResult> CacheGetOrCreateAsync<TResponse>(
|
|||
return result is null ? NotFound() : (IActionResult)Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
|||
return await CacheGetOrCreateAsync(() => _mediator.Send(new GetLanguages.Query(), cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
|||
return await CacheGetOrCreateAsync(() => _mediator.Send(new GetLicenses.Query(), cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ public async Task<IActionResult> GetDetails(int id, CancellationToken cancellati
|
|||
return await CacheGetOrCreateAsync(() => _mediator.Send(new GetListDetails.Query(id), cancellationToken), id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
|||
return await CacheGetOrCreateAsync(() => _mediator.Send(new GetMaintainers.Query(), cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
|||
return await CacheGetOrCreateAsync(() => _mediator.Send(new GetSoftware.Query(), cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
|||
return await CacheGetOrCreateAsync(() => _mediator.Send(new GetSyntaxes.Query(), cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public async Task<IActionResult> Get(CancellationToken cancellationToken)
|
|||
return await CacheGetOrCreateAsync(() => _mediator.Send(new GetTags.Query(), cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ public static IHostBuilder CreateHostBuilder(string[] args)
|
|||
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/v1/lists",
|
||||
"publishAllPorts": true
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/v1/lists",
|
||||
"publishAllPorts": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,10 +30,13 @@ public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|||
{
|
||||
app.UseApplication();
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(e => e.MapControllers());
|
||||
app.UseSwagger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@ public static void AddSwaggerGen(this IServiceCollection services)
|
|||
"FilterLists is the independent, comprehensive directory of filter and host lists for advertisements, trackers, malware, and annoyances.",
|
||||
Version = "v1",
|
||||
//TermsOfService = "",
|
||||
Contact = new OpenApiContact
|
||||
{
|
||||
Name = "FilterLists",
|
||||
Url = new Uri("https://filterlists.com")
|
||||
},
|
||||
Contact = new OpenApiContact {Name = "FilterLists", Url = new Uri("https://filterlists.com")},
|
||||
License = new OpenApiLicense
|
||||
{
|
||||
Name = "MIT License",
|
||||
|
|
@ -54,4 +50,4 @@ public static void UseSwagger(this IApplicationBuilder app)
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"DirectoryConnection": "Server=directory-db;Database=filterlists;User Id=filterlists;Password=filterlists;"
|
||||
}
|
||||
}
|
||||
"ConnectionStrings": {
|
||||
"DirectoryConnection": "Server=directory-db;Database=filterlists;User Id=filterlists;Password=filterlists;"
|
||||
}
|
||||
}
|
||||
|
|
@ -27,4 +27,4 @@ public static void UseApplication(this IApplicationBuilder app)
|
|||
app.UseInfrastructure();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,4 +58,4 @@ public class LanguageVm
|
|||
public IEnumerable<int>? FilterListIds { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,4 @@ public class LicenseVm
|
|||
public IEnumerable<int>? FilterListIds { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,4 +93,4 @@ public ListDetailsViewUrlVmProfile()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,4 @@ public ListVmProfile()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,4 +61,4 @@ public class MaintainerVm
|
|||
public IEnumerable<int>? FilterListIds { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,4 @@ public class SoftwareVm
|
|||
public IEnumerable<int>? SyntaxIds { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,4 +64,4 @@ public class SyntaxVm
|
|||
public IEnumerable<int>? SoftwareIds { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,4 +58,4 @@ public class TagVm
|
|||
public IEnumerable<int>? FilterListIds { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ public async Task Migrate_DoesNotThrowException()
|
|||
Assert.Null(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ public static void UseInfrastructure(this IApplicationBuilder app)
|
|||
app.UseLogging();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ public interface IQueryContext
|
|||
IQueryable<Syntax> Syntaxes { get; }
|
||||
IQueryable<Tag> Tags { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public async ValueTask DisposeAsync()
|
|||
public IQueryable<Syntax> Syntaxes => _dbContext.Syntaxes.AsNoTracking();
|
||||
public IQueryable<Tag> Tags => _dbContext.Tags.AsNoTracking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ public override int SaveChanges(bool acceptAllChangesOnSuccess)
|
|||
throw new InvalidOperationException("This context is read-only.");
|
||||
}
|
||||
|
||||
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess,
|
||||
public override Task<int> SaveChangesAsync(
|
||||
bool acceptAllChangesOnSuccess,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new InvalidOperationException("This context is read-only.");
|
||||
|
|
@ -38,4 +39,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|||
modelBuilder.ApplyConfigurationsFromAssembly(GetType().Assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public virtual void Configure(EntityTypeBuilder<Dependent> builder)
|
|||
builder.HasDataJsonFile<Dependent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,4 @@ public virtual void Configure(EntityTypeBuilder<FilterList> builder)
|
|||
builder.HasDataJsonFile<FilterList>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ public virtual void Configure(EntityTypeBuilder<FilterListLanguage> builder)
|
|||
builder.HasDataJsonFile<FilterListLanguage>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ public virtual void Configure(EntityTypeBuilder<FilterListMaintainer> builder)
|
|||
builder.HasDataJsonFile<FilterListMaintainer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ public virtual void Configure(EntityTypeBuilder<FilterListSyntax> builder)
|
|||
builder.HasDataJsonFile<FilterListSyntax>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ public virtual void Configure(EntityTypeBuilder<FilterListTag> builder)
|
|||
builder.HasDataJsonFile<FilterListTag>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ public virtual void Configure(EntityTypeBuilder<FilterListViewUrl> builder)
|
|||
builder.HasDataJsonFile<FilterListViewUrl>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public virtual void Configure(EntityTypeBuilder<Fork> builder)
|
|||
builder.HasDataJsonFile<Fork>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ public virtual void Configure(EntityTypeBuilder<Language> builder)
|
|||
builder.HasDataJsonFile<Language>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ public virtual void Configure(EntityTypeBuilder<License> builder)
|
|||
builder.HasDataJsonFile<License>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ public virtual void Configure(EntityTypeBuilder<Maintainer> builder)
|
|||
builder.HasDataJsonFile<Maintainer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ public virtual void Configure(EntityTypeBuilder<Merge> builder)
|
|||
builder.HasDataJsonFile<Merge>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ public virtual void Configure(EntityTypeBuilder<Software> builder)
|
|||
builder.HasDataJsonFile<Software>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ public virtual void Configure(EntityTypeBuilder<SoftwareSyntax> builder)
|
|||
builder.HasDataJsonFile<SoftwareSyntax>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ public virtual void Configure(EntityTypeBuilder<Syntax> builder)
|
|||
builder.HasDataJsonFile<Syntax>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ public virtual void Configure(EntityTypeBuilder<Tag> builder)
|
|||
builder.HasDataJsonFile<Tag>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,15 +30,16 @@ public static void HasDataJsonFile<TEntity>(this EntityTypeBuilder entityTypeBui
|
|||
_ = entityTypeBuilder ?? throw new ArgumentNullException(nameof(entityTypeBuilder));
|
||||
|
||||
var path = Path.Combine("../data", $"{typeof(TEntity).Name}.json");
|
||||
if (!File.Exists(path)) return;
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var entitiesJson = File.ReadAllText(path);
|
||||
var entities = JsonSerializer.Deserialize<IEnumerable<TEntity>>(entitiesJson, new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
});
|
||||
var entities = JsonSerializer.Deserialize<IEnumerable<TEntity>>(entitiesJson,
|
||||
new JsonSerializerOptions {PropertyNamingPolicy = JsonNamingPolicy.CamelCase});
|
||||
|
||||
entityTypeBuilder.HasData((IEnumerable<object>)entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ protected async Task<T> GetAsync<T>(string requestUri, CancellationToken cancell
|
|||
return await JsonSerializer.DeserializeAsync<T>(responseStream, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ public static void AddApiClients(this IServiceCollection services)
|
|||
services.AddHttpClient<IDirectoryApiClient, DirectoryApiApiClient>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ public async Task<ListDetailsVm> GetListDetailsAsync(int id, CancellationToken c
|
|||
return await GetAsync<ListDetailsVm>($"/lists/{id}", cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ public interface IDirectoryApiClient
|
|||
Task<IEnumerable<ListVm>> GetListsAsync(CancellationToken cancellationToken = default);
|
||||
Task<ListDetailsVm> GetListDetailsAsync(int id, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ public class ListDetailsViewUrlVm
|
|||
public short Primariness { get; private set; }
|
||||
public Uri Url { get; private set; } = null!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ public class ListVm
|
|||
public IEnumerable<int>? TagIds { get; private set; }
|
||||
public IEnumerable<int>? MaintainerIds { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ public static LoggerConfiguration WriteToApplicationInsights(
|
|||
return loggerConfiguration.WriteTo.ApplicationInsights(telemetryClient, TelemetryConverter.Traces);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ public static void UseLogging(this IApplicationBuilder app)
|
|||
app.UseSerilogRequestLogging();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,4 @@ public static async Task<int> TryRunWithLoggingAsync(this IHost host, Func<Task>
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue