Skip to content

Commit

Permalink
dotnet-format
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Jun 3, 2024
1 parent d274627 commit e89b324
Show file tree
Hide file tree
Showing 312 changed files with 7,405 additions and 7,187 deletions.
456 changes: 442 additions & 14 deletions .editorconfig

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ jobs:
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Install dotnet format
run: dotnet tool update -g dotnet-format
- name: Check Format
run: dotnet format --verify-no-changes --severity error src/
4 changes: 1 addition & 3 deletions src/Stars.Console.Tests/BaseCommandLineTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using McMaster.Extensions.CommandLineUtils;
using Terradue.Stars.Console;
using Terradue.Stars.Console;
using Xunit;
using Xunit.Abstractions;

Expand Down
4 changes: 2 additions & 2 deletions src/Stars.Console.Tests/Utilities/CommandLineParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Nate McMaster.
// Copyright (c) Nate McMaster.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.IO;
Expand Down Expand Up @@ -27,4 +27,4 @@ private static T ParseArgsImpl<T>(IConsole console, string[] args) where T : cla
return app.Model;
}
}
}
}
4 changes: 2 additions & 2 deletions src/Stars.Console.Tests/Utilities/ConventionTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Nate McMaster.
// Copyright (c) Nate McMaster.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using McMaster.Extensions.CommandLineUtils;
Expand All @@ -25,4 +25,4 @@ protected CommandLineApplication<T> Create<T, TConvention>()
return app;
}
}
}
}
4 changes: 2 additions & 2 deletions src/Stars.Console.Tests/Utilities/TestConsole.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Xunit.Abstractions;
using McMaster.Extensions.CommandLineUtils;
using Xunit.Abstractions;
using Xunit.Sdk;

namespace Stars.Console.Tests
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Console.Tests/Utilities/XunitTextWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using System.Text;
using Xunit.Abstractions;

Expand Down
6 changes: 3 additions & 3 deletions src/Stars.Console/ConsoleCredentialsManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Net;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -66,7 +66,7 @@ private void PromptSaveCredentials(ICredentials cred, Uri uri, string authType)
private void SaveCredentials(ICredentials cred, Uri uri, string authType)
{
CredentialsConfigurationSection credConfigSection = cred.ToCredentialsConfigurationSection(uri, authType);
consoleUserSettings.AddOrUpdateSetting<CredentialsConfigurationSection>("Credentials:" + Guid.NewGuid().ToString(), credConfigSection);
consoleUserSettings.AddOrUpdateSetting("Credentials:" + Guid.NewGuid().ToString(), credConfigSection);
}

private NetworkCredential PromptCredentials(Uri uri, string authType)
Expand Down Expand Up @@ -119,4 +119,4 @@ private NetworkCredential PromptCredentials(Uri uri, string authType)
return new NetworkCredential(username, pass);
}
}
}
}
7 changes: 3 additions & 4 deletions src/Stars.Console/ConsoleUserSettings.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System;
using System;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Terradue.Stars.Console
{
internal class ConsoleUserSettings
{
private readonly string userSettingsFilePath = Path.Join(System.Environment.GetEnvironmentVariable("HOME"), ".config", "Stars" , "usersettings.json");
private readonly string userSettingsFilePath = Path.Join(System.Environment.GetEnvironmentVariable("HOME"), ".config", "Stars", "usersettings.json");
private readonly ILogger logger;
private readonly IConfigurationRoot configuration;

Expand Down Expand Up @@ -75,4 +74,4 @@ private void SetValueRecursively<T>(string sectionPathKey, dynamic jsonObj, T va
}
}
}
}
}
37 changes: 18 additions & 19 deletions src/Stars.Console/Operations/BaseOperation.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System;
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Terradue.Stars.Services;
using Microsoft.Extensions.Configuration.EnvironmentVariables;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;

namespace Terradue.Stars.Console.Operations
{
Expand All @@ -38,7 +37,7 @@ internal abstract class BaseOperation

public BaseOperation(IConsole console)
{
this._console = console;
_console = console;
}

protected IServiceProvider ServiceProvider { get; private set; }
Expand All @@ -57,7 +56,7 @@ private string GetBasePath()
{

using var processModule = Process.GetCurrentProcess().MainModule;
return Path.GetDirectoryName(processModule?.FileName);
return Path.GetDirectoryName(processModule?.FileName);
}

public async Task<int> OnExecuteAsync(CancellationToken ct)
Expand Down Expand Up @@ -107,7 +106,7 @@ private ServiceCollection RegisterServices()
// tell the builder to look for the appsettings.json file
builder.AddNewtonsoftJsonFile("/etc/Stars/appsettings.json", optional: true);
foreach (var jsonFilename in Directory.EnumerateFiles(GetBasePath(), "stars-*.json", SearchOption.TopDirectoryOnly))
builder.AddNewtonsoftJsonFile(jsonFilename);
builder.AddNewtonsoftJsonFile(jsonFilename);

if (Directory.Exists("/etc/Stars/conf.d"))
{
Expand All @@ -120,7 +119,7 @@ private ServiceCollection RegisterServices()
//only add secrets in development
if (isDevelopment)
{
var binPath = Path.GetDirectoryName((new System.Uri(Assembly.GetExecutingAssembly().Location)).AbsolutePath);
var binPath = Path.GetDirectoryName((new Uri(Assembly.GetExecutingAssembly().Location)).AbsolutePath);
foreach (var jsonFilename in Directory.EnumerateFiles(binPath, "stars-*.json", SearchOption.TopDirectoryOnly))
builder.AddNewtonsoftJsonFile(jsonFilename);
builder.AddNewtonsoftJsonFile("appsettings.Development.json", optional: true);
Expand All @@ -143,10 +142,10 @@ private ServiceCollection RegisterServices()



collection.AddSingleton<IConfigurationRoot>(Configuration);
collection.AddSingleton(Configuration);

// Add the command line services
collection.AddSingleton<IConsole>(_console);
collection.AddSingleton(_console);
collection.AddSingleton<ILogger>(logger);

// Add Stars Services
Expand All @@ -172,10 +171,10 @@ private ServiceCollection RegisterServices()
private int GetVerbosityLevel()
{
int verbosity = 0;
if ( Verbose )
verbosity ++;
if ( Trace )
if (Verbose)
verbosity++;

if (Trace)
verbosity = 2;

return verbosity;
Expand All @@ -190,12 +189,12 @@ private static void DisposeServices(IServiceProvider serviceProvider)
return;
}

if (serviceProvider is IDisposable)
if (serviceProvider is IDisposable disposable)
{
((IDisposable)serviceProvider).Dispose();
disposable.Dispose();
}

}

}
}
}
47 changes: 22 additions & 25 deletions src/Stars.Console/Operations/CopyOperation.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Stac;
using Terradue.Stars.Interface;
using Terradue.Stars.Interface.Processing;
using Terradue.Stars.Interface.Router;
using Terradue.Stars.Interface.Router.Translator;
using Terradue.Stars.Interface.Supplier;
using Terradue.Stars.Interface.Supplier.Destination;
using Terradue.Stars.Services;
using Terradue.Stars.Services.Model.Stac;
using Terradue.Stars.Services.Router;
using Terradue.Stars.Services.Plugins;
using Terradue.Stars.Services.Processing;
using Terradue.Stars.Services.Router;
using Terradue.Stars.Services.Store;
using Terradue.Stars.Services.Supplier;
using Terradue.Stars.Services.Supplier.Carrier;
using Terradue.Stars.Services.Translator;
using Terradue.Stars.Services.Supplier;
using Terradue.Stars.Interface.Processing;
using Terradue.Stars.Interface;
using Terradue.Stars.Services;
using Terradue.Stars.Services.Store;
using System.Net;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using Terradue.Stars.Services.Plugins;
using Stac;
using System.Threading;

namespace Terradue.Stars.Console.Operations
{
Expand Down Expand Up @@ -340,16 +337,16 @@ private PluginList<ISupplier> InitSuppliersEnumerator(IResource route, SupplierF

protected override async Task ExecuteAsync(CancellationToken ct)
{
this.routingService = ServiceProvider.GetService<RouterService>();
this.carrierManager = ServiceProvider.GetService<CarrierManager>();
this.processingManager = ServiceProvider.GetService<ProcessingManager>();
this.storeService = ServiceProvider.GetService<StacStoreService>();
this.translatorManager = ServiceProvider.GetService<TranslatorManager>();
this.supplierManager = ServiceProvider.GetService<SupplierManager>();
this.stacLinkTranslator = ServiceProvider.GetService<StacLinkTranslator>();
this.resourceServiceProvider = ServiceProvider.GetService<IResourceServiceProvider>();
routingService = ServiceProvider.GetService<RouterService>();
carrierManager = ServiceProvider.GetService<CarrierManager>();
processingManager = ServiceProvider.GetService<ProcessingManager>();
storeService = ServiceProvider.GetService<StacStoreService>();
translatorManager = ServiceProvider.GetService<TranslatorManager>();
supplierManager = ServiceProvider.GetService<SupplierManager>();
stacLinkTranslator = ServiceProvider.GetService<StacLinkTranslator>();
resourceServiceProvider = ServiceProvider.GetService<IResourceServiceProvider>();
var stacRouter = ServiceProvider.GetService<StacRouter>();
await this.storeService.InitAsync(ct, !AppendCatalog);
await storeService.InitAsync(ct, !AppendCatalog);
InitRoutingTask();
await PrepareNewRouteAsync(null, storeService.RootCatalogNode, null, null, ct);
routingService.OnRoutingException((res, router, ex, state, ct) => Task.FromResult(OnRoutingException(res, router, ex, state, ct)));
Expand All @@ -372,7 +369,7 @@ protected override async Task ExecuteAsync(CancellationToken ct)
CopyOperationState copyState = state as CopyOperationState;
stacNodes.Add(copyState.CurrentStacObject);
}
storeService.RootCatalogNode.StacCatalog.UpdateLinks(stacNodes.SelectMany<StacNode, IResource>(sn =>
storeService.RootCatalogNode.StacCatalog.UpdateLinks(stacNodes.SelectMany(sn =>
{
if (sn is StacItemNode) return new IResource[] { sn };
if (sn is StacCatalogNode) return sn.GetRoutes(stacRouter);
Expand Down Expand Up @@ -435,4 +432,4 @@ protected override void RegisterOperationServices(ServiceCollection collection)
}
}
}
}
}
8 changes: 2 additions & 6 deletions src/Stars.Console/Operations/CopyOperationState.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Collections.Generic;
using Terradue.Stars.Interface;
using Terradue.Stars.Interface.Router;

using Terradue.Stars.Interface.Supplier.Destination;
using Terradue.Stars.Interface.Supplier.Destination;
using Terradue.Stars.Services.Model.Stac;
using Terradue.Stars.Services.Store;

Expand All @@ -22,4 +18,4 @@ public CopyOperationState(int depth, StacStoreService storeService, IDestination
public StacNode CurrentStacObject { get; internal set; }
public StacStoreService StoreService { get; internal set; }
}
}
}
Loading

0 comments on commit e89b324

Please sign in to comment.