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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ jobs:
- name: Build
run: dotnet build --no-restore --configuration '${{ env.BUILD_CONFIGURATION }}'

- name: Run check-deps in Demo Application
run: dotnet run --project Neolution.DotNet.Console.Demo --no-build --configuration '${{ env.BUILD_CONFIGURATION }}' -- check-deps

- name: Test
run: dotnet test --no-build --verbosity normal --configuration '${{ env.BUILD_CONFIGURATION }}'
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added `DotNetConsoleLogger.cs` static class to provide initialization, access, and shutdown for the logger instance used in console applications.

### Changed

- Updated Scrutor to v6.1.0.
- Updated Microsoft.Extensions packages to latest patch versions.

### Removed

- Removed obsolete serialization constructor and `[Serializable]` attribute from `DotNetConsoleException` as formatter-based serialization is no longer supported or recommended in modern .NET.

## [5.0.0] - 2025-01-27

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neolution.DotNet.Console.SampleAsync.Commands.Echo
namespace Neolution.DotNet.Console.Demo.Commands.Echo
{
using System;
using Microsoft.Extensions.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neolution.DotNet.Console.SampleAsync.Commands.Echo
namespace Neolution.DotNet.Console.Demo.Commands.Echo
{
using CommandLine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neolution.DotNet.Console.SampleAsync.Commands.GuidGen
namespace Neolution.DotNet.Console.Demo.Commands.GuidGen
{
using System;
using System.Globalization;
Expand Down Expand Up @@ -41,7 +41,7 @@ public Task RunAsync(GuidGenOptions options, CancellationToken cancellationToken
result = result.ToUpperInvariant();
}

System.Console.WriteLine(result);
Console.WriteLine(result);

this.logger.LogTrace("Wrote result to console");
return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Neolution.DotNet.Console.SampleAsync.Commands.GuidGen
namespace Neolution.DotNet.Console.Demo.Commands.GuidGen
{
using CommandLine;
using Neolution.DotNet.Console.SampleAsync.Commands.Echo;
using Neolution.DotNet.Console.Demo.Commands.Echo;

/// <summary>
/// The options for the <see cref="EchoCommand"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neolution.DotNet.Console.SampleAsync.Commands.Start
namespace Neolution.DotNet.Console.Demo.Commands.Start
{
using System;
using Microsoft.Extensions.Logging;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neolution.DotNet.Console.SampleAsync.Commands.Start
namespace Neolution.DotNet.Console.Demo.Commands.Start
{
using CommandLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/runtime:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Neolution.DotNet.Console.SampleAsync.dll"]
ENTRYPOINT ["dotnet", "Neolution.DotNet.Console.Demo.dll"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Neolution.CodeAnalysis" Version="3.2.1">
<PackageReference Include="Neolution.CodeAnalysis" Version="3.3.0-beta.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
37 changes: 37 additions & 0 deletions Neolution.DotNet.Console.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Neolution.DotNet.Console.Demo
{
/// <summary>
/// The program
/// </summary>
public static class Program
{
/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>
/// <returns>The <see cref="Task"/>.</returns>
public static async Task Main(string[] args)
{
try
{
var builder = DotNetConsole.CreateDefaultBuilder(args);
DotNetConsoleLogger.Initialize(builder.Configuration);

var startup = new Startup(builder.Environment, builder.Configuration);
startup.ConfigureServices(builder.Services);
var console = builder.Build();
await console.RunAsync();
}
catch (Exception ex)
{
DotNetConsoleLogger.Log.Error(ex, "Stopped program because of an unexpected exception");
throw;
}
finally
{
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
DotNetConsoleLogger.Shutdown();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"profiles": {
"Sample Console App": {
"Demo Console App": {
"commandName": "Project",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
},
"Sample Console App: check-deps": {
"Demo Console App: check-deps": {
"commandName": "Project",
"commandLineArgs": "check-deps",
"environmentVariables": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Neolution.DotNet.Console.SampleAsync
namespace Neolution.DotNet.Console.Demo
{
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
},
"Neolution.CodeAnalysis": {
"type": "Direct",
"requested": "[3.2.1, )",
"resolved": "3.2.1",
"contentHash": "AQDkBJ9e6TrnhpwTtf4KrwlAPBLy77I5XkNey586nN2IFfjk1LVwBwvOcjORD1dSNtEhOf69JQjdmiMf54C90w==",
"requested": "[3.3.0-beta.2, )",
"resolved": "3.3.0-beta.2",
"contentHash": "88mG4f4P16K4Ql3uTqeaoeXGJLNMReFh9z3ZKmKZ0bY4RTk4z4syjuF/TefouGM2hR+mcBSdWbAtsKT/+FowlA==",
"dependencies": {
"SonarAnalyzer.CSharp": "9.20.0.85982",
"SonarAnalyzer.CSharp": "9.32.0.97167",
"StyleCop.Analyzers.Unstable": "1.2.0.556"
}
},
Expand Down Expand Up @@ -332,17 +332,17 @@
},
"Scrutor": {
"type": "Transitive",
"resolved": "6.0.1",
"contentHash": "5xKT6ND5GqnFzwSaYozHCJe75GFL8sPy4yw/iRFqeBFGlmqPNFpOg1T9Q0Gl2h76Cklt0ZTg6Ypkri5iUBKXsA==",
"resolved": "6.1.0",
"contentHash": "m4+0RdgnX+jeiaqteq9x5SwEtuCjWG0KTw1jBjCzn7V8mCanXKoeF8+59E0fcoRbAjdEq6YqHFCmxZ49Kvqp3g==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1",
"Microsoft.Extensions.DependencyModel": "8.0.2"
}
},
"SonarAnalyzer.CSharp": {
"type": "Transitive",
"resolved": "9.20.0.85982",
"contentHash": "c0IYtFg4mYusTafTy0Bs5wev45vRKNShkuoWyQyPMbC6imEFHL7tY/7xbbUJd6JNLYx5vP8wyi2LgiBsMHqb2Q=="
"resolved": "9.32.0.97167",
"contentHash": "Yxk86RV+8ynJpUhku1Yw2hITFmnmXKkXJ73cIFSy85ol5SnWREQg9RuTyV8nI7V7+pyLKpCfRmD7P0widsgjkg=="
},
"StyleCop.Analyzers.Unstable": {
"type": "Transitive",
Expand All @@ -358,18 +358,18 @@
"type": "Project",
"dependencies": {
"CommandLineParser": "[2.9.1, )",
"Microsoft.Extensions.Configuration.Abstractions": "[8.0.0, )",
"Microsoft.Extensions.Configuration.CommandLine": "[8.0.0, )",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "[8.0.0, )",
"Microsoft.Extensions.Configuration.Json": "[8.0.1, )",
"Microsoft.Extensions.Configuration.UserSecrets": "[8.0.1, )",
"Microsoft.Extensions.DependencyInjection": "[8.0.1, )",
"Microsoft.Extensions.Hosting": "[8.0.1, )",
"Microsoft.Extensions.Logging": "[8.0.1, )",
"Microsoft.Extensions.Logging.Configuration": "[8.0.1, )",
"Microsoft.Extensions.Configuration.Abstractions": "[8.0.*, )",
"Microsoft.Extensions.Configuration.CommandLine": "[8.0.*, )",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "[8.0.*, )",
"Microsoft.Extensions.Configuration.Json": "[8.0.*, )",
"Microsoft.Extensions.Configuration.UserSecrets": "[8.0.*, )",
"Microsoft.Extensions.DependencyInjection": "[8.0.*, )",
"Microsoft.Extensions.Hosting": "[8.0.*, )",
"Microsoft.Extensions.Logging": "[8.0.*, )",
"Microsoft.Extensions.Logging.Configuration": "[8.0.*, )",
"NLog": "[5.3.4, )",
"NLog.Extensions.Logging": "[5.3.15, )",
"Scrutor": "[6.0.1, )"
"Scrutor": "[6.1.0, )"
}
}
}
Expand Down
49 changes: 0 additions & 49 deletions Neolution.DotNet.Console.SampleAsync/Program.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Neolution.CodeAnalysis.TestsRuleset" Version="3.2.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Neolution.CodeAnalysis.TestsRuleset" Version="3.3.0-beta.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Objectivity.AutoFixture.XUnit2.AutoNSubstitute" Version="3.6.2" />
<PackageReference Include="Objectivity.AutoFixture.XUnit2.AutoNSubstitute" Version="3.6.3" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading