├── .editorconfig ├── .gitignore ├── Build └── Gated Build Pipeline.yml ├── ClassLibraries ├── Macross.CommandLine │ ├── Code │ │ ├── CommandLineArgumentParser.cs │ │ ├── CommandLineArguments.cs │ │ ├── Macross.CommandLine.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── CommandLineTests.cs │ │ ├── Macross.CommandLine.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── keypair.snk ├── Macross.Extensions │ ├── Code │ │ ├── Extensions │ │ │ └── System │ │ │ │ ├── ConversionExtensions.cs │ │ │ │ ├── EnumExtensions.cs │ │ │ │ ├── HexViewExtensions.cs │ │ │ │ ├── StringExtensions.cs │ │ │ │ ├── System.Collections.Generic │ │ │ │ ├── ConversionExtensions.cs │ │ │ │ └── DictionaryExtensions.cs │ │ │ │ ├── System.IO │ │ │ │ └── BinaryExtensions.cs │ │ │ │ ├── System.Reflection │ │ │ │ └── ReflectionExtensions.cs │ │ │ │ └── System.Xml.Linq │ │ │ │ └── XmlExtensions.cs │ │ ├── Macross.Extensions.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Types │ │ │ └── System │ │ │ │ ├── BitCompactor.cs │ │ │ │ ├── IJsonConfigurable.cs │ │ │ │ ├── ManualInterventionException.cs │ │ │ │ ├── MaskedRegion.cs │ │ │ │ ├── ParseFunc.cs │ │ │ │ └── TryParseFunc.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── BitCompactorTests.cs │ │ ├── EnumExtensionTests.cs │ │ ├── HexStringExtensionTests.cs │ │ ├── HexViewExtensionTests.cs │ │ ├── Macross.Extensions.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── StringExtensionTests.cs │ │ ├── ToStringArrayExtensionTests.cs │ │ └── keypair.snk ├── Macross.Json.Extensions │ ├── CHANGELOG.md │ ├── Code │ │ ├── Macross.Json.Extensions.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── System.Net.Http │ │ │ ├── PushStreamContent.cs │ │ │ └── PushStreamContent{T}.cs │ │ ├── System.Text.Json.Serialization │ │ │ ├── DateTimeWireFormatHelper.cs │ │ │ ├── JsonDelegatedStringConverter.cs │ │ │ ├── JsonIPAddressConverter.cs │ │ │ ├── JsonIPEndPointConverter.cs │ │ │ ├── JsonMicrosoftDateTimeConverter.cs │ │ │ ├── JsonMicrosoftDateTimeOffsetConverter.cs │ │ │ ├── JsonStringEnumMemberConverter.cs │ │ │ ├── JsonStringEnumMemberConverterOptions.cs │ │ │ ├── JsonStringEnumMemberConverterOptionsAttribute.cs │ │ │ ├── JsonStringEnumMemberConverter{TEnum}.cs │ │ │ └── JsonTypeConverterAdapter.cs │ │ ├── System.Text.Json │ │ │ └── Utf8JsonStreamReader.cs │ │ ├── ThrowHelper.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── DateTimeWireFormatHelperTests.cs │ │ ├── JsonDelegatedStringConverterTests.cs │ │ ├── JsonIPAddressConverterTests.cs │ │ ├── JsonIPEndPointConverterTests.cs │ │ ├── JsonMicrosoftDateTimeConverterTests.cs │ │ ├── JsonMicrosoftDateTimeOffsetConverterTests.cs │ │ ├── JsonStringEnumMemberConverterTests.cs │ │ ├── JsonTypeConverterAdapterTests.cs │ │ ├── Macross.Json.Extensions.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── Utf8JsonStreamReaderTests.cs │ │ └── keypair.snk ├── Macross.Logging.Abstractions │ ├── CHANGELOG.md │ ├── Code │ │ ├── Extensions │ │ │ ├── LoggerExtensions.Critical.cs │ │ │ ├── LoggerExtensions.Debug.cs │ │ │ ├── LoggerExtensions.Error.cs │ │ │ ├── LoggerExtensions.Info.cs │ │ │ ├── LoggerExtensions.Trace.cs │ │ │ ├── LoggerExtensions.Warning.cs │ │ │ └── LoggerExtensions.cs │ │ ├── FormattedLogValues.cs │ │ ├── LogValuesFormatter.cs │ │ ├── LoggerGroup.cs │ │ ├── LoggerGroupCache.cs │ │ ├── LoggerGroupOptions.cs │ │ ├── LoggerJsonMessage.cs │ │ ├── LoggerJsonMessageException.cs │ │ ├── Macross.Logging.Abstractions.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── PropertyGetter.cs │ │ ├── ValueStringBuilder.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── LoggerJsonMessageTests.cs │ │ ├── Macross.Logging.Abstractions.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── keypair.snk ├── Macross.Logging.Files │ ├── Benchmarks │ │ ├── Macross.Logging.Files.Benchmarks.csproj │ │ ├── MacrossFileLoggingProvider.cs │ │ ├── NLogProvider.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── ProviderComparisonBenchmarks.cs │ │ ├── SerilogProvider.cs │ │ └── keypair.snk │ ├── CHANGELOG.md │ ├── Code │ │ ├── BufferWriter.cs │ │ ├── Extensions │ │ │ ├── FileLoggerExtensions.cs │ │ │ ├── FileSystem.cs │ │ │ ├── IFileSystem.cs │ │ │ ├── ISystemTime.cs │ │ │ └── SystemTime.cs │ │ ├── FileLogger.cs │ │ ├── FileLoggerOptions.cs │ │ ├── FileLoggerProvider.cs │ │ ├── FileNameGenerator.cs │ │ ├── LogFile.cs │ │ ├── LogFileManagementSchedule.cs │ │ ├── LogFileManager.cs │ │ ├── Macross.Logging.Files.csproj │ │ ├── NullScope.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── FileLoggerOptionsTests.cs │ │ ├── FileNameGeneratorTests.cs │ │ ├── LogFileManagementScheduleTests.cs │ │ ├── LogFileManagerTests.cs │ │ ├── Macross.Logging.Files.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── TestFileSystem.cs │ │ ├── TestSystemTime.cs │ │ └── keypair.snk ├── Macross.Logging.StandardOutput │ ├── Benchmarks │ │ ├── Macross.Logging.StandardOutput.Benchmarks.csproj │ │ ├── MacrossStandardOutputLoggingProvider.cs │ │ ├── NLogProvider.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── ProviderComparisonBenchmarks.cs │ │ ├── SerilogProvider.cs │ │ └── keypair.snk │ ├── CHANGELOG.md │ ├── Code │ │ ├── BufferWriter.cs │ │ ├── Extensions │ │ │ └── StandardOutputLoggerExtensions.cs │ │ ├── Macross.Logging.StandardOutput.csproj │ │ ├── NullScope.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── StandardOutputLogger.cs │ │ ├── StandardOutputLoggerOptions.cs │ │ ├── StandardOutputLoggerProvider.cs │ │ └── keypair.snk │ └── README.md ├── Macross.OpenTelemetry.Extensions │ ├── CHANGELOG.md │ ├── Code │ │ ├── ActivityEnrichmentScope │ │ │ ├── ActionActivityEnrichmentScope.cs │ │ │ ├── ActivityEnricher.cs │ │ │ ├── ActivityEnrichmentScope.cs │ │ │ ├── ActivityEnrichmentScopeBase.cs │ │ │ ├── ActivityEnrichmentScopeProcessor.cs │ │ │ └── GenericActivityEnrichmentScope{TState}.cs │ │ ├── ActivityTraceListenerManager.cs │ │ ├── ActivityTraceListenerManagerOptions.cs │ │ ├── ActivityTraceListenerSampler.cs │ │ ├── Extensions │ │ │ ├── OpenTelemetryServiceCollectionExtensions.cs │ │ │ └── TracerProviderBuilderExtensions.cs │ │ ├── IActivityTraceListener.cs │ │ ├── Macross.OpenTelemetry.Extensions.csproj │ │ ├── OpenTelemetryEventListener.cs │ │ ├── OpenTelemetryEventLogAction.cs │ │ ├── OpenTelemetryEventLoggingHostedService.cs │ │ ├── OpenTelemetryEventLoggingOptions.cs │ │ ├── OpenTelemetryEventLoggingSourceOptions.cs │ │ ├── OpenTelemetryExtensionsEventSource.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── ActivityEnrichmentScopeProcessorTests.cs │ │ ├── ActivityTraceListenerManagerTests.cs │ │ ├── Macross.OpenTelemetry.Extensions.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── TestActivityProcessor.cs │ │ └── keypair.snk ├── Macross.Performance.Extensions │ ├── Benchmarks │ │ ├── EnumerationBenchmarks.cs │ │ ├── PerformanceBenchmarks.csproj │ │ ├── PoolBackedCollectionBenchmarks.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ └── launchSettings.json │ │ └── keypair.snk │ ├── Code │ │ ├── DictionaryStructEnumerator.cs │ │ ├── ListStructEnumerator.cs │ │ ├── Macross.Performance.Extensions.csproj │ │ ├── PoolBackedCollection.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── StructEnumerator.cs │ │ ├── StructPoolBackedCollection.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── DictionaryStructEnumeratorTests.cs │ │ ├── ListStructEnumeratorTests.cs │ │ ├── Macross.Performance.Extensions.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── keypair.snk ├── Macross.ServiceModel.Extensions │ ├── Code │ │ ├── DefaultSoapClientFactory.cs │ │ ├── DefaultTypedSoapClientFactory.cs │ │ ├── DependencyInjection │ │ │ ├── DefaultSoapClientBuilder.cs │ │ │ ├── ISoapClientBuilder.cs │ │ │ ├── SoapClientBuilderExtensions.cs │ │ │ └── SoapServiceCollectionExtensions.cs │ │ ├── ISoapClientFactory.cs │ │ ├── ITypedSoapClientFactory.cs │ │ ├── Macross.ServiceModel.Extensions.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── SoapClient.cs │ │ ├── SoapClientFactoryOptions.cs │ │ ├── SoapClient{TChannel}.cs │ │ └── keypair.snk │ ├── README.md │ └── Test │ │ ├── Macross.ServiceModel.Extensions.Tests.csproj │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── SoapServiceCollectionExtensionsTests.cs │ │ └── keypair.snk ├── Macross.Windows.Debugging │ ├── CHANGELOG.md │ ├── Code │ │ ├── DebugWindow.Layout.cs │ │ ├── DebugWindow.cs │ │ ├── DebugWindowConfigureAction.cs │ │ ├── DebugWindowConfigureTabAction.cs │ │ ├── DebugWindowFactory.cs │ │ ├── DebugWindowHost.cs │ │ ├── DebugWindowHostedService.cs │ │ ├── DebugWindowLogger.cs │ │ ├── DebugWindowLoggerOptions.cs │ │ ├── DebugWindowLoggerProvider.cs │ │ ├── DebugWindowMessageManager.cs │ │ ├── DebugWindowTabPage.Layout.cs │ │ ├── DebugWindowTabPage.cs │ │ ├── DebuggingExtensions.cs │ │ ├── Macross.Windows.Debugging.csproj │ │ ├── NativeMethods.cs │ │ ├── NullScope.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── WinFormsExtensions.cs │ │ └── keypair.snk │ ├── Demo │ │ ├── Controllers │ │ │ └── WeatherForecastController.cs │ │ ├── DemoWebApplication.csproj │ │ ├── IWeatherService.cs │ │ ├── MessageSpamBackgroundService.cs │ │ ├── Middleware │ │ │ └── RequestTraceMiddleware.cs │ │ ├── Pages │ │ │ ├── Error.cshtml │ │ │ ├── Error.cshtml.cs │ │ │ ├── Index.cshtml │ │ │ ├── Index.cshtml.cs │ │ │ ├── Privacy.cshtml │ │ │ ├── Privacy.cshtml.cs │ │ │ ├── Shared │ │ │ │ ├── _Layout.cshtml │ │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ │ └── _WeatherServicePartial.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── _ViewStart.cshtml │ │ ├── Program.cs │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ └── launchSettings.json │ │ ├── README.md │ │ ├── Startup.cs │ │ ├── WeatherForecast.cs │ │ ├── WeatherService.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── wwwroot │ │ │ ├── css │ │ │ └── site.css │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ └── site.js │ │ │ └── lib │ │ │ ├── bootstrap │ │ │ ├── LICENSE │ │ │ └── dist │ │ │ │ ├── css │ │ │ │ ├── bootstrap-grid.css │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ ├── bootstrap.css │ │ │ │ ├── bootstrap.css.map │ │ │ │ ├── bootstrap.min.css │ │ │ │ └── bootstrap.min.css.map │ │ │ │ └── js │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.js.map │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── bootstrap.min.js.map │ │ │ ├── jquery-validation-unobtrusive │ │ │ ├── LICENSE.txt │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ ├── LICENSE.md │ │ │ └── dist │ │ │ │ ├── additional-methods.js │ │ │ │ ├── additional-methods.min.js │ │ │ │ ├── jquery.validate.js │ │ │ │ └── jquery.validate.min.js │ │ │ └── jquery │ │ │ ├── LICENSE.txt │ │ │ └── dist │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ ├── Example.png │ ├── README.md │ └── Test │ │ ├── TestConsoleApp │ │ ├── MessageSpamBackgroundService.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── TestConsoleApp.csproj │ │ ├── TestWebApplication │ │ ├── ControllerNameLoggerGroupMiddleware.cs │ │ ├── Controllers │ │ │ └── WeatherForecastController.cs │ │ ├── MessageSpamBackgroundService.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ └── launchSettings.json │ │ ├── Startup.cs │ │ ├── TestWebApplication.csproj │ │ ├── WeatherForecast.cs │ │ ├── appsettings.Development.json │ │ └── appsettings.json │ │ └── TestWindowsService │ │ ├── MessageSpamBackgroundService.cs │ │ ├── Program.cs │ │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── launchSettings.json │ │ ├── TestWindowsService.csproj │ │ ├── appsettings.Development.json │ │ └── appsettings.json ├── Macross.Windows.Impersonation │ ├── Code │ │ ├── Extensions │ │ │ └── System.Net │ │ │ │ └── ImpersonationExtensions.cs │ │ ├── ImpersonationSettings.cs │ │ ├── Macross.Windows.Impersonation.csproj │ │ ├── NativeMethods.Win32.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── keypair.snk │ └── README.md ├── Macross.Windows.Permissions │ ├── Code │ │ ├── LocalSecurityAuthorityController.cs │ │ ├── Macross.Windows.Permissions.csproj │ │ ├── NativeMethods.Win32.cs │ │ ├── PermissionsHelper.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── keypair.snk │ └── README.md └── Macross.Windows.ServiceManagement │ ├── Code │ ├── Macross.Windows.ServiceManagement.csproj │ ├── NativeMethods.Win32.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SafeServiceHandle.cs │ ├── Service.cs │ ├── ServiceAccount.cs │ ├── ServiceConfiguration.cs │ ├── ServiceController.cs │ ├── ServiceHelper.cs │ ├── ServiceStartMode.cs │ ├── ServiceState.cs │ └── keypair.snk │ └── README.md ├── CodeAnalysis.ruleset ├── Directory.Build.props ├── Directory.Packages.props ├── LICENSE.txt ├── Macross-Master.sln ├── NuGet.config ├── README.md ├── global.json └── stylecop.json /Build/Gated Build Pipeline.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - master 3 | - develop 4 | 5 | variables: 6 | solution: 'Macross-Master.sln' 7 | buildPlatform: 'Any CPU' 8 | buildConfiguration: 'Release' 9 | 10 | jobs: 11 | - job: Macross_Master_Gated_Win 12 | displayName: Macross Master Solution Gated Build - Windows 13 | pool: 14 | vmImage: 'windows-latest' 15 | steps: 16 | - task: UseDotNet@2 17 | inputs: 18 | useGlobalJson: true 19 | 20 | - task: UseDotNet@2 21 | inputs: 22 | version: '5.0.x' 23 | 24 | - task: UseDotNet@2 25 | inputs: 26 | version: '3.1.x' 27 | 28 | - task: UseDotNet@2 29 | inputs: 30 | version: '2.1.x' 31 | 32 | - task: NuGetToolInstaller@1 33 | inputs: 34 | versionSpec: 5.8 35 | 36 | - task: DotNetCoreCLI@2 37 | displayName: Dotnet Restore 38 | inputs: 39 | command: 'restore' 40 | projects: '$(solution)' 41 | arguments: '--configuration $(buildConfiguration)' 42 | 43 | - task: DotNetCoreCLI@2 44 | displayName: Dotnet Build 45 | inputs: 46 | command: 'build' 47 | projects: '$(solution)' 48 | arguments: '--configuration $(buildConfiguration) --no-restore' 49 | 50 | - task: DotNetCoreCLI@2 51 | displayName: Dotnet Test 52 | inputs: 53 | command: 'test' 54 | projects: '$(solution)' 55 | arguments: '--configuration $(buildConfiguration) --no-build --filter TestCategory!=Integration' -------------------------------------------------------------------------------- /ClassLibraries/Macross.CommandLine/Code/Macross.CommandLine.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;netstandard2.0 5 | True 6 | keypair.snk 7 | 8 | Macross Software command-line library. 9 | 10 | Provides a simple lightweight API for parsing command-line arguments in the .NET CLI style. 11 | 12 | Commonly Used Types: 13 | Macross.CommandLine.CommandLineArgumentParser 14 | 15 | Macross.CommandLine 16 | true 17 | false 18 | false 19 | 0.0.1 20 | alpha1 21 | $(VersionPrefix) 22 | 23 | 24 | 25 | $(VersionPrefix) 26 | 27 | 28 | $(VersionPrefix)-$(VersionSuffix) 29 | 30 | 31 | 32 | ..\..\..\_build\DLLs\$(Configuration)\ 33 | ..\..\..\_build\DLLs\$(Configuration)\Macross.CommandLine.xml 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.CommandLine/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("c41cb00f-9086-4e76-936f-da915f971e51")] 9 | 10 | [assembly: AssemblyVersion("0.0.1.20011")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.CommandLine/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.CommandLine/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.CommandLine/README.md: -------------------------------------------------------------------------------- 1 | # Macross Software Command-Line 2 | 3 | Macross.CommandLine is a simple and light-weight .NET Standard 2.0+ library for parsing the `string[]` command-line arguments passed into a process into a command with optional parameters, options, and switches. 4 | 5 | ## Format 6 | 7 | The parser supports the general format used by the `dotnet` command-line interface: 8 | 9 | `C:\application.exe command parameter1 parameter2 -option1 option1value -option2=option2value --option3 option3value -switch1` -------------------------------------------------------------------------------- /ClassLibraries/Macross.CommandLine/Test/Macross.CommandLine.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1;net5.0 5 | true 6 | keypair.snk 7 | Macross Software command-line library tests. 8 | Macross.CommandLine.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.CommandLine/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("fbcc246e-0153-42fb-91ff-da3d132ed529")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20018")] 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.CommandLine/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.CommandLine/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Extensions/System/System.Collections.Generic/DictionaryExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace System.Collections.Generic 2 | { 3 | /// 4 | /// Methods extending what is provided in the System.Collections.Generic namespace for Dictionaries. 5 | /// 6 | public static class DictionaryExtensions 7 | { 8 | /// 9 | /// Gets a value from the instance or returns a default if not found. 10 | /// 11 | /// Key Type. 12 | /// Value Type. 13 | /// instance. 14 | /// Key value to search for. 15 | /// Default value to return if Key cannot be found. 16 | /// Value found for the key or default value if key was not found. 17 | public static TValue ValueOrDefault(this IDictionary dictionary, TKey key, TValue defaultValue) 18 | { 19 | if (dictionary == null) 20 | throw new ArgumentNullException(nameof(dictionary)); 21 | 22 | return !dictionary.TryGetValue(key, out TValue Value) 23 | ? defaultValue 24 | : Value; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Extensions/System/System.IO/BinaryExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace System.IO 2 | { 3 | /// 4 | /// Methods extending what is provided in the System namespace for binary manipulation. 5 | /// 6 | public static class BinaryExtensions 7 | { 8 | /// 9 | /// Write a instance to a instance. 10 | /// 11 | /// instance. 12 | /// instance. 13 | public static void Write(this BinaryWriter writer, BitCompactor bitCompactor) 14 | { 15 | if (writer == null) 16 | throw new ArgumentNullException(nameof(writer)); 17 | if (bitCompactor == null) 18 | throw new ArgumentNullException(nameof(bitCompactor)); 19 | 20 | writer.Write(bitCompactor.Value); 21 | } 22 | 23 | /// 24 | /// Read a instance from a instance. 25 | /// 26 | /// instance. 27 | /// Number of bits stored. 28 | /// instance. 29 | public static BitCompactor ReadBitCompactor(this BinaryReader reader, int numberOfBits) 30 | { 31 | if (reader == null) 32 | throw new ArgumentNullException(nameof(reader)); 33 | if (numberOfBits < 1) 34 | throw new ArgumentOutOfRangeException(nameof(numberOfBits)); 35 | 36 | return new BitCompactor(reader.ReadBytes(BitCompactor.CalculateBytesNeededToStoreBits(numberOfBits))); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Extensions/System/System.Reflection/ReflectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace System.Reflection 5 | { 6 | /// 7 | /// Methods extending what is provided in the System.Reflection namespace for reflection. 8 | /// 9 | public static class ReflectionExtensions 10 | { 11 | /// 12 | /// Load as many types from the given as possible. 13 | /// 14 | /// source. 15 | /// All the s that could be loaded successfully from the supplied . 16 | public static IEnumerable GetTypesSafely(this Assembly assembly) 17 | { 18 | if (assembly == null) 19 | throw new ArgumentNullException(nameof(assembly)); 20 | 21 | try 22 | { 23 | return assembly.GetTypes(); 24 | } 25 | catch (ReflectionTypeLoadException ex) 26 | { 27 | return ex.Types.Where(x => x != null); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Macross.Extensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;netstandard2.0 5 | True 6 | keypair.snk 7 | 8 | Macross Software extensions library. 9 | 10 | Provides useful types, helper methods, and utilities not found in the framework. 11 | 12 | Commonly Used Types: 13 | System.ParseFunc 14 | System.TryParseFunc 15 | System.BitCompactor 16 | 17 | Commonly Used Extensions: 18 | System.IEnumerable<byte>.ToHexView 19 | 20 | Macross.Extensions 21 | true 22 | false 23 | false 24 | 0.0.1 25 | alpha1 26 | $(VersionPrefix) 27 | 28 | 29 | 30 | $(VersionPrefix) 31 | 32 | 33 | $(VersionPrefix)-$(VersionSuffix) 34 | 35 | 36 | 37 | ..\..\..\_build\DLLs\$(Configuration)\ 38 | ..\..\..\_build\DLLs\$(Configuration)\Macross.Extensions.xml 39 | 40 | 41 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("6468b8f5-b893-4216-9a0f-64a1a7f9112a")] 9 | 10 | [assembly: AssemblyVersion("0.0.1.21206")] 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Types/System/IJsonConfigurable.cs: -------------------------------------------------------------------------------- 1 | namespace System 2 | { 3 | /// 4 | /// Marks objects that can be configured from a JSON string. 5 | /// 6 | public interface IJsonConfigurable 7 | { 8 | /// 9 | /// Apply JSON string configuration to the current instance. 10 | /// 11 | /// JSON string configuration. 12 | void ApplyJsonConfiguration(string configuration); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Types/System/ManualInterventionException.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace System 4 | { 5 | /// 6 | /// Thrown when an issue is encountered requiring the attention of an admin. 7 | /// 8 | [Serializable] 9 | public class ManualInterventionException : Exception 10 | { 11 | /// 12 | public ManualInterventionException() 13 | : base() 14 | { 15 | } 16 | 17 | /// 18 | public ManualInterventionException(string message) 19 | : base(message) 20 | { 21 | } 22 | 23 | /// 24 | public ManualInterventionException(string message, Exception innerException) 25 | : base(message, innerException) 26 | { 27 | } 28 | 29 | /// 30 | protected ManualInterventionException(SerializationInfo serializationInfo, StreamingContext streamingContext) 31 | : base(serializationInfo, streamingContext) 32 | { 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Types/System/MaskedRegion.cs: -------------------------------------------------------------------------------- 1 | namespace System 2 | { 3 | /// 4 | /// Stores the offset of a region of data to be masked when written to log files and traces. 5 | /// 6 | public class MaskedRegion 7 | { 8 | /// 9 | /// Gets the starting offset (inclusive) of the . 10 | /// 11 | public int StartOffsetInclusive { get; } 12 | 13 | /// 14 | /// Gets the ending offset (exclusive) of the . 15 | /// 16 | public int EndOffsetExclusive { get; } 17 | 18 | /// 19 | /// Gets the length of the . 20 | /// 21 | public int Length => EndOffsetExclusive - StartOffsetInclusive; 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// The starting zero-based index of the masked region. 27 | /// The number of characters to mask from the starting offset. 28 | public MaskedRegion(int offset, int count) 29 | { 30 | if (offset < 0) 31 | throw new ArgumentOutOfRangeException(nameof(offset)); 32 | if (count < 0) 33 | throw new ArgumentOutOfRangeException(nameof(count)); 34 | 35 | StartOffsetInclusive = offset; 36 | EndOffsetExclusive = offset + count; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Types/System/ParseFunc.cs: -------------------------------------------------------------------------------- 1 | namespace System 2 | { 3 | /// 4 | /// Delegate for parsing a string value into a destination Type. 5 | /// 6 | /// Destination Type. 7 | /// Source string value. 8 | /// Parsed value in the destination Type. 9 | public delegate T ParseFunc(string input); 10 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/Types/System/TryParseFunc.cs: -------------------------------------------------------------------------------- 1 | namespace System 2 | { 3 | /// 4 | /// Delegate for attempting to parse a string value into a destination Type. 5 | /// 6 | /// Destination Type. 7 | /// Source string value. 8 | /// The parsed value as an instance of when parsing was successful. 9 | /// Whether or not parsing was successful. 10 | public delegate bool TryParseFunc(string input, out T value); 11 | } 12 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Extensions/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/README.md: -------------------------------------------------------------------------------- 1 | # Macross Software Extensons 2 | 3 | Macross.Extensions is .NET Standard 2.0+ library for augmenting what is provided out of the box by the framework. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Test/EnumExtensionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace Macross.Extensions.Tests 7 | { 8 | [TestClass] 9 | public class EnumExtensionTests 10 | { 11 | private enum TestEnum : int 12 | { 13 | Default = 0, 14 | Definition1 = 1, 15 | [EnumMember(Value = "B")] 16 | Definition2 = 2, 17 | } 18 | 19 | [TestMethod] 20 | public void EnumParseStringMatchesDefinitionTest() 21 | { 22 | TestEnum ExptectedValue = TestEnum.Definition1; 23 | TestEnum ActualValue = "Definition1".ToEnum(); 24 | 25 | Assert.AreEqual(ExptectedValue, ActualValue); 26 | } 27 | 28 | [TestMethod] 29 | public void EnumParseStringMatchesAttributeTest() 30 | { 31 | TestEnum ExptectedValue = TestEnum.Definition2; 32 | TestEnum ActualValue = "B".ToEnum(); 33 | 34 | Assert.AreEqual(ExptectedValue, ActualValue); 35 | } 36 | 37 | [TestMethod] 38 | public void EnumParseFallbackTest() 39 | { 40 | TestEnum ExptectedValue = TestEnum.Default; 41 | TestEnum ActualValue = "Definition3".ToEnum(TestEnum.Default); 42 | 43 | Assert.AreEqual(ExptectedValue, ActualValue); 44 | } 45 | 46 | [TestMethod] 47 | [ExpectedException(typeof(ArgumentException))] 48 | public void EnumParseInvalidMatchTest() => "Definition3".ToEnum(); 49 | 50 | [TestMethod] 51 | public void EnumFromValueTest() 52 | { 53 | TestEnum ExptectedValue = TestEnum.Definition2; 54 | TestEnum ActualValue = 2.ToEnum(); 55 | 56 | Assert.AreEqual(ExptectedValue, ActualValue); 57 | } 58 | 59 | [TestMethod] 60 | public void EnumFromValueFallbackTest() 61 | { 62 | TestEnum ExptectedValue = TestEnum.Default; 63 | TestEnum ActualValue = 99.ToEnum(TestEnum.Default); 64 | 65 | Assert.AreEqual(ExptectedValue, ActualValue); 66 | } 67 | 68 | [TestMethod] 69 | [ExpectedException(typeof(ArgumentException))] 70 | public void EnumFromValueInvalidMatchTest() => 99.ToEnum(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Test/HexStringExtensionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | 7 | namespace Macross.Extensions.Tests 8 | { 9 | [TestClass] 10 | public class HexStringExtensionTests 11 | { 12 | [TestMethod] 13 | public void ByteArrayToHexStringTestSuccess() 14 | { 15 | byte[] Value = new byte[] { 0xFF, 0x01, 0x0A, 0x15, 0xBD }; 16 | 17 | string Actual = Value.ToHexString(); 18 | 19 | Assert.AreEqual("FF010A15BD", Actual); 20 | } 21 | 22 | [TestMethod] 23 | public void ByteToHexStringTestSuccess() 24 | { 25 | string Actual = ((byte)0x1A).ToHexString(); 26 | 27 | Assert.AreEqual("1A", Actual); 28 | } 29 | 30 | [TestMethod] 31 | public void HexStringToByteArrayTestSuccess() 32 | { 33 | string Value = "FF010A15BD"; 34 | 35 | byte[] Actual = Value.ToByteArray(); 36 | 37 | byte[] Expected = new byte[] { 0xFF, 0x01, 0x0A, 0x15, 0xBD }; 38 | 39 | Assert.IsTrue(Expected.SequenceEqual(Actual)); 40 | } 41 | 42 | [TestMethod] 43 | public void HexStringMixedCaseToByteArrayTestSuccess() 44 | { 45 | string Value = "Ff010a15bdFF"; 46 | 47 | byte[] Actual = Value.ToByteArray(); 48 | 49 | byte[] Expected = new byte[] { 0xFF, 0x01, 0x0A, 0x15, 0xBD, 0xFF }; 50 | 51 | Assert.IsTrue(Expected.SequenceEqual(Actual)); 52 | } 53 | 54 | [TestMethod] 55 | [ExpectedException(typeof(InvalidOperationException))] 56 | public void InvalidLengthHexStringToByteArrayTestFailure() 57 | { 58 | string Value = "Ff0"; 59 | 60 | Value.ToByteArray(); 61 | } 62 | 63 | [TestMethod] 64 | [ExpectedException(typeof(ArgumentOutOfRangeException))] 65 | public void InvalidContentHexStringToByteArrayTestFailure() 66 | { 67 | string Value = "hello world!"; 68 | 69 | Value.ToByteArray(); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Test/Macross.Extensions.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1;net5.0 5 | true 6 | keypair.snk 7 | Macross Software extensions library tests. 8 | Macross.Extensions.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("3a8f072c-81ae-4d55-892e-53207032baa3")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20018")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Test/StringExtensionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | 7 | namespace Macross.Extensions.Tests 8 | { 9 | [TestClass] 10 | public class StringExtensionTests 11 | { 12 | [TestMethod] 13 | public void StringSplitPredicateTest() 14 | { 15 | string[] Expected = new string[] 16 | { 17 | "value1", 18 | "value2" 19 | }; 20 | IEnumerable Actual = "value1|value2".Split(c => c == '|'); 21 | 22 | Assert.IsTrue(Expected.SequenceEqual(Actual)); 23 | } 24 | 25 | [TestMethod] 26 | public void StringSplitPredicateWithEmptyTest() 27 | { 28 | string[] Expected = new string[] 29 | { 30 | "value1", 31 | string.Empty, 32 | " ", 33 | "value2" 34 | }; 35 | IEnumerable Actual = "value1|| |value2".Split(c => c == '|'); 36 | 37 | Assert.IsTrue(Expected.SequenceEqual(Actual)); 38 | } 39 | 40 | [TestMethod] 41 | public void StringSplitPredicateWithEmptyRemovedTest() 42 | { 43 | string[] Expected = new string[] 44 | { 45 | "value1", 46 | " ", 47 | "value2" 48 | }; 49 | IEnumerable Actual = "value1|| |value2".Split(c => c == '|', StringSplitOptions.RemoveEmptyEntries); 50 | 51 | Assert.IsTrue(Expected.SequenceEqual(Actual)); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Test/ToStringArrayExtensionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace Macross.Extensions.Tests 7 | { 8 | [TestClass] 9 | public class ToStringArrayExtensionTests 10 | { 11 | [TestMethod] 12 | public void TestToStringArrayExtensionBasicSuccess() 13 | { 14 | ArraySegment[] Data = new ArraySegment[] 15 | { 16 | new ArraySegment(Encoding.ASCII.GetBytes("Hello")), 17 | new ArraySegment(Encoding.ASCII.GetBytes("World")), 18 | }; 19 | 20 | string[] Strings = Data.ToStringArray(Encoding.ASCII); 21 | 22 | Assert.IsNotNull(Strings); 23 | Assert.AreEqual(2, Strings.Length); 24 | Assert.AreEqual("Hello", Strings[0]); 25 | Assert.AreEqual("World", Strings[1]); 26 | } 27 | 28 | [TestMethod] 29 | public void TestToStringArrayExtensionNullRecordSuccess() 30 | { 31 | ArraySegment[] Data = new ArraySegment[] 32 | { 33 | new ArraySegment(Encoding.ASCII.GetBytes("Hello"), 1, 3) 34 | }; 35 | 36 | string[] Strings = Data.ToStringArray(Encoding.ASCII); 37 | 38 | Assert.IsNotNull(Strings); 39 | Assert.AreEqual(1, Strings.Length); 40 | Assert.AreEqual("ell", Strings[0]); 41 | } 42 | 43 | [TestMethod] 44 | public void TestToStringArrayExtensionInvalidCharactersSuccess() 45 | { 46 | byte[] One = new byte[] { 0x00, 0x00, 0x00 }; 47 | byte[] Two = new byte[] { (byte)'A', 0x2F, (byte)'z' }; 48 | byte[] Three = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }; 49 | 50 | ArraySegment[] Data = new ArraySegment[] 51 | { 52 | new ArraySegment(One), 53 | new ArraySegment(Two), 54 | new ArraySegment(Three) 55 | }; 56 | 57 | string[] Strings = Data.ToStringArray(Encoding.ASCII); 58 | 59 | Assert.IsNotNull(Strings); 60 | Assert.AreEqual(3, Strings.Length); 61 | Assert.AreEqual(Encoding.ASCII.GetString(One), Strings[0]); 62 | Assert.AreEqual(Encoding.ASCII.GetString(Two), Strings[1]); 63 | Assert.AreEqual(Encoding.ASCII.GetString(Three), Strings[2]); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Extensions/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Extensions/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: ComVisible(false)] 7 | [assembly: CLSCompliant(false)] 8 | 9 | [assembly: Guid("46de8812-8b05-40b9-8012-7702f9f31506")] 10 | 11 | [assembly: InternalsVisibleTo("Macross.Json.Extensions.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051b7a480b13cecfa44862449486c6884bd6168c325445a0848f48deca9643657c5ae85df3cf6ffdb24d5bd3e9b71dc074ca602544b83511fbce1f83f1d06bb8b7b564414c9d8c719e4e39b95643dfc8e9ce997b5e2a1542a8ff6379186f87b8b695fee82c506170c4fb8ffcbf2e68f4b5d270083f8909c67916500608ce747e9")] 12 | 13 | [assembly: AssemblyVersion("3.0.0.22164")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Code/System.Net.Http/PushStreamContent.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | 4 | namespace System.Net.Http 5 | { 6 | /// 7 | /// Provides an implementation that exposes an output 8 | /// which can be written to directly. The ability to push data to the output stream differs from the 9 | /// where data is pulled and not pushed. 10 | /// 11 | public class PushStreamContent : HttpContent 12 | { 13 | private readonly Func _OnStreamAvailable; 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// Callback function to write to the stream once it is available. 19 | public PushStreamContent(Func onStreamAvailable) 20 | { 21 | _OnStreamAvailable = onStreamAvailable ?? throw new ArgumentNullException(nameof(onStreamAvailable)); 22 | } 23 | 24 | /// 25 | protected override async Task SerializeToStreamAsync(Stream stream, TransportContext? context) 26 | => await _OnStreamAvailable(stream).ConfigureAwait(false); 27 | 28 | /// 29 | protected override bool TryComputeLength(out long length) 30 | { 31 | // We can't know the length of the content being pushed to the output stream. 32 | length = -1; 33 | return false; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Code/System.Net.Http/PushStreamContent{T}.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | 4 | namespace System.Net.Http 5 | { 6 | /// 7 | /// Provides an implementation that exposes an output 8 | /// which can be written to directly. The ability to push data to the output stream differs from the 9 | /// where data is pulled and not pushed. 10 | /// 11 | /// State type. 12 | public class PushStreamContent : HttpContent 13 | { 14 | private readonly Func _OnStreamAvailable; 15 | private readonly T _State; 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// Callback function to write to the stream once it is available. 21 | /// State to be passed to the callback function. 22 | public PushStreamContent(Func onStreamAvailable, T state) 23 | { 24 | _OnStreamAvailable = onStreamAvailable ?? throw new ArgumentNullException(nameof(onStreamAvailable)); 25 | _State = state; 26 | } 27 | 28 | /// 29 | protected override async Task SerializeToStreamAsync(Stream stream, TransportContext? context) 30 | => await _OnStreamAvailable(stream, _State).ConfigureAwait(false); 31 | 32 | /// 33 | protected override bool TryComputeLength(out long length) 34 | { 35 | // We can't know the length of the content being pushed to the output stream. 36 | length = -1; 37 | return false; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Code/System.Text.Json.Serialization/JsonTypeConverterAdapter.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | using Macross.Json.Extensions; 6 | 7 | namespace System.Text.Json.Serialization 8 | { 9 | /// 10 | /// to convert types to and from strings using s. Supports nullable value types. 11 | /// 12 | public class JsonTypeConverterAdapter : JsonConverterFactory 13 | { 14 | /// 15 | public override bool CanConvert(Type typeToConvert) 16 | { 17 | if (typeToConvert.GetCustomAttributes(inherit: true).Any()) 18 | { 19 | TypeConverter typeConverter = TypeDescriptor.GetConverter(typeToConvert); 20 | return typeConverter.CanConvertFrom(typeof(string)) && typeConverter.CanConvertTo(typeof(string)); 21 | } 22 | return false; 23 | } 24 | 25 | /// 26 | public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) 27 | { 28 | Type converterType = typeof(TypeConverterAdapter<>).MakeGenericType(typeToConvert); 29 | return (JsonConverter)Activator.CreateInstance(converterType)!; 30 | } 31 | 32 | private class TypeConverterAdapter : JsonConverter 33 | { 34 | private readonly TypeConverter _Converter; 35 | 36 | public TypeConverterAdapter() 37 | { 38 | _Converter = TypeDescriptor.GetConverter(typeof(T)); 39 | } 40 | 41 | /// 42 | public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 43 | { 44 | return reader.TokenType != JsonTokenType.String 45 | ? throw ThrowHelper.GenerateJsonException_DeserializeUnableToConvertValue(typeof(T)) 46 | : (T)_Converter.ConvertFromString(reader.GetString()!)!; 47 | } 48 | 49 | /// 50 | public override void Write(Utf8JsonWriter writer, T objectToWrite, JsonSerializerOptions options) 51 | => writer.WriteStringValue(_Converter.ConvertToString(objectToWrite)); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Json.Extensions/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Test/DateTimeWireFormatHelperTests.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using System.Text.Json.Serialization; 3 | 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace Macross.Json.Extensions.Tests 7 | { 8 | [TestClass] 9 | public class DateTimeWireFormatHelperTests 10 | { 11 | [TestMethod] 12 | [DataRow("/Date(1)/", 1)] 13 | [DataRow("/Date(-1)/", -1)] 14 | [DataRow("/Date(18+1234)/", 18, 1, 12, 34)] 15 | [DataRow("/Date(-20-9876)/", -20, -1, 98, 76)] 16 | [DataRow(@"\/Date(1580803200000)\/", 1580803200000)] 17 | [DataRow(@"\/Date(1580803200000+0800)\/", 1580803200000, 1, 8, 0)] 18 | public void ValidTryParseTests(string json, long ticks, int multiplier = 0, int hours = 0, int minutes = 0) 19 | { 20 | bool result = DateTimeWireFormatHelper.TryParse(Encoding.UTF8.GetBytes(json), out DateTimeWireFormatHelper.DateTimeOffsetParseResult parseResult); 21 | 22 | Assert.IsTrue(result); 23 | Assert.AreEqual(ticks, parseResult.UnixEpochMilliseconds); 24 | Assert.AreEqual(multiplier, parseResult.OffsetMultiplier); 25 | Assert.AreEqual(hours, parseResult.OffsetHours); 26 | Assert.AreEqual(minutes, parseResult.OffsetMinutes); 27 | } 28 | 29 | [TestMethod] 30 | [DataRow("")] 31 | [DataRow("/Date()/")] 32 | [DataRow("/Date000/")] 33 | [DataRow("/Date(0)0")] 34 | [DataRow("0Date(0)/")] 35 | [DataRow("/Date(012/")] 36 | [DataRow("/date(0)/")] 37 | [DataRow(@"\/Date(0)/")] 38 | [DataRow(@"/Date(0)\/")] 39 | [DataRow("/Date(+0000)/")] 40 | [DataRow("/Date(1234a+0000)/")] 41 | [DataRow("/Date(1234-000a)/")] 42 | [DataRow("/Date(1234-00z0)/")] 43 | [DataRow("/Date(1234-0a00)/")] 44 | [DataRow("/Date(1234-z000)/")] 45 | [DataRow("/Date(1234+000)/")] 46 | [DataRow("/Date(1234+00000)/")] 47 | [DataRow("/Date(-)/")] 48 | [DataRow("/Date(0+)/")] 49 | public void InvalidTryParseTests(string json) 50 | { 51 | bool result = DateTimeWireFormatHelper.TryParse(Encoding.UTF8.GetBytes(json), out DateTimeWireFormatHelper.DateTimeOffsetParseResult parseResult); 52 | 53 | Assert.IsFalse(result); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Test/JsonIPAddressConverterTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Text.Json; 4 | using System.Text.Json.Serialization; 5 | 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | 8 | namespace Macross.Json.Extensions.Tests 9 | { 10 | [TestClass] 11 | public class JsonIPAddressConverterTests 12 | { 13 | [TestMethod] 14 | public void IPAddressSerializationTest() 15 | { 16 | string Json = JsonSerializer.Serialize( 17 | new TestClass 18 | { 19 | IPAddress = IPAddress.Loopback 20 | }); 21 | 22 | Assert.AreEqual(@"{""IPAddress"":""127.0.0.1""}", Json); 23 | 24 | Json = JsonSerializer.Serialize( 25 | new TestClass 26 | { 27 | IPAddress = IPAddress.IPv6Loopback 28 | }); 29 | 30 | Assert.AreEqual(@"{""IPAddress"":""::1""}", Json); 31 | 32 | Json = JsonSerializer.Serialize( 33 | new TestClass 34 | { 35 | IPAddress = null 36 | }); 37 | 38 | Assert.AreEqual(@"{""IPAddress"":null}", Json); 39 | } 40 | 41 | [TestMethod] 42 | public void IPAddressDeserializationTest() 43 | { 44 | TestClass? Actual = JsonSerializer.Deserialize(@"{""IPAddress"":""127.0.0.1""}"); 45 | 46 | Assert.IsNotNull(Actual); 47 | Assert.AreEqual(IPAddress.Loopback, Actual.IPAddress); 48 | 49 | Actual = JsonSerializer.Deserialize(@"{""IPAddress"":""::1""}"); 50 | 51 | Assert.IsNotNull(Actual); 52 | Assert.AreEqual(IPAddress.IPv6Loopback, Actual.IPAddress); 53 | 54 | Actual = JsonSerializer.Deserialize(@"{""IPAddress"":null}"); 55 | 56 | Assert.IsNotNull(Actual); 57 | Assert.IsNull(Actual.IPAddress); 58 | } 59 | 60 | [ExpectedException(typeof(JsonException))] 61 | [TestMethod] 62 | public void IPAddressInvalidTypeDeserializationTest() => JsonSerializer.Deserialize(@"{""IPAddress"":1}"); 63 | 64 | [ExpectedException(typeof(JsonException))] 65 | [TestMethod] 66 | public void IPAddressInvalidValueDeserializationTest() => JsonSerializer.Deserialize(@"{""IPAddress"":""invalid_value""}"); 67 | 68 | private class TestClass 69 | { 70 | [JsonConverter(typeof(JsonIPAddressConverter))] 71 | public IPAddress? IPAddress { get; set; } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Test/Macross.Json.Extensions.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1;net6.0;net462 5 | true 6 | keypair.snk 7 | Macross Software System.Text.Json extensions library tests. 8 | Macross.Json.Extensions.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("c365f59c-0a68-463e-91f0-9d026b568f01")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.22159")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Json.Extensions/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Json.Extensions/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2.0.0 4 | 5 | * Improved the performance of `LoggerJsonMessage` serialization: 6 | 7 | * `LogLevel` is now a string. `JsonStringEnumMemberConverter` no longer needs 8 | to be invoked during serialization. 9 | 10 | * `LoggerJsonMessage.Scope` switched to `List`, 11 | `LoggerJsonMessage.Data` switched to `Dictionary`, and 12 | `LoggerJsonMessageException.InnerExceptions` switched to 13 | `List` so `JsonSerializer` can take advantage of 14 | the `struct` enumerators exposed on the concrete types. Instances will now 15 | also be pooled (up to 1024 items per type) to reduce allocations and resize 16 | copying. 17 | 18 | * `LoggerJsonMessageException.InnerExceptions.StackTrace` switched to `string` 19 | from `IEnumerabl` so that string manipulation doesn't need to be 20 | performed during message creation. 21 | 22 | * State & Scope processing will now attempt to perform `for` loops over 23 | `IReadOnlyList`s before performing `foreach` loops over `IEnumerable`s to 24 | avoid enumerator allocation. 25 | 26 | * `TypeDescriptor.GetProperties` usage replaced by `Type.GetProperties`. The 27 | resulting property model for a type is now cached to reduce allocations and 28 | processing time. 29 | 30 | * `IExternalScopeProvider` is now passed into 31 | `LoggerJsonMessage.FromLoggerData` so that scopes can be processed directly 32 | onto the message. 33 | 34 | * Added a `struct` enumerator to `FormattedLogValues` (used by `Write*` 35 | extensions) to eliminate boxing. 36 | 37 | * Updated `LogValuesFormatter` to the latest version from `dotnet\runtime` to 38 | reduce allocations on startup. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Code/LoggerGroup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Microsoft.Extensions.Logging 4 | { 5 | /// 6 | /// A class for representing a group of logger messages. 7 | /// 8 | public class LoggerGroup 9 | { 10 | /// 11 | /// Gets the group name. 12 | /// 13 | public string GroupName { get; } 14 | 15 | /// 16 | /// Gets the priority of the group. 17 | /// 18 | /// 19 | /// When multiple s are applied the highest priority group will be selected. 20 | /// When multiple s with the same priority are found, the last one applied will be selected. 21 | /// 22 | public int Priority { get; } 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | /// Group name. 28 | /// Group priority. 29 | public LoggerGroup(string groupName, int priority = 0) 30 | { 31 | if (string.IsNullOrEmpty(groupName)) 32 | throw new ArgumentNullException(nameof(groupName)); 33 | 34 | GroupName = groupName; 35 | Priority = priority; 36 | } 37 | 38 | /// 39 | public override string ToString() => GroupName; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Code/LoggerGroupOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Macross.Logging 4 | { 5 | /// 6 | /// Stores options for grouping log messages by category. 7 | /// 8 | public class LoggerGroupOptions 9 | { 10 | /// 11 | /// Gets or sets the group name. 12 | /// 13 | public string? GroupName { get; set; } 14 | 15 | /// 16 | /// Gets or sets the category name filters that apply to the group. 17 | /// 18 | public IEnumerable? CategoryNameFilters { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("d24d02b2-8e78-4224-93da-1dd2ff88d915")] 9 | 10 | [assembly: AssemblyVersion("2.0.0.21013")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Code/PropertyGetter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Reflection; 4 | using System.Reflection.Emit; 5 | 6 | namespace Macross.Logging 7 | { 8 | internal class PropertyGetter 9 | { 10 | public string PropertyName { get; } 11 | 12 | public Func GetPropertyFunc { get; } 13 | 14 | public PropertyGetter(Type type, PropertyInfo propertyInfo) 15 | { 16 | PropertyName = propertyInfo.Name; 17 | 18 | GetPropertyFunc = BuildGetPropertyFunc(propertyInfo, type); 19 | } 20 | 21 | private static Func BuildGetPropertyFunc(PropertyInfo propertyInfo, Type runtimePropertyType) 22 | { 23 | MethodInfo? realMethod = propertyInfo.GetMethod; 24 | Debug.Assert(realMethod != null); 25 | 26 | Type? declaringType = propertyInfo.DeclaringType; 27 | Debug.Assert(declaringType != null); 28 | 29 | Type declaredPropertyType = propertyInfo.PropertyType; 30 | 31 | DynamicMethod dynamicMethod = new DynamicMethod( 32 | nameof(PropertyGetter), 33 | typeof(object), 34 | new[] { typeof(object) }, 35 | typeof(PropertyGetter).Module, 36 | skipVisibility: true); 37 | ILGenerator generator = dynamicMethod.GetILGenerator(); 38 | 39 | generator.Emit(OpCodes.Ldarg_0); 40 | 41 | if (declaringType.IsValueType) 42 | { 43 | generator.Emit(OpCodes.Unbox, declaringType); 44 | generator.Emit(OpCodes.Call, realMethod); 45 | } 46 | else 47 | { 48 | generator.Emit(OpCodes.Castclass, declaringType); 49 | generator.Emit(OpCodes.Callvirt, realMethod); 50 | } 51 | 52 | if (declaredPropertyType != runtimePropertyType && declaredPropertyType.IsValueType) 53 | { 54 | generator.Emit(OpCodes.Box, declaredPropertyType); 55 | } 56 | 57 | generator.Emit(OpCodes.Ret); 58 | 59 | return (Func)dynamicMethod.CreateDelegate(typeof(Func)); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Logging.Abstractions/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Test/Macross.Logging.Abstractions.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1;net5.0 5 | true 6 | keypair.snk 7 | Macross Software logging abstractions library tests. 8 | Macross.Logging.Abstractions.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("cd0b863d-924e-48e6-9b2d-17859cd0ca40")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.21013")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Abstractions/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Logging.Abstractions/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Benchmarks/Macross.Logging.Files.Benchmarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0;netcoreapp3.1 6 | true 7 | false 8 | false 9 | false 10 | false 11 | true 12 | keypair.snk 13 | false 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Benchmarks/MacrossFileLoggingProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Microsoft.Extensions.Hosting; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace LoggingBenchmarks 6 | { 7 | public static class MacrossFileLoggingProvider 8 | { 9 | public const string LogFileDirectoryPath = "C:\\LogsPerf\\Macross\\"; 10 | 11 | public static (IHost Host, ILoggerProvider LoggerProvider) CreateMacrossProvider(bool useGroupNaming = false) 12 | { 13 | IHost host = Host 14 | .CreateDefaultBuilder() 15 | .ConfigureLogging(builder => 16 | { 17 | builder.ClearProviders(); 18 | builder.AddFiles(files => 19 | { 20 | files.IncludeGroupNameInFileName = useGroupNaming; 21 | files.LogFileDirectory = LogFileDirectoryPath; 22 | files.LogFileArchiveDirectory = $"{LogFileDirectoryPath}Archive"; 23 | files.LogFileMaxSizeInKilobytes = ProviderComparisonBenchmarks.LogFileMaxSizeInBytes / 1024; 24 | }); 25 | }).Build(); 26 | 27 | return (host, host.Services.GetRequiredService()); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Benchmarks/NLogProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | using NLog; 4 | using NLog.Config; 5 | using NLog.Targets; 6 | using NLog.Layouts; 7 | using NLog.Extensions.Logging; 8 | 9 | namespace LoggingBenchmarks 10 | { 11 | #pragma warning disable CA2000 // Dispose objects before losing scope 12 | public static class NLogProvider 13 | { 14 | public const string LogFileDirectoryPath = "C:\\LogsPerf\\NLog\\"; 15 | 16 | public static (ILoggerProvider LogggerProvider, LogFactory LogFactory) CreateNLogProvider() 17 | { 18 | LoggingConfiguration Config = new LoggingConfiguration(); 19 | 20 | JsonLayout Layout = new JsonLayout 21 | { 22 | IncludeAllProperties = true 23 | }; 24 | 25 | Layout.Attributes.Add(new JsonAttribute("time", "${longdate}")); 26 | Layout.Attributes.Add(new JsonAttribute("threadId", "${threadid}")); 27 | Layout.Attributes.Add(new JsonAttribute("level", "${level:upperCase=true}")); 28 | Layout.Attributes.Add(new JsonAttribute("message", "${message}")); 29 | 30 | Target Target = new FileTarget("File") 31 | { 32 | FileName = $"{LogFileDirectoryPath}Log${{shortdate}}.log", 33 | Layout = Layout, 34 | KeepFileOpen = true, // Default for Serilog, but not for NLog 35 | ConcurrentWrites = false, // Matches Serilog Shared 36 | AutoFlush = true, // Matches Serilog Buffered 37 | ArchiveEvery = FileArchivePeriod.Day, 38 | ArchiveAboveSize = ProviderComparisonBenchmarks.LogFileMaxSizeInBytes, 39 | ArchiveNumbering = ArchiveNumberingMode.Sequence, 40 | }; 41 | 42 | Config.AddTarget("File", Target); 43 | 44 | Config.AddRuleForAllLevels(Target, "*", true); 45 | 46 | LogFactory LogFactory = new LogFactory(Config); 47 | 48 | NLogLoggerProvider Provider = new NLogLoggerProvider( 49 | new NLogProviderOptions 50 | { 51 | ShutdownOnDispose = true 52 | }, 53 | LogFactory); 54 | 55 | return (Provider, LogFactory); 56 | } 57 | } 58 | #pragma warning restore CA2000 // Dispose objects before losing scope 59 | } 60 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Benchmarks/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | 3 | namespace LoggingBenchmarks 4 | { 5 | internal static class Program 6 | { 7 | public static void Main(string[] args) 8 | => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Benchmarks/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("8717717d-8f61-4559-8095-629b34a11692")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20167")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Benchmarks/SerilogProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.Logging; 4 | 5 | using Serilog; 6 | using Serilog.Extensions.Logging; 7 | using Serilog.Formatting.Json; 8 | 9 | namespace LoggingBenchmarks 10 | { 11 | public static class SerilogProvider 12 | { 13 | public const string LogFileDirectoryPath = "C:\\LogsPerf\\Serilog\\"; 14 | 15 | public static (Action CleanupAction, ILoggerFactory LoggerFactory) CreateSerilogFactory() 16 | { 17 | Log.Logger = new LoggerConfiguration() 18 | .MinimumLevel.Debug() 19 | .Enrich.FromLogContext() 20 | .Enrich.WithThreadId() 21 | .WriteTo.File( 22 | new JsonFormatter(renderMessage: true), 23 | $"{LogFileDirectoryPath}Log.log", 24 | rollingInterval: RollingInterval.Day, 25 | fileSizeLimitBytes: ProviderComparisonBenchmarks.LogFileMaxSizeInBytes, 26 | rollOnFileSizeLimit: true, 27 | retainedFileCountLimit: null, 28 | buffered: false) 29 | .CreateLogger(); 30 | 31 | return (Log.CloseAndFlush, new SerilogLoggerFactory()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Benchmarks/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Logging.Files/Benchmarks/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 3.0.0 4 | 5 | * Updated for 3.0.0 version of 6 | [Macross.Json.Extensions](../Macross.Json.Extensions/CHANGELOG.md) which 7 | contains breaking changes. 8 | 9 | ## 2.0.0 10 | 11 | * Updated for new 12 | [Macross.Logging.Abstractions](../Macross.Logging.Abstractions/README.md) API. 13 | 14 | * Performance enhancements. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/BufferWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Buffers; 3 | using System.IO; 4 | 5 | namespace Macross.Logging.Files 6 | { 7 | internal sealed class BufferWriter : IBufferWriter 8 | { 9 | private const int MinimumBufferSize = 256; 10 | 11 | private byte[] _Buffer; 12 | private int _Index; 13 | 14 | public BufferWriter(int initialCapacity) 15 | { 16 | _Buffer = new byte[initialCapacity]; 17 | } 18 | 19 | public void Advance(int count) => _Index += count; 20 | 21 | public Memory GetMemory(int sizeHint = 0) 22 | { 23 | CheckAndResizeBuffer(sizeHint); 24 | return _Buffer.AsMemory(_Index); 25 | } 26 | 27 | public Span GetSpan(int sizeHint = 0) 28 | { 29 | CheckAndResizeBuffer(sizeHint); 30 | return _Buffer.AsSpan(_Index); 31 | } 32 | 33 | public void Clear() => _Index = 0; 34 | 35 | public void WriteToStream(Stream destination) => destination.Write(_Buffer, 0, _Index); 36 | 37 | private void CheckAndResizeBuffer(int sizeHint) 38 | { 39 | if (sizeHint == 0) 40 | sizeHint = MinimumBufferSize; 41 | 42 | int availableSpace = _Buffer.Length - _Index; 43 | 44 | if (sizeHint > availableSpace) 45 | { 46 | int growBy = Math.Max(sizeHint, _Buffer.Length); 47 | 48 | int newSize = checked(_Buffer.Length + growBy); 49 | 50 | Span previousBuffer = _Buffer.AsSpan(0, _Index); 51 | 52 | _Buffer = new byte[newSize]; 53 | 54 | previousBuffer.CopyTo(_Buffer); 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/Extensions/FileLoggerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.DependencyInjection.Extensions; 5 | using Microsoft.Extensions.Logging.Configuration; 6 | 7 | using Macross.Logging.Files; 8 | 9 | namespace Microsoft.Extensions.Logging 10 | { 11 | /// 12 | /// Contains extension methods for registering into the logging framework. 13 | /// 14 | public static class FileLoggerExtensions 15 | { 16 | /// 17 | /// Adds a file logger named 'Macross.Files' to the factory. 18 | /// 19 | /// The to use. 20 | /// A delegate to configure the . 21 | /// for chaining. 22 | public static ILoggingBuilder AddFiles(this ILoggingBuilder builder, Action? configure = null) 23 | { 24 | if (builder == null) 25 | throw new ArgumentNullException(nameof(builder)); 26 | 27 | builder.AddConfiguration(); 28 | builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); 29 | 30 | LoggerProviderOptions.RegisterProviderOptions(builder.Services); 31 | 32 | if (configure != null) 33 | builder.Services.Configure(configure); 34 | 35 | return builder; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/Extensions/FileSystem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace System.IO 4 | { 5 | internal class FileSystem : IFileSystem 6 | { 7 | public bool FileExists(string path) 8 | => File.Exists(path); 9 | 10 | public DateTime GetFileCreationTimeUtc(string path) 11 | => File.GetCreationTimeUtc(path); 12 | 13 | public void MoveFile(string sourceFileName, string destFileName) 14 | => File.Move(sourceFileName, destFileName); 15 | 16 | public Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share) 17 | => new FileStream(path, mode, access, share); 18 | 19 | public IEnumerable EnumerateFiles(string path) 20 | => Directory.EnumerateFiles(path); 21 | 22 | public IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption) 23 | => Directory.EnumerateFiles(path, searchPattern, searchOption); 24 | } 25 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/Extensions/IFileSystem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace System.IO 4 | { 5 | /// 6 | /// IFileSystem interface is a slim wrapper over the System.IO interface so that unit tests don't need to access the actual file system. 7 | /// 8 | internal interface IFileSystem 9 | { 10 | bool FileExists(string path); 11 | 12 | DateTime GetFileCreationTimeUtc(string path); 13 | 14 | void MoveFile(string sourceFileName, string destFileName); 15 | 16 | Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share); 17 | 18 | IEnumerable EnumerateFiles(string path); 19 | 20 | IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/Extensions/ISystemTime.cs: -------------------------------------------------------------------------------- 1 | namespace System 2 | { 3 | /// 4 | /// ISystemTime interface is a slim wrapper over the System interface so that unit tests don't need to access the actual actual system clock. 5 | /// 6 | internal interface ISystemTime 7 | { 8 | DateTime Now { get; } 9 | 10 | DateTime UtcNow { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/Extensions/SystemTime.cs: -------------------------------------------------------------------------------- 1 | namespace System 2 | { 3 | internal class SystemTime : ISystemTime 4 | { 5 | public DateTime Now => DateTime.Now; 6 | 7 | public DateTime UtcNow => DateTime.UtcNow; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/FileLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Macross.Logging.Files 6 | { 7 | internal class FileLogger : ILogger 8 | { 9 | private readonly string _CategoryName; 10 | private readonly Action _AddMessageAction; 11 | 12 | internal IExternalScopeProvider? ScopeProvider { get; set; } 13 | 14 | public FileLogger(string categoryName, Action addMessageAction) 15 | { 16 | _CategoryName = categoryName; 17 | _AddMessageAction = addMessageAction; 18 | } 19 | 20 | /// 21 | public IDisposable BeginScope(TState state) => ScopeProvider?.Push(state) ?? NullScope.Instance; 22 | 23 | /// 24 | public bool IsEnabled(LogLevel logLevel) => logLevel != LogLevel.None; 25 | 26 | /// 27 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) 28 | { 29 | if (!IsEnabled(logLevel)) 30 | return; 31 | 32 | _AddMessageAction( 33 | LoggerJsonMessage.FromLoggerData(_CategoryName, ScopeProvider, logLevel, eventId, state, exception, formatter)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/LogFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Macross.Logging.Files 5 | { 6 | internal class LogFile 7 | { 8 | public DateTime CreatedAtUtc { get; } 9 | 10 | public LogFileManagementSchedule ManagementSchedule { get; } 11 | 12 | public string FileName { get; } 13 | 14 | public int Index { get; } 15 | 16 | public string FinalFileName { get; } 17 | 18 | public string FinalFullPath { get; } 19 | 20 | public Stream Stream { get; } 21 | 22 | public bool Toxic { get; set; } 23 | 24 | public LogFile(DateTime createdAtUtc, LogFileManagementSchedule managementSchedule, string fileName, int index, string finalFileName, string finalFullPath, Stream stream) 25 | { 26 | CreatedAtUtc = createdAtUtc; 27 | ManagementSchedule = managementSchedule; 28 | FileName = fileName; 29 | Index = index; 30 | FinalFileName = finalFileName; 31 | FinalFullPath = finalFullPath; 32 | Stream = stream; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/NullScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Macross.Logging.Files 4 | { 5 | /// 6 | /// An empty scope without any logic. 7 | /// 8 | internal class NullScope : IDisposable 9 | { 10 | public static NullScope Instance { get; } = new NullScope(); 11 | 12 | private NullScope() 13 | { 14 | } 15 | 16 | /// 17 | public void Dispose() 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: ComVisible(false)] 7 | [assembly: CLSCompliant(false)] 8 | 9 | [assembly: Guid("77ea2f6f-8e89-4284-9d89-ba8b21c79c98")] 10 | 11 | [assembly: InternalsVisibleTo("Macross.Logging.Files.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f18113c4a5e17d17a13467a8d8aea9496b80888c79186fa4bb05627746ce50e31ea03224c4ba07ad2ae23d261739665c844ff56725c83e995e40f9a1ca61aa05577601d27fc786a2b06ecabdf00810652a86b9dab3695b70366c22e60800c0f8efeaef7fc61e43279a41b5587bea01bbe72de1350205c6f8ac06d42e3a8dd4c7")] 12 | 13 | [assembly: AssemblyVersion("3.0.0.22082")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Logging.Files/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Test/FileLoggerOptionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.Json; 3 | 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace Macross.Logging.Files.Tests 7 | { 8 | [TestClass] 9 | public class FileLoggerOptionsTests 10 | { 11 | [TestMethod] 12 | public void TimeSpanDeserializationTest() 13 | { 14 | string json = @"{ 15 | ""CutoverAndArchiveTimeZoneMode"": ""Local"", 16 | ""LogFileCutoverTime"": ""01:02:03"", 17 | ""LogFileArchiveTime"": null 18 | }"; 19 | 20 | FileLoggerOptions? Options = JsonSerializer.Deserialize(json); 21 | 22 | Assert.IsNotNull(Options); 23 | Assert.AreEqual(DateTimeKind.Local, Options.CutoverAndArchiveTimeZoneMode); 24 | Assert.AreEqual(new TimeSpan(1, 2, 3), Options.LogFileCutoverTime); 25 | Assert.IsFalse(Options.LogFileArchiveTime.HasValue); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Test/Macross.Logging.Files.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1;net5.0 5 | true 6 | keypair.snk 7 | Macross Software file logging library tests. 8 | Macross.Logging.Files.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("29e53075-89eb-4b56-a0e4-3ff05251ef92")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20025")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Test/TestSystemTime.cs: -------------------------------------------------------------------------------- 1 | namespace System 2 | { 3 | public class TestSystemTime : ISystemTime 4 | { 5 | public DateTime Now => UtcNow.ToLocalTime(); 6 | 7 | public DateTime UtcNow { get; set; } 8 | 9 | public TestSystemTime( 10 | int year, 11 | int month, 12 | int day, 13 | int hour = 0, 14 | int minute = 0, 15 | int second = 0, 16 | DateTimeKind kind = DateTimeKind.Utc) 17 | { 18 | UtcNow = kind == DateTimeKind.Local 19 | ? DateTime.SpecifyKind(new DateTime(year, month, day, hour, minute, second), DateTimeKind.Local).ToUniversalTime() 20 | : DateTime.SpecifyKind(new DateTime(year, month, day, hour, minute, second), DateTimeKind.Utc); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.Files/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Logging.Files/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/Macross.Logging.StandardOutput.Benchmarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0;netcoreapp3.1 6 | true 7 | false 8 | false 9 | false 10 | false 11 | true 12 | keypair.snk 13 | false 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/MacrossStandardOutputLoggingProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Microsoft.Extensions.Hosting; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace LoggingBenchmarks 6 | { 7 | public static class MacrossStandardOutputLoggingProvider 8 | { 9 | public static (IHost Host, ILoggerProvider LoggerProvider) CreateMacrossProvider() 10 | { 11 | IHost host = Host 12 | .CreateDefaultBuilder() 13 | .ConfigureLogging(builder => 14 | { 15 | builder.ClearProviders(); 16 | builder.AddStdout(); 17 | }).Build(); 18 | 19 | return (host, host.Services.GetRequiredService()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/NLogProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | using NLog; 4 | using NLog.Config; 5 | using NLog.Targets; 6 | using NLog.Layouts; 7 | using NLog.Extensions.Logging; 8 | 9 | namespace LoggingBenchmarks 10 | { 11 | #pragma warning disable CA2000 // Dispose objects before losing scope 12 | public static class NLogProvider 13 | { 14 | public static (ILoggerProvider LogggerProvider, LogFactory LogFactory) CreateNLogProvider() 15 | { 16 | LoggingConfiguration Config = new LoggingConfiguration(); 17 | 18 | JsonLayout Layout = new JsonLayout 19 | { 20 | IncludeAllProperties = true 21 | }; 22 | 23 | Layout.Attributes.Add(new JsonAttribute("time", "${longdate}")); 24 | Layout.Attributes.Add(new JsonAttribute("threadId", "${threadid}")); 25 | Layout.Attributes.Add(new JsonAttribute("level", "${level:upperCase=true}")); 26 | Layout.Attributes.Add(new JsonAttribute("message", "${message}")); 27 | 28 | Target Target = new ConsoleTarget("Console") 29 | { 30 | Layout = Layout, 31 | AutoFlush = true, // Matches Serilog Buffered 32 | }; 33 | 34 | Config.AddTarget("Console", Target); 35 | 36 | Config.AddRuleForAllLevels(Target, "*", true); 37 | 38 | LogFactory LogFactory = new LogFactory(Config); 39 | 40 | NLogLoggerProvider Provider = new NLogLoggerProvider( 41 | new NLogProviderOptions 42 | { 43 | ShutdownOnDispose = true 44 | }, 45 | LogFactory); 46 | 47 | return (Provider, LogFactory); 48 | } 49 | } 50 | #pragma warning restore CA2000 // Dispose objects before losing scope 51 | } 52 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | 3 | namespace LoggingBenchmarks 4 | { 5 | internal static class Program 6 | { 7 | public static void Main(string[] args) 8 | => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("e5a67469-bb89-497c-86bb-5facc3f93689")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20306")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/SerilogProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.Logging; 4 | 5 | using Serilog; 6 | using Serilog.Extensions.Logging; 7 | using Serilog.Formatting.Compact; 8 | 9 | namespace LoggingBenchmarks 10 | { 11 | public static class SerilogProvider 12 | { 13 | public static (Action CleanupAction, ILoggerFactory LoggerFactory) CreateSerilogFactory() 14 | { 15 | Log.Logger = new LoggerConfiguration() 16 | .MinimumLevel.Debug() 17 | .Enrich.FromLogContext() 18 | .Enrich.WithThreadId() 19 | .WriteTo.Console(new RenderedCompactJsonFormatter()) 20 | .CreateLogger(); 21 | 22 | return (Log.CloseAndFlush, new SerilogLoggerFactory()); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Logging.StandardOutput/Benchmarks/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2.0.0 4 | 5 | * Updated for new 6 | [Macross.Logging.Abstractions](../Macross.Logging.Abstractions/README.md) API. 7 | 8 | * Performance enhancements. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Code/BufferWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Buffers; 3 | using System.IO; 4 | 5 | namespace Macross.Logging.StandardOutput 6 | { 7 | internal sealed class BufferWriter : IBufferWriter 8 | { 9 | private const int MinimumBufferSize = 256; 10 | 11 | private byte[] _Buffer; 12 | private int _Index; 13 | 14 | public BufferWriter(int initialCapacity) 15 | { 16 | _Buffer = new byte[initialCapacity]; 17 | } 18 | 19 | public void Advance(int count) => _Index += count; 20 | 21 | public Memory GetMemory(int sizeHint = 0) 22 | { 23 | CheckAndResizeBuffer(sizeHint); 24 | return _Buffer.AsMemory(_Index); 25 | } 26 | 27 | public Span GetSpan(int sizeHint = 0) 28 | { 29 | CheckAndResizeBuffer(sizeHint); 30 | return _Buffer.AsSpan(_Index); 31 | } 32 | 33 | public void Clear() => _Index = 0; 34 | 35 | public void WriteToStream(Stream destination) => destination.Write(_Buffer, 0, _Index); 36 | 37 | private void CheckAndResizeBuffer(int sizeHint) 38 | { 39 | if (sizeHint == 0) 40 | sizeHint = MinimumBufferSize; 41 | 42 | int availableSpace = _Buffer.Length - _Index; 43 | 44 | if (sizeHint > availableSpace) 45 | { 46 | int growBy = Math.Max(sizeHint, _Buffer.Length); 47 | 48 | int newSize = checked(_Buffer.Length + growBy); 49 | 50 | Span previousBuffer = _Buffer.AsSpan(0, _Index); 51 | 52 | _Buffer = new byte[newSize]; 53 | 54 | previousBuffer.CopyTo(_Buffer); 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Code/Extensions/StandardOutputLoggerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.DependencyInjection.Extensions; 5 | using Microsoft.Extensions.Logging.Configuration; 6 | 7 | using Macross.Logging.StandardOutput; 8 | 9 | namespace Microsoft.Extensions.Logging 10 | { 11 | /// 12 | /// Contains extension methods for registering into the logging framework. 13 | /// 14 | public static class StandardOutputLoggerExtensions 15 | { 16 | /// 17 | /// Adds a stdout logger named 'Macross.stdout' to the factory. 18 | /// 19 | /// The to use. 20 | /// A delegate to configure the . 21 | /// for chaining. 22 | public static ILoggingBuilder AddStdout(this ILoggingBuilder builder, Action? configure = null) 23 | { 24 | if (builder == null) 25 | throw new ArgumentNullException(nameof(builder)); 26 | 27 | builder.AddConfiguration(); 28 | builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); 29 | 30 | LoggerProviderOptions.RegisterProviderOptions(builder.Services); 31 | 32 | if (configure != null) 33 | builder.Services.Configure(configure); 34 | 35 | return builder; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Code/NullScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Macross.Logging.StandardOutput 4 | { 5 | /// 6 | /// An empty scope without any logic. 7 | /// 8 | internal class NullScope : IDisposable 9 | { 10 | public static NullScope Instance { get; } = new NullScope(); 11 | 12 | private NullScope() 13 | { 14 | } 15 | 16 | /// 17 | public void Dispose() 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: ComVisible(false)] 7 | [assembly: CLSCompliant(false)] 8 | 9 | [assembly: Guid("70263af4-25ac-4596-be12-53dc4d5e319d")] 10 | 11 | [assembly: InternalsVisibleTo("Macross.Logging.StandardOutput.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f18113c4a5e17d17a13467a8d8aea9496b80888c79186fa4bb05627746ce50e31ea03224c4ba07ad2ae23d261739665c844ff56725c83e995e40f9a1ca61aa05577601d27fc786a2b06ecabdf00810652a86b9dab3695b70366c22e60800c0f8efeaef7fc61e43279a41b5587bea01bbe72de1350205c6f8ac06d42e3a8dd4c7")] 12 | 13 | [assembly: AssemblyVersion("2.0.0.21011")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Code/StandardOutputLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Macross.Logging.StandardOutput 6 | { 7 | internal class StandardOutputLogger : ILogger 8 | { 9 | private readonly string _CategoryName; 10 | private readonly Action _AddMessageAction; 11 | 12 | internal IExternalScopeProvider? ScopeProvider { get; set; } 13 | 14 | public StandardOutputLogger(string categoryName, Action addMessageAction) 15 | { 16 | _CategoryName = categoryName; 17 | _AddMessageAction = addMessageAction; 18 | } 19 | 20 | /// 21 | public IDisposable BeginScope(TState state) => ScopeProvider?.Push(state) ?? NullScope.Instance; 22 | 23 | /// 24 | public bool IsEnabled(LogLevel logLevel) => logLevel != LogLevel.None; 25 | 26 | /// 27 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) 28 | { 29 | if (!IsEnabled(logLevel)) 30 | return; 31 | 32 | _AddMessageAction( 33 | LoggerJsonMessage.FromLoggerData(_CategoryName, ScopeProvider, logLevel, eventId, state, exception, formatter)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Logging.StandardOutput/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Logging.StandardOutput/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 Beta 6 4 | 5 | * `AutomaticallySampleChildren` flag has been added on 6 | `ActivityTraceListenerManagerOptions` to disable automatic sampling in cases 7 | where custom sampling logic is already being used. -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityEnrichmentScope/ActionActivityEnrichmentScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Macross.OpenTelemetry.Extensions 5 | { 6 | internal sealed class ActionActivityEnrichmentScope : ActivityEnrichmentScopeBase 7 | { 8 | public Action? EnrichmentAction { get; private set; } 9 | 10 | public ActionActivityEnrichmentScope(Action enrichmentAction) 11 | { 12 | EnrichmentAction = enrichmentAction ?? throw new ArgumentNullException(nameof(enrichmentAction)); 13 | } 14 | 15 | public override void Enrich(Activity activity) 16 | => EnrichmentAction?.Invoke(activity); 17 | 18 | protected override void Dispose(bool isDisposing) 19 | { 20 | EnrichmentAction = null; 21 | 22 | base.Dispose(isDisposing); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityEnrichmentScope/ActivityEnricher.cs: -------------------------------------------------------------------------------- 1 | namespace System.Diagnostics 2 | { 3 | /// 4 | /// A callback function for enriching an using some known state. 5 | /// 6 | /// State type. 7 | /// being enriched. 8 | /// State. 9 | public delegate void ActivityEnricher(Activity activity, TState state); 10 | } 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityEnrichmentScope/ActivityEnrichmentScope.cs: -------------------------------------------------------------------------------- 1 | using Macross.OpenTelemetry.Extensions; 2 | 3 | namespace System.Diagnostics 4 | { 5 | /// 6 | /// A class for enriching the data of objects. 7 | /// 8 | public static class ActivityEnrichmentScope 9 | { 10 | /// 11 | /// Registers an action that will be called to enrich the next processed under the current scope if it has been sampled. 12 | /// 13 | /// Action to be called. 14 | /// to cancel the enrichment scope. 15 | public static IDisposable Begin(Action enrichmentAction) 16 | => new ActionActivityEnrichmentScope(enrichmentAction); 17 | 18 | /// 19 | /// Registers an that will be called to enrich the next processed under the current scope if it has been sampled. 20 | /// 21 | /// State type. 22 | /// to be called. 23 | /// The state to pass to the . 24 | /// to cancel the enrichment scope. 25 | public static IDisposable Begin(ActivityEnricher activityEnricher, TState state) 26 | => new GenericActivityEnrichmentScope(activityEnricher, state); 27 | } 28 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityEnrichmentScope/ActivityEnrichmentScopeBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | using OpenTelemetry.Context; 5 | 6 | namespace Macross.OpenTelemetry.Extensions 7 | { 8 | internal abstract class ActivityEnrichmentScopeBase : IDisposable 9 | { 10 | private static readonly RuntimeContextSlot s_RuntimeContextSlot = RuntimeContext.RegisterSlot("otel.activity_enrichment_scope"); 11 | 12 | public static ActivityEnrichmentScopeBase? Current => s_RuntimeContextSlot.Get(); 13 | 14 | private bool _Disposed; 15 | 16 | public ActivityEnrichmentScopeBase? Parent { get; private set; } 17 | 18 | public ActivityEnrichmentScopeBase? Child { get; private set; } 19 | 20 | protected ActivityEnrichmentScopeBase() 21 | { 22 | Parent = Current; 23 | if (Parent != null) 24 | { 25 | Parent.Child = this; 26 | } 27 | 28 | s_RuntimeContextSlot.Set(this); 29 | } 30 | 31 | public void Dispose() 32 | { 33 | if (!_Disposed) 34 | { 35 | Dispose(true); 36 | _Disposed = true; 37 | } 38 | } 39 | 40 | public abstract void Enrich(Activity activity); 41 | 42 | protected virtual void Dispose(bool isDisposing) 43 | { 44 | if (Parent?.Child == this) 45 | { 46 | Parent.Child = Child; 47 | } 48 | 49 | if (Child?.Parent == this) 50 | { 51 | Child.Parent = Parent; 52 | } 53 | 54 | if (s_RuntimeContextSlot.Get() == this) 55 | { 56 | s_RuntimeContextSlot.Set(Parent); 57 | } 58 | 59 | Parent = null; 60 | Child = null; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityEnrichmentScope/ActivityEnrichmentScopeProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | using OpenTelemetry; 5 | 6 | namespace Macross.OpenTelemetry.Extensions 7 | { 8 | internal sealed class ActivityEnrichmentScopeProcessor : BaseProcessor 9 | { 10 | /// 11 | public override void OnEnd(Activity activity) 12 | { 13 | ActivityEnrichmentScopeBase? scope = ActivityEnrichmentScopeBase.Current; 14 | while (scope != null) 15 | { 16 | try 17 | { 18 | scope.Enrich(activity); 19 | } 20 | #pragma warning disable CA1031 // Do not catch general exception types 21 | catch (Exception ex) 22 | #pragma warning restore CA1031 // Do not catch general exception types 23 | { 24 | OpenTelemetryExtensionsEventSource.Log.SpanProcessorException(nameof(ActivityEnrichmentScopeProcessor), ex); 25 | } 26 | 27 | scope = scope.Parent; 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityEnrichmentScope/GenericActivityEnrichmentScope{TState}.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Macross.OpenTelemetry.Extensions 5 | { 6 | internal sealed class GenericActivityEnrichmentScope : ActivityEnrichmentScopeBase 7 | { 8 | private readonly TState _State; 9 | 10 | public ActivityEnricher? ActivityEnricher { get; private set; } 11 | 12 | public GenericActivityEnrichmentScope(ActivityEnricher activityEnricher, TState state) 13 | { 14 | ActivityEnricher = activityEnricher ?? throw new ArgumentNullException(nameof(activityEnricher)); 15 | _State = state; 16 | } 17 | 18 | public override void Enrich(Activity activity) 19 | => ActivityEnricher?.Invoke(activity, _State); 20 | 21 | protected override void Dispose(bool isDisposing) 22 | { 23 | ActivityEnricher = null; 24 | 25 | base.Dispose(isDisposing); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityTraceListenerManagerOptions.cs: -------------------------------------------------------------------------------- 1 | namespace System.Diagnostics 2 | { 3 | /// 4 | /// Stores options for the class. 5 | /// 6 | public class ActivityTraceListenerManagerOptions 7 | { 8 | /// 9 | /// Gets the default cleanup interval in milliseconds. 10 | /// 11 | public const int DefaultCleanupIntervalInMilliseconds = 20 * 60 * 1000; // 20 minutes 12 | 13 | /// 14 | /// Gets or sets the cleanup interval in milliseconds. Default value: . 15 | /// 16 | /// 17 | /// The is automatically closed when inactive to save on resources. 18 | /// 19 | public int? CleanupIntervalInMilliseconds { get; set; } 20 | 21 | /// 22 | /// Gets or sets the callback action invoked when the is opened due to a listener being registered. 23 | /// 24 | public Action? OpenedAction { get; set; } 25 | 26 | /// 27 | /// Gets or sets the callback action invoked when the is closed due to inactivity. 28 | /// 29 | public Action? ClosedAction { get; set; } 30 | 31 | /// 32 | /// Gets or sets the callback action invoked when options are configured. 33 | /// 34 | public Action? ConfiguredAction { get; set; } 35 | 36 | /// 37 | /// Gets or sets a value indicating whether or not child objects created under a trace with a registered 39 | /// listener should automatically be sampled. Default value: True. 40 | /// 41 | public bool AutomaticallySampleChildren { get; set; } = true; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/ActivityTraceListenerSampler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | using OpenTelemetry.Trace; 5 | 6 | namespace Macross.OpenTelemetry.Extensions 7 | { 8 | internal sealed class ActivityTraceListenerSampler : Sampler 9 | { 10 | private readonly Sampler _InnerSampler; 11 | 12 | internal ActivityTraceListenerManager? ActivityTraceListenerManager { get; set; } 13 | 14 | public ActivityTraceListenerSampler(Sampler innerSampler) 15 | { 16 | _InnerSampler = innerSampler ?? throw new ArgumentNullException(nameof(innerSampler)); 17 | } 18 | 19 | public override SamplingResult ShouldSample(in SamplingParameters samplingParameters) 20 | { 21 | ActivityTraceListenerManager? activityTraceListenerManager = ActivityTraceListenerManager; 22 | return activityTraceListenerManager != null 23 | && activityTraceListenerManager.IsTraceIdRegistered(samplingParameters.TraceId) 24 | ? new SamplingResult(SamplingDecision.RecordAndSample) 25 | : _InnerSampler.ShouldSample(samplingParameters); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/Extensions/OpenTelemetryServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Diagnostics.Tracing; 4 | 5 | using Macross.OpenTelemetry.Extensions; 6 | 7 | namespace Microsoft.Extensions.DependencyInjection 8 | { 9 | /// 10 | /// Class for exposing configuration extensions. 11 | /// 12 | public static class OpenTelemetryServiceCollectionExtensions 13 | { 14 | /// 15 | /// Add OpenTelemetry event logging to an application's startup configuration. 16 | /// 17 | /// Application being configured. 18 | /// Optional callback for configuring at runtime. 19 | /// Supplied for chaining. 20 | public static IServiceCollection AddOpenTelemetryEventLogging( 21 | this IServiceCollection services, 22 | Action? configure = null) 23 | { 24 | if (configure != null) 25 | services.Configure(configure); 26 | 27 | return services.AddHostedService(); 28 | } 29 | 30 | /// 31 | /// Add to an application's startup configuration. 32 | /// 33 | /// Application being configured. 34 | /// Optional callback for configuring at runtime. 35 | /// Supplied for chaining. 36 | public static IServiceCollection AddActivityTraceListener( 37 | this IServiceCollection services, 38 | Action? configure = null) 39 | { 40 | if (configure != null) 41 | services.Configure(configure); 42 | 43 | return services.AddSingleton(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/Extensions/TracerProviderBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | using Macross.OpenTelemetry.Extensions; 4 | 5 | namespace OpenTelemetry.Trace 6 | { 7 | /// 8 | /// Contains extension methods for the class. 9 | /// 10 | public static class TracerProviderBuilderExtensions 11 | { 12 | /// 13 | /// Adds a which will enrich objects created while inside an . 14 | /// 15 | /// . 16 | /// Returns the supplied for chaining. 17 | public static TracerProviderBuilder AddActivityEnrichmentScopeProcessor(this TracerProviderBuilder tracerProviderBuilder) 18 | #pragma warning disable CA2000 // Dispose objects before losing scope 19 | => tracerProviderBuilder.AddProcessor(new ActivityEnrichmentScopeProcessor()); 20 | #pragma warning restore CA2000 // Dispose objects before losing scope 21 | 22 | /// 23 | /// Adds a which will automatically sample any span under a traceId registered through . 24 | /// 25 | /// . 26 | /// . 27 | /// Returns the supplied for chaining. 28 | public static TracerProviderBuilder SetActivityTraceListenerSampler(this TracerProviderBuilder tracerProviderBuilder, Sampler innerSampler) 29 | => tracerProviderBuilder.SetSampler(new ActivityTraceListenerSampler(innerSampler)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/IActivityTraceListener.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace System.Diagnostics 4 | { 5 | /// 6 | /// An interface for capturing completed objects created under a specific . 7 | /// 8 | /// 9 | /// Note: Call to stop listening. 10 | /// 11 | public interface IActivityTraceListener : IDisposable 12 | { 13 | /// 14 | /// Gets the completed objects. 15 | /// 16 | IReadOnlyList CompletedActivities { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/Macross.OpenTelemetry.Extensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0;netstandard2.1 5 | True 6 | keypair.snk 7 | 8 | Macross OpenTelemetry .NET extensions library. 9 | 10 | Provides extensions and utilities for OpenTelemetry .NET. 11 | 12 | Commonly Used Types: 13 | System.Diagnostics.ActivityTraceListenerManager 14 | System.Diagnostics.ActivityEnrichmentScope 15 | 16 | Commonly Used Extensions: 17 | IServiceCollection.AddOpenTelemetryEventLogging 18 | IServiceCollection.AddActivityTraceListener 19 | TracerProviderBuilder.AddActivityEnrichmentScopeProcessor 20 | TracerProviderBuilder.SetActivityTraceListenerSampler 21 | 22 | Macross.OpenTelemetry.Extensions 23 | true 24 | false 25 | false 26 | 1.0.0 27 | beta6 28 | $(VersionPrefix) 29 | https://github.com/Macross-Software/core/tree/develop/ClassLibraries/Macross.OpenTelemetry.Extensions 30 | 31 | 32 | 33 | $(VersionPrefix) 34 | 35 | 36 | $(VersionPrefix)-$(VersionSuffix) 37 | 38 | 39 | 40 | ..\..\..\_build\DLLs\$(Configuration)\ 41 | ..\..\..\_build\DLLs\$(Configuration)\Macross.OpenTelemetry.Extensions.xml 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/OpenTelemetryEventLogAction.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace System.Diagnostics.Tracing 4 | { 5 | /// 6 | /// Callback action for writing OpenTelemetry events to an instance. 7 | /// 8 | /// . 9 | /// . 10 | /// . 11 | public delegate void OpenTelemetryEventLogAction(ILogger logger, LogLevel logLevel, EventWrittenEventArgs openTelemetryEvent); 12 | } 13 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/OpenTelemetryEventLoggingHostedService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.Tracing; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | using Microsoft.Extensions.Hosting; 7 | using Microsoft.Extensions.Logging; 8 | using Microsoft.Extensions.Options; 9 | 10 | namespace Macross.OpenTelemetry.Extensions 11 | { 12 | #pragma warning disable CA1812 // Remove class never instantiated 13 | internal sealed class OpenTelemetryEventLoggingHostedService : IHostedService, IDisposable 14 | #pragma warning restore CA1812 // Remove class never instantiated 15 | { 16 | private readonly OpenTelemetryEventListener _OpenTelemetryEventListener; 17 | 18 | public OpenTelemetryEventLoggingHostedService( 19 | ILoggerFactory loggerFactory, 20 | IOptionsMonitor options) 21 | { 22 | if (loggerFactory == null) 23 | throw new ArgumentNullException(nameof(loggerFactory)); 24 | 25 | _OpenTelemetryEventListener = new OpenTelemetryEventListener( 26 | loggerFactory.CreateLogger(), 27 | options); 28 | } 29 | 30 | public Task StartAsync(CancellationToken cancellationToken) 31 | => Task.CompletedTask; 32 | 33 | public Task StopAsync(CancellationToken cancellationToken) 34 | => Task.CompletedTask; 35 | 36 | public void Dispose() 37 | => _OpenTelemetryEventListener.Dispose(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/OpenTelemetryEventLoggingOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace System.Diagnostics.Tracing 6 | { 7 | /// 8 | /// Stores options for controlling OpenTelemetry event logging. 9 | /// 10 | public class OpenTelemetryEventLoggingOptions 11 | { 12 | /// 13 | /// Gets the default event source options. 14 | /// 15 | internal static IReadOnlyCollection DefaultEventSources { get; } = new[] 16 | { 17 | new OpenTelemetryEventLoggingSourceOptions 18 | { 19 | EventSourceRegExExpression = "^OpenTelemetry.*$", 20 | } 21 | }; 22 | 23 | /// 24 | /// Gets or sets the options used to select the event sources for the listener. 25 | /// 26 | /// 27 | /// By default the ^OpenTelemetry.*$ regular expression is used at the level or lower (more severe). 28 | /// 29 | public IReadOnlyCollection? EventSources { get; set; } 30 | 31 | /// 32 | /// Gets or sets the callback action used to write OpenTelemetry events to an instance. 33 | /// 34 | public OpenTelemetryEventLogAction LogAction { get; set; } = (logger, logLevel, openTelemetryEvent) 35 | => logger.Log( 36 | logLevel, 37 | openTelemetryEvent.EventId, 38 | "[{EventName}] {Message} {{{Payload}}}", 39 | openTelemetryEvent.EventName, 40 | openTelemetryEvent.Message, 41 | openTelemetryEvent.Payload); 42 | 43 | /// 44 | /// Gets or sets the callback action invoked when options are configured. 45 | /// 46 | public Action? ConfiguredAction { get; set; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/OpenTelemetryEventLoggingSourceOptions.cs: -------------------------------------------------------------------------------- 1 | namespace System.Diagnostics.Tracing 2 | { 3 | /// 4 | /// Stores options for controlling OpenTelemetry event logging for an individual event source. 5 | /// 6 | public class OpenTelemetryEventLoggingSourceOptions 7 | { 8 | /// 9 | /// Gets or sets the regular expression which will be applied to the event source name. 10 | /// 11 | public string? EventSourceRegExExpression { get; set; } 12 | 13 | /// 14 | /// Gets or sets the maximum event level to capture. All events lower (more severe) will also be captured. 15 | /// 16 | public EventLevel EventLevel { get; set; } = EventLevel.Warning; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/OpenTelemetryExtensionsEventSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.Tracing; 3 | using System.Globalization; 4 | using System.Threading; 5 | 6 | namespace Macross.OpenTelemetry.Extensions 7 | { 8 | /// 9 | /// EventSource implementation for OpenTelemetry extensions. 10 | /// 11 | [EventSource(Name = "OpenTelemetry-Extensions")] 12 | internal sealed class OpenTelemetryExtensionsEventSource : EventSource 13 | { 14 | public static OpenTelemetryExtensionsEventSource Log { get; } = new OpenTelemetryExtensionsEventSource(); 15 | 16 | [NonEvent] 17 | public void SpanProcessorException(string evnt, Exception ex) 18 | { 19 | if (IsEnabled(EventLevel.Error, (EventKeywords)(-1))) 20 | { 21 | SpanProcessorException(evnt, ToInvariantString(ex)); 22 | } 23 | } 24 | 25 | [Event(1, Message = "Unknown error in SpanProcessor event '{0}': '{1}'.", Level = EventLevel.Error)] 26 | public void SpanProcessorException(string evnt, string ex) 27 | => WriteEvent(1, evnt, ex); 28 | 29 | private static string ToInvariantString(Exception exception) 30 | { 31 | CultureInfo originalUICulture = Thread.CurrentThread.CurrentUICulture; 32 | 33 | try 34 | { 35 | Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; 36 | return exception.ToString(); 37 | } 38 | finally 39 | { 40 | Thread.CurrentThread.CurrentUICulture = originalUICulture; 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: ComVisible(false)] 7 | [assembly: CLSCompliant(false)] 8 | 9 | [assembly: Guid("645b7e05-af18-448d-9040-e3bdb6b04c4f")] 10 | 11 | [assembly: InternalsVisibleTo("Macross.OpenTelemetry.Extensions.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1a4dad5605af5f97a39e67571c3a03a6762442db77512795feb38f00db953d7ec222951dd58cd511610c902b73577beb10f1bc868b539a3d1593ae2037524dbb116e7f137a3bfc8d0c9ad7c2e6ea5bb68a86b5fed17516d6678fd9b899e371a14ea4daca38722b8ca030480c69a418b92f5704b1e2a925e213ef9039b2420e7")] 12 | 13 | [assembly: AssemblyVersion("1.0.0.21306")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.OpenTelemetry.Extensions/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Test/Macross.OpenTelemetry.Extensions.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1;netcoreapp3.1;net5.0 5 | true 6 | keypair.snk 7 | Macross Software OpenTelemetry extensions library tests. 8 | Macross.OpenTelemetry.Extensions.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("beb815de-41a4-4cfe-80eb-a5a1d64559c5")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.21306")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.OpenTelemetry.Extensions/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.OpenTelemetry.Extensions/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Benchmarks/PerformanceBenchmarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0;netcoreapp3.1;netcoreapp2.1;net48 6 | true 7 | false 8 | false 9 | false 10 | false 11 | true 12 | keypair.snk 13 | false 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Benchmarks/PoolBackedCollectionBenchmarks.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using BenchmarkDotNet.Attributes; 5 | 6 | namespace PerformanceBenchmarks 7 | { 8 | [MinIterationTime(8000)] 9 | [MemoryDiagnoser] 10 | #if !NETFRAMEWORK 11 | [ThreadingDiagnoser] 12 | #endif 13 | public class PoolBackedCollectionBenchmarks 14 | { 15 | [Params(500)] 16 | public int NumberOfLists { get; set; } 17 | 18 | [Params(1000)] 19 | public int NumberOfItems { get; set; } 20 | 21 | [Benchmark] 22 | public void TraditionalListAllocation() 23 | { 24 | for (int i = 0; i < NumberOfLists; i++) 25 | { 26 | List items = new List(64); 27 | 28 | for (int c = 0; c < NumberOfItems; c++) 29 | { 30 | items.Add(c); 31 | } 32 | 33 | foreach (int c in items) 34 | { 35 | if (items[c] != c) 36 | throw new InvalidOperationException(); 37 | } 38 | 39 | items.Clear(); 40 | } 41 | } 42 | 43 | [Benchmark] 44 | public void PoolBackedCollectionAllocation() 45 | { 46 | for (int i = 0; i < NumberOfLists; i++) 47 | { 48 | using PoolBackedCollection items = new PoolBackedCollection(64); 49 | 50 | for (int c = 0; c < NumberOfItems; c++) 51 | { 52 | items.Add(c); 53 | } 54 | 55 | foreach (int c in items) 56 | { 57 | if (items[c] != c) 58 | throw new InvalidOperationException(); 59 | } 60 | 61 | items.Clear(); 62 | } 63 | } 64 | 65 | [Benchmark] 66 | public void StructPoolBackedCollectionAllocation() 67 | { 68 | for (int i = 0; i < NumberOfLists; i++) 69 | { 70 | StructPoolBackedCollection items = new StructPoolBackedCollection(64); 71 | 72 | for (int c = 0; c < NumberOfItems; c++) 73 | { 74 | items = items.Add(c); 75 | } 76 | 77 | foreach (int c in items) 78 | { 79 | if (items[c] != c) 80 | throw new InvalidOperationException(); 81 | } 82 | 83 | items = items.Clear(); 84 | 85 | items.Return(); 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Benchmarks/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | 3 | namespace PerformanceBenchmarks 4 | { 5 | internal static class Program 6 | { 7 | public static void Main(string[] args) 8 | => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Benchmarks/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("b9c8372c-fd10-447b-a7db-a62a74b48434")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20194")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Benchmarks/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:50524", 8 | "sslPort": 44300 9 | } 10 | }, 11 | "profiles": { 12 | "WebApplication1": { 13 | "commandName": "Project", 14 | "launchBrowser": false, 15 | "launchUrl": "weatherforecast", 16 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Benchmarks/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Performance.Extensions/Benchmarks/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Code/Macross.Performance.Extensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;netstandard2.0 5 | true 6 | keypair.snk 7 | 8 | Macross Software performance extensions library. 9 | 10 | A collection of types and utilities for writing high performance .NET applications. 11 | 12 | Commonly Used Types: 13 | System.Collections.Generic.DictionaryStructEnumerator 14 | System.Collections.Generic.ListStructEnumerator 15 | 16 | Macross.Performance.Extensions 17 | true 18 | false 19 | false 20 | 0.0.1 21 | alpha1 22 | $(VersionPrefix) 23 | https://github.com/Macross-Software/core/tree/develop/ClassLibraries/Macross.Performance.Extensions 24 | 25 | 26 | 27 | $(VersionPrefix) 28 | 29 | 30 | $(VersionPrefix)-$(VersionSuffix) 31 | 32 | 33 | 34 | ..\..\..\_build\DLLs\$(Configuration)\ 35 | ..\..\..\_build\DLLs\$(Configuration)\Macross.Performance.Extensions.xml 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("4f5d8ace-4162-4655-9055-d237e86a8dbd")] 9 | 10 | [assembly: AssemblyVersion("0.0.1.21011")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Performance.Extensions/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/README.md: -------------------------------------------------------------------------------- 1 | # Macross Software Performance Extensions 2 | 3 | Macross.Performance.Extensions is a .NET Standard 2.0+ library for augmenting what is provided out of the box for developing high peformance applications. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Test/Macross.Performance.Extensions.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1;net5.0 5 | true 6 | keypair.snk 7 | Macross Software performance extensions library tests. 8 | Macross.Performance.Extensions.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("9ce7c797-980c-46d2-9a18-91bf76ed7cc4")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20194")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Performance.Extensions/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Performance.Extensions/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/DefaultTypedSoapClientFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace System.ServiceModel 6 | { 7 | #pragma warning disable CA1812 // Remove class never instantiated 8 | internal class DefaultTypedSoapClientFactory : ITypedSoapClientFactory 9 | #pragma warning restore CA1812 // Remove class never instantiated 10 | { 11 | private static readonly Func s_CreateActivator = () => ActivatorUtilities.CreateFactory(typeof(TImplementation), new Type[] { typeof(SoapClient) }); 12 | 13 | private readonly IServiceProvider _ServiceProvider; 14 | private ObjectFactory? _Activator; 15 | private bool _Initialized; 16 | private object? _Lock; 17 | 18 | public ObjectFactory Activator => LazyInitializer.EnsureInitialized( 19 | ref _Activator, 20 | ref _Initialized, 21 | ref _Lock, 22 | s_CreateActivator)!; 23 | 24 | public DefaultTypedSoapClientFactory(IServiceProvider serviceProvider) 25 | { 26 | _ServiceProvider = serviceProvider; 27 | } 28 | 29 | public TImplementation CreateClient(SoapClient soapClient) 30 | => (TImplementation)Activator(_ServiceProvider, new object[] { soapClient }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/DependencyInjection/DefaultSoapClientBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Extensions.DependencyInjection 2 | { 3 | internal class DefaultSoapClientBuilder : ISoapClientBuilder 4 | { 5 | public IServiceCollection Services { get; } 6 | 7 | public string Name { get; } 8 | 9 | public DefaultSoapClientBuilder(IServiceCollection services, string name) 10 | { 11 | Services = services; 12 | Name = name; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/DependencyInjection/ISoapClientBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.ServiceModel; 2 | 3 | namespace Microsoft.Extensions.DependencyInjection 4 | { 5 | /// 6 | /// A builder for configuring named instances returned by . 7 | /// 8 | public interface ISoapClientBuilder 9 | { 10 | /// 11 | /// Gets the application service collection. 12 | /// 13 | IServiceCollection Services { get; } 14 | 15 | /// 16 | /// Gets the name of the client configured by this builder. 17 | /// 18 | string Name { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/ISoapClientFactory.cs: -------------------------------------------------------------------------------- 1 | namespace System.ServiceModel 2 | { 3 | /// 4 | /// A factory abstraction for a component that creates instances with custom 5 | /// configuration for a given logical name. 6 | /// 7 | public interface ISoapClientFactory 8 | { 9 | /// 10 | /// Creates and configures a instance using the configuration that corresponds 11 | /// to the logical name. 12 | /// 13 | /// The type of channel. 14 | /// The created . 15 | SoapClient GetSoapClient(); 16 | 17 | /// 18 | /// Expire the cached instance if one has been created. 19 | /// 20 | /// The type of channel. 21 | /// Typically called after configuration changes. A new instance will be created on the next request. 22 | void Invalidate(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/ITypedSoapClientFactory.cs: -------------------------------------------------------------------------------- 1 | namespace System.ServiceModel 2 | { 3 | /// 4 | /// A factory abstraction for a component that can create typed client instances with custom 5 | /// configuration for a given logical name. 6 | /// 7 | /// The type of channel. 8 | /// The type of typed client to create. 9 | public interface ITypedSoapClientFactory 10 | { 11 | /// 12 | /// Creates an instance of using the supplied . 13 | /// 14 | /// . 15 | /// Created instance. 16 | TImplementation CreateClient(SoapClient soapClient); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/Macross.ServiceModel.Extensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;netstandard2.0 5 | true 6 | keypair.snk 7 | 8 | Macross Software System.ServiceModel extensions library. 9 | 10 | Provides extensions for the System.ServiceModel API. 11 | 12 | Commonly Used Types: 13 | System.ServiceModel.SoapClient<TChannel> 14 | 15 | Commonly Used Extensions: 16 | Microsoft.Extensions.DependencyInjection.AddSoapClient<TChannel, TImplementation> 17 | 18 | Macross.ServiceModel.Extensions 19 | true 20 | false 21 | false 22 | 1.0.1 23 | 24 | $(VersionPrefix) 25 | https://github.com/Macross-Software/core/tree/develop/ClassLibraries/Macross.ServiceModel.Extensions 26 | 27 | 28 | 29 | $(VersionPrefix) 30 | 31 | 32 | $(VersionPrefix)-$(VersionSuffix) 33 | 34 | 35 | 36 | ..\..\..\_build\DLLs\$(Configuration)\ 37 | ..\..\..\_build\DLLs\$(Configuration)\Macross.ServiceModel.Extensions.xml 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("002756ec-091a-4a65-8533-d407b31d7166")] 9 | 10 | [assembly: AssemblyVersion("1.0.1.20098")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/SoapClientFactoryOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace System.ServiceModel 4 | { 5 | #pragma warning disable CA1812 // Remove class never instantiated 6 | internal class SoapClientFactoryOptions 7 | #pragma warning restore CA1812 // Remove class never instantiated 8 | { 9 | public Func? CreateChannelFactory { get; set; } 10 | 11 | public IList> ChannelFactoryConfigurationActions { get; } = new List>(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/SoapClient{TChannel}.cs: -------------------------------------------------------------------------------- 1 | using System.ServiceModel.Description; 2 | 3 | namespace System.ServiceModel 4 | { 5 | /// 6 | /// Provides a class for calling a SOAP service. 7 | /// 8 | /// The channel for the client. 9 | public class SoapClient : SoapClient 10 | { 11 | /// Gets the inner channel used to send messages to variously configured service endpoints. 12 | public TChannel Channel { get; } 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// . 18 | /// instance. 19 | public SoapClient(ServiceEndpoint endpoint, TChannel channel) 20 | : base(endpoint, EnsureCommunicationObject(channel)) 21 | { 22 | Channel = channel ?? throw new ArgumentNullException(nameof(channel)); 23 | } 24 | 25 | private static ICommunicationObject EnsureCommunicationObject(TChannel channel) 26 | { 27 | if (channel is ICommunicationObject CommunicationObject) 28 | return CommunicationObject; 29 | 30 | if (channel == null) 31 | throw new ArgumentNullException(nameof(channel)); 32 | 33 | throw new InvalidOperationException($"Channel of Type '{typeof(TChannel).FullName}' is invalid."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.ServiceModel.Extensions/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Test/Macross.ServiceModel.Extensions.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1;net5.0 5 | true 6 | keypair.snk 7 | Macross Software System.ServiceModel extensions library tests. 8 | Macross.ServiceModel.Extensions.Tests 9 | true 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | ..\..\..\_build\Tests\$(Configuration)\ 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("dc042124-75bf-4b79-959b-1c78bf39e245")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20025")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.ServiceModel.Extensions/Test/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.ServiceModel.Extensions/Test/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2.0.0 4 | 5 | * `DebugWindow` is registered earlier during application startup to capture & 6 | display log messages written in `static Main` method. 7 | 8 | * Updated for new 9 | [Macross.Logging.Abstractions](../Macross.Logging.Abstractions/README.md) API. 10 | 11 | * Added net5.0-windows target. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/DebugWindowConfigureAction.cs: -------------------------------------------------------------------------------- 1 | namespace Macross.Windows.Debugging 2 | { 3 | /// 4 | /// A delegate for configuring created at runtime. 5 | /// 6 | /// being created. 7 | public delegate void DebugWindowConfigureAction(DebugWindow debugWindow); 8 | } 9 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/DebugWindowConfigureTabAction.cs: -------------------------------------------------------------------------------- 1 | namespace Macross.Windows.Debugging 2 | { 3 | /// 4 | /// A delegate for configuring s as they are added to the launched . 5 | /// 6 | /// being created. 7 | public delegate void DebugWindowConfigureTabAction(DebugWindowTabPage debugWindowTab); 8 | } 9 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/DebugWindowFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Hosting; 2 | using Microsoft.Extensions.Options; 3 | 4 | namespace Macross.Windows.Debugging 5 | { 6 | /// 7 | /// A factory class for constructing instances at runtime. 8 | /// 9 | /// 10 | /// This class exists mostly for performance so instances are not created unless options dicticate and pre-conditions are satisfied. 11 | /// 12 | public class DebugWindowFactory 13 | { 14 | private readonly IHostEnvironment _HostEnvironment; 15 | private readonly DebugWindowMessageManager _MessageManager; 16 | private readonly IOptionsMonitor _Options; 17 | private readonly DebugWindowConfigureAction? _ConfigureAction; 18 | private readonly DebugWindowConfigureTabAction? _ConfigureTabAction; 19 | 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | /// . 24 | /// . 25 | /// . 26 | /// . 27 | /// . 28 | public DebugWindowFactory( 29 | IHostEnvironment hostEnvironment, 30 | DebugWindowMessageManager messageManager, 31 | IOptionsMonitor options, 32 | DebugWindowConfigureAction? configureAction = null, 33 | DebugWindowConfigureTabAction? configureTabAction = null) 34 | { 35 | _HostEnvironment = hostEnvironment; 36 | _MessageManager = messageManager; 37 | _Options = options; 38 | 39 | _ConfigureAction = configureAction; 40 | _ConfigureTabAction = configureTabAction; 41 | } 42 | 43 | /// 44 | /// Create a instance. 45 | /// 46 | /// Created . 47 | public DebugWindow Create() => new DebugWindow(_HostEnvironment, _MessageManager, _Options, _ConfigureAction, _ConfigureTabAction); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/DebugWindowLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Extensions.Logging; 4 | 5 | using Macross.Logging; 6 | 7 | namespace Macross.Windows.Debugging 8 | { 9 | internal class DebugWindowLogger : ILogger 10 | { 11 | private readonly string _CategoryName; 12 | private readonly DebugWindowMessageManager _MessageManager; 13 | 14 | internal IExternalScopeProvider? ScopeProvider { get; set; } 15 | 16 | public DebugWindowLogger(string categoryName, DebugWindowMessageManager messageManager) 17 | { 18 | _CategoryName = categoryName; 19 | _MessageManager = messageManager; 20 | } 21 | 22 | /// 23 | public IDisposable BeginScope(TState state) => ScopeProvider?.Push(state) ?? NullScope.Instance; 24 | 25 | /// 26 | public bool IsEnabled(LogLevel logLevel) => logLevel != LogLevel.None; 27 | 28 | /// 29 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) 30 | { 31 | if (!IsEnabled(logLevel)) 32 | return; 33 | 34 | _MessageManager.AddMessage( 35 | LoggerJsonMessage.FromLoggerData(_CategoryName, ScopeProvider, logLevel, eventId, state, exception, formatter)); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/DebugWindowLoggerProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | using System.Collections.Generic; 3 | 4 | using Microsoft.Extensions.Logging; 5 | 6 | namespace Macross.Windows.Debugging 7 | { 8 | [ProviderAlias("DebugWindow")] 9 | #pragma warning disable CA1812 // Remove class never instantiated 10 | internal class DebugWindowLoggerProvider : ILoggerProvider, ISupportExternalScope 11 | #pragma warning restore CA1812 // Remove class never instantiated 12 | { 13 | private readonly ConcurrentDictionary _Loggers = new ConcurrentDictionary(); 14 | private readonly DebugWindowMessageManager _MessageManager; 15 | private IExternalScopeProvider? _ScopeProvider; 16 | 17 | public DebugWindowLoggerProvider(DebugWindowMessageManager messageManager) 18 | { 19 | _MessageManager = messageManager; 20 | } 21 | 22 | /// 23 | public void Dispose() 24 | { 25 | } 26 | 27 | /// 28 | public ILogger CreateLogger(string categoryName) 29 | { 30 | return _Loggers.GetOrAdd( 31 | categoryName, 32 | _ => new DebugWindowLogger(categoryName, _MessageManager) 33 | { 34 | ScopeProvider = _ScopeProvider 35 | }); 36 | } 37 | 38 | /// 39 | public void SetScopeProvider(IExternalScopeProvider scopeProvider) 40 | { 41 | _ScopeProvider = scopeProvider; 42 | 43 | foreach (KeyValuePair Logger in _Loggers) 44 | { 45 | Logger.Value.ScopeProvider = _ScopeProvider; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/DebugWindowMessageManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Channels; 4 | using System.Threading.Tasks; 5 | 6 | using Macross.Logging; 7 | 8 | namespace Macross.Windows.Debugging 9 | { 10 | /// 11 | /// A class for coordinating messages being written by the hosting application and consumed for display by the . 12 | /// 13 | public class DebugWindowMessageManager 14 | { 15 | internal Channel Messages { get; } = Channel.CreateUnbounded(); 16 | 17 | /// 18 | /// Adds a message to be displayed. 19 | /// 20 | /// . 21 | /// Optional . 22 | public void AddMessage(LoggerJsonMessage message, CancellationToken token = default) 23 | { 24 | ChannelWriter Writer = Messages.Writer; 25 | 26 | while (true) 27 | { 28 | ValueTask Task = Writer.WaitToWriteAsync(token); 29 | if (!(Task.IsCompleted ? Task.Result : Task.AsTask().GetAwaiter().GetResult())) 30 | break; 31 | 32 | if (Writer.TryWrite(message)) 33 | return; 34 | } 35 | 36 | throw new InvalidOperationException("MessageManager has closed."); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Windows.Forms; 4 | 5 | namespace Macross.Windows.Debugging 6 | { 7 | internal static class NativeMethods 8 | { 9 | public const int ATTACH_PARENT_PROCESS = -1; 10 | public const int ERROR_ACCESS_DENIED = 5; 11 | public const int ERROR_INVALID_HANDLE = 6; 12 | 13 | public const uint WM_HSCROLL = 0x0114; 14 | public const uint WM_VSCROLL = 0x115; 15 | public const int WM_SETREDRAW = 11; 16 | public const uint SB_BOTTOM = 7; 17 | public const int SW_HIDE = 0; 18 | public const int SW_SHOW = 5; 19 | 20 | [DllImport("kernel32.dll", SetLastError = true)] 21 | [return: MarshalAs(UnmanagedType.Bool)] 22 | public static extern bool AttachConsole(int dwProcessId); 23 | 24 | [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] 25 | [return: MarshalAs(UnmanagedType.Bool)] 26 | public static extern bool FreeConsole(); 27 | 28 | [DllImport("kernel32.dll")] 29 | public static extern IntPtr GetConsoleWindow(); 30 | 31 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 32 | public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam); 33 | 34 | [DllImport("user32.dll")] 35 | public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); 36 | 37 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 38 | public static extern int GetScrollPos(IntPtr hWnd, Orientation nBar); 39 | 40 | [DllImport("user32.dll")] 41 | public static extern int SetScrollPos(IntPtr hWnd, Orientation nBar, int nPos, bool bRedraw); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/NullScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Macross.Windows.Debugging 4 | { 5 | /// 6 | /// An empty scope without any logic. 7 | /// 8 | internal class NullScope : IDisposable 9 | { 10 | public static NullScope Instance { get; } = new NullScope(); 11 | 12 | private NullScope() 13 | { 14 | } 15 | 16 | /// 17 | public void Dispose() 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("7936396a-8e58-47ba-835a-1b2ec7369ede")] 9 | 10 | [assembly: AssemblyVersion("2.0.0.21019")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Windows.Debugging/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace DemoWebApplication.Controllers 9 | { 10 | [Route("api/[controller]")] 11 | [ApiController] 12 | public class WeatherForecastController : ControllerBase 13 | { 14 | private readonly ILogger _Logger; 15 | private readonly IWeatherService _WeatherService; 16 | 17 | public WeatherForecastController(ILogger logger, IWeatherService weatherService) 18 | { 19 | _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); 20 | _WeatherService = weatherService ?? throw new ArgumentNullException(nameof(weatherService)); 21 | } 22 | 23 | [HttpGet] 24 | public async Task GetWeatherForecast(int postalCode) 25 | { 26 | _Logger.WriteInfo( 27 | new 28 | { 29 | PostalCode = postalCode 30 | }, 31 | "START"); 32 | 33 | WeatherForecast? WeatherForecast = await _WeatherService.GetWeatherForecase(postalCode).ConfigureAwait(false); 34 | 35 | _Logger.WriteInfo( 36 | new 37 | { 38 | Success = WeatherForecast != null 39 | }, 40 | "END"); 41 | 42 | if (WeatherForecast == null) 43 | throw new InvalidOperationException("Invalid postalCode provided."); 44 | 45 | return WeatherForecast; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/DemoWebApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | false 7 | false 8 | false 9 | 10 | 11 | 12 | net5.0-windows 13 | WINDOWS 14 | 15 | 16 | 17 | net5.0 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/IWeatherService.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace DemoWebApplication 4 | { 5 | public interface IWeatherService 6 | { 7 | Task GetWeatherForecase(int postalCode); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/MessageSpamBackgroundService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | using Microsoft.Extensions.Hosting; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace DemoWebApplication 9 | { 10 | public class MessageSpamBackgroundService : BackgroundService 11 | { 12 | private readonly ILogger _Log; 13 | 14 | public MessageSpamBackgroundService(ILogger logger) 15 | { 16 | _Log = logger ?? throw new ArgumentNullException(nameof(logger)); 17 | 18 | _Log.LogInformation("MessageSpamBackgroundService created."); 19 | } 20 | 21 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 22 | { 23 | using IDisposable Group = _Log.BeginGroup(nameof(MessageSpamBackgroundService)); 24 | 25 | int MessageIndex = 0; 26 | 27 | while (!stoppingToken.IsCancellationRequested) 28 | { 29 | if (MessageIndex % 7 == 0) 30 | _Log.LogInformation("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 31 | else if (MessageIndex % 10 == 0) 32 | _Log.LogWarning("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 33 | else 34 | _Log.LogDebug("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 35 | 36 | await Task.Delay(100, stoppingToken).ConfigureAwait(false); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 | Error. 8 | An error occurred while processing your request. 9 | 10 | @if (Model.ShowRequestId) 11 | { 12 | 13 | Request ID: @Model.RequestId 14 | 15 | } 16 | 17 | Development Mode 18 | 19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 | 21 | 22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 | 27 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | 4 | using Microsoft.Extensions.Logging; 5 | 6 | namespace DemoWebApplication.Pages 7 | { 8 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _Logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _Logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | _Logger.WriteInfo("START"); 25 | 26 | RequestId = HttpContext.TraceIdentifier; 27 | 28 | _Logger.WriteInfo( 29 | new 30 | { 31 | RequestId 32 | }, 33 | "END"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "Home page"; 5 | } 6 | 7 | 8 | Welcome 9 | Learn about building Web apps with ASP.NET Core. 10 | 11 | 12 | 13 | 14 | @section scripts{ 15 | 23 | } -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.AspNetCore.Mvc.RazorPages; 6 | 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace DemoWebApplication.Pages 10 | { 11 | public class IndexModel : PageModel 12 | { 13 | private readonly IWeatherService _WeatherService; 14 | private readonly ILogger _Logger; 15 | 16 | public int? PostalCode { get; set; } 17 | 18 | public IndexModel(IWeatherService weatherService, ILogger logger) 19 | { 20 | _WeatherService = weatherService; 21 | _Logger = logger; 22 | } 23 | 24 | public IActionResult OnGet(int? postalCode) 25 | { 26 | _Logger.WriteInfo( 27 | new 28 | { 29 | PostalCode = postalCode 30 | }, 31 | "START"); 32 | 33 | if (postalCode == 1) 34 | throw new InvalidOperationException("PostalCode 1 throws an exception."); 35 | 36 | if (postalCode < 10000) 37 | return BadRequest(); 38 | 39 | PostalCode = postalCode ?? 90210; 40 | 41 | return Page(); 42 | } 43 | 44 | public async Task OnGetWeatherServiceDetails(int postalCode) 45 | { 46 | _Logger.WriteInfo( 47 | new 48 | { 49 | PostalCode = postalCode 50 | }, 51 | "START"); 52 | 53 | WeatherForecast? WeatherForecast = await _WeatherService.GetWeatherForecase(postalCode).ConfigureAwait(false); 54 | 55 | _Logger.WriteInfo( 56 | new 57 | { 58 | Success = WeatherForecast != null 59 | }, 60 | "END"); 61 | 62 | if (WeatherForecast == null) 63 | throw new InvalidOperationException("Invalid postalCode provided."); 64 | 65 | return Partial("_WeatherServicePartial", WeatherForecast); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PrivacyModel 3 | @{ 4 | ViewData["Title"] = "Privacy Policy"; 5 | } 6 | @ViewData["Title"] 7 | 8 | Use this page to detail your site's privacy policy. 9 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.RazorPages; 2 | 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace DemoWebApplication.Pages 6 | { 7 | public class PrivacyModel : PageModel 8 | { 9 | private readonly ILogger _Logger; 10 | 11 | public PrivacyModel(ILogger logger) 12 | { 13 | _Logger = logger; 14 | } 15 | 16 | public void OnGet() => _Logger.WriteInfo("START"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - DemoWebApplication 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | DemoWebApplication 15 | 17 | 18 | 19 | 20 | 21 | 22 | Home 23 | 24 | 25 | Privacy 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | @RenderBody() 35 | 36 | 37 | 38 | 43 | 44 | 45 | 46 | 47 | 48 | @RenderSection("Scripts", required: false) 49 | 50 | 51 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/Shared/_WeatherServicePartial.cshtml: -------------------------------------------------------------------------------- 1 | @model WeatherForecast 2 | 3 | Weather Forecast for @Model.FriendlyName (@Model.PostalCode) 4 | 5 | 6 | High: @Model.HighTemperatureInFahrenheitDegrees 7 | 8 | 9 | 10 | Low: @Model.HighTemperatureInFahrenheitDegrees 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using DemoWebApplication 2 | @namespace DemoWebApplication.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading.Tasks; 4 | 5 | using Microsoft.AspNetCore.Hosting; 6 | 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace DemoWebApplication 12 | { 13 | public static class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | Activity.DefaultIdFormat = ActivityIdFormat.W3C; 18 | 19 | IHost host = CreateHostBuilder(args).Build(); 20 | 21 | ILogger log = host.Services.GetRequiredService() 22 | .CreateLogger(typeof(Program).FullName); 23 | 24 | using IDisposable group = log.BeginGroup("Main"); 25 | 26 | log.WriteInfo("Starting..."); 27 | 28 | try 29 | { 30 | await host.StartAsync().ConfigureAwait(false); 31 | 32 | await host.WaitForShutdownAsync().ConfigureAwait(false); 33 | } 34 | catch (Exception runException) 35 | { 36 | log.WriteCritical(runException, "Process Main unhandled Exception thrown."); 37 | throw; 38 | } 39 | finally 40 | { 41 | log.WriteInfo("Stopping..."); 42 | 43 | if (host is IAsyncDisposable asyncDisposable) 44 | { 45 | await asyncDisposable.DisposeAsync().ConfigureAwait(false); 46 | } 47 | else 48 | { 49 | host.Dispose(); 50 | } 51 | } 52 | } 53 | 54 | public static IHostBuilder CreateHostBuilder(string[] args) 55 | { 56 | return Host 57 | .CreateDefaultBuilder(args) 58 | #if WINDOWS && DEBUG 59 | .ConfigureDebugWindow() 60 | #endif 61 | .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()) 62 | .ConfigureLogging((builder) => builder.AddFiles(options => options.IncludeGroupNameInFileName = true)); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("b2e9e27f-d451-4f83-bc06-958127a71af4")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.21019")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:50524", 8 | "sslPort": 44300 9 | } 10 | }, 11 | "profiles": { 12 | "WebApplication1": { 13 | "commandName": "Project", 14 | "launchBrowser": false, 15 | "launchUrl": "weatherforecast", 16 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.Extensions.Hosting; 7 | 8 | namespace DemoWebApplication 9 | { 10 | public class Startup 11 | { 12 | public IConfiguration Configuration { get; } 13 | 14 | public Startup(IConfiguration configuration) 15 | { 16 | Configuration = configuration; 17 | } 18 | 19 | #pragma warning disable CA1822 // Mark members as static 20 | public void ConfigureServices(IServiceCollection services) 21 | #pragma warning restore CA1822 // Mark members as static 22 | { 23 | services.AddControllers(); 24 | services.AddRazorPages(); 25 | 26 | services.AddHostedService(); 27 | 28 | services.AddSingleton(); 29 | } 30 | 31 | #pragma warning disable CA1822 // Mark members as static 32 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 33 | #pragma warning restore CA1822 // Mark members as static 34 | { 35 | app.UseMiddleware(); 36 | 37 | if (env.IsDevelopment()) 38 | { 39 | app.UseDeveloperExceptionPage(); 40 | } 41 | else 42 | { 43 | app.UseExceptionHandler("/Error"); 44 | 45 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 46 | app.UseHsts(); 47 | } 48 | 49 | app.UseHttpsRedirection(); 50 | app.UseStaticFiles(); 51 | 52 | app.UseRouting(); 53 | 54 | app.UseAuthorization(); 55 | 56 | app.UseEndpoints(endpoints => 57 | { 58 | endpoints.MapControllers(); 59 | endpoints.MapRazorPages(); 60 | }); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DemoWebApplication 4 | { 5 | public class WeatherForecast 6 | { 7 | public int? PostalCode { get; set; } 8 | 9 | public string? FriendlyName { get; set; } 10 | 11 | public int? HighTemperatureInFahrenheitDegrees { get; set; } 12 | 13 | public int? LowTemperatureInFahrenheitDegrees { get; set; } 14 | 15 | public DateTime? ForecastGoodUntilTime { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/WeatherService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | using Microsoft.Extensions.Logging; 5 | 6 | namespace DemoWebApplication 7 | { 8 | public class WeatherService : IWeatherService 9 | { 10 | private readonly ILogger _Logger; 11 | 12 | public WeatherService(ILogger logger) 13 | { 14 | _Logger = logger; 15 | } 16 | 17 | public Task GetWeatherForecase(int postalCode) 18 | { 19 | WeatherForecast? Forecast = postalCode <= 0 20 | ? null 21 | : new WeatherForecast 22 | { 23 | PostalCode = postalCode, 24 | FriendlyName = "Blanchtown", 25 | HighTemperatureInFahrenheitDegrees = 70, 26 | LowTemperatureInFahrenheitDegrees = 50, 27 | ForecastGoodUntilTime = DateTime.Now.AddSeconds(30) 28 | }; 29 | 30 | _Logger.WriteInfo(Forecast, "Weather forecast generated."); 31 | 32 | return Task.FromResult(Forecast); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "DemoWebApplication": "Debug", 5 | "DemoWebApplication.MessageSpamBackgroundService": "Information" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "Console": { 4 | "IncludeScopes": false, 5 | "LogLevel": { 6 | "Default": "Error" 7 | } 8 | }, 9 | "LogLevel": { 10 | "Default": "Information", 11 | "System": "Warning", 12 | "Microsoft": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Information", 14 | "Microsoft.Extensions": "Trace" 15 | } 16 | }, 17 | "AllowedHosts": "*" 18 | } 19 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/favicon.ico -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your Javascript code. 5 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Demo/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Windows.Debugging/Example.png -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestConsoleApp/MessageSpamBackgroundService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | using Microsoft.Extensions.Hosting; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace TestConsoleApp 9 | { 10 | public class MessageSpamBackgroundService : BackgroundService 11 | { 12 | private readonly ILogger _Log; 13 | 14 | public MessageSpamBackgroundService(ILogger logger) 15 | { 16 | _Log = logger ?? throw new ArgumentNullException(nameof(logger)); 17 | } 18 | 19 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 20 | { 21 | int MessageIndex = 0; 22 | 23 | while (!stoppingToken.IsCancellationRequested) 24 | { 25 | _Log.LogInformation("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 26 | 27 | await Task.Delay(100, stoppingToken).ConfigureAwait(false); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace TestConsoleApp 5 | { 6 | public static class Program 7 | { 8 | public static void Main(string[] args) => CreateHostBuilder(args).Build().Run(); 9 | 10 | public static IHostBuilder CreateHostBuilder(string[] args) 11 | { 12 | return Host.CreateDefaultBuilder(args) 13 | #if WINDOWS && DEBUG 14 | .ConfigureDebugWindow() 15 | #endif 16 | .ConfigureServices((hostContext, services) => services.AddHostedService()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestConsoleApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("e6ebb5c7-8d0e-4ddf-a862-b1af8ca8adbd")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20331")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestConsoleApp/TestConsoleApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | true 6 | false 7 | false 8 | false 9 | false 10 | 11 | 12 | 13 | net5.0-windows 14 | WINDOWS 15 | 16 | 17 | 18 | net5.0 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/ControllerNameLoggerGroupMiddleware.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Routing; 6 | 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace TestWebApplication 10 | { 11 | // Make sure you register routing (UseRouting) before this middleware or route data won't be available when it is invoked. 12 | public class ControllerNameLoggerGroupMiddleware 13 | { 14 | private readonly ILogger _Logger; 15 | private readonly RequestDelegate _Next; 16 | 17 | public ControllerNameLoggerGroupMiddleware(ILogger logger, RequestDelegate next) 18 | { 19 | _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); 20 | _Next = next ?? throw new ArgumentNullException(nameof(next)); 21 | } 22 | 23 | public async Task InvokeAsync(HttpContext context) 24 | { 25 | RouteValueDictionary? RouteValues = context?.Request.RouteValues; 26 | 27 | IDisposable? Group = null; 28 | if (RouteValues != null && RouteValues.TryGetValue("controller", out object? ControllerName)) 29 | { 30 | string? controllerName = ControllerName?.ToString(); 31 | if (!string.IsNullOrEmpty(controllerName)) 32 | Group = _Logger.BeginGroup(controllerName); 33 | } 34 | 35 | try 36 | { 37 | await _Next(context!).ConfigureAwait(false); 38 | } 39 | finally 40 | { 41 | Group?.Dispose(); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace TestWebApplication.Controllers 10 | { 11 | [ApiController] 12 | [Route("[controller]")] 13 | public class WeatherForecastController : ControllerBase 14 | { 15 | private static readonly string[] s_Summaries = new[] 16 | { 17 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 18 | }; 19 | 20 | private static readonly Random s_Random = new Random(); 21 | 22 | private readonly ILogger _Logger; 23 | 24 | public WeatherForecastController(ILogger logger) 25 | { 26 | _Logger = logger; 27 | } 28 | 29 | [HttpGet] 30 | public IEnumerable Get([FromQuery] int? optionalId) 31 | { 32 | _Logger.WriteInfo( 33 | new 34 | { 35 | optionalId 36 | }, 37 | "REQ"); 38 | 39 | WeatherForecast[] Forecast = Enumerable 40 | .Range(1, 5) 41 | .Select(index => new WeatherForecast 42 | { 43 | Date = DateTime.Now.AddDays(index), 44 | TemperatureC = s_Random.Next(-20, 55), 45 | Summary = s_Summaries[s_Random.Next(s_Summaries.Length)] 46 | }) 47 | .ToArray(); 48 | 49 | _Logger.WriteInfo( 50 | new 51 | { 52 | Forecast 53 | }, 54 | "RSP"); 55 | 56 | return Forecast; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/MessageSpamBackgroundService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | using Microsoft.Extensions.Hosting; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace TestWebApplication 9 | { 10 | public class MessageSpamBackgroundService : BackgroundService 11 | { 12 | private readonly ILogger _Log; 13 | 14 | public MessageSpamBackgroundService(ILogger logger) 15 | { 16 | _Log = logger ?? throw new ArgumentNullException(nameof(logger)); 17 | } 18 | 19 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 20 | { 21 | int MessageIndex = 0; 22 | 23 | while (!stoppingToken.IsCancellationRequested) 24 | { 25 | if (MessageIndex % 7 == 0) 26 | _Log.LogDebug("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 27 | else if (MessageIndex % 10 == 0) 28 | _Log.LogWarning("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 29 | else 30 | _Log.LogInformation("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 31 | 32 | await Task.Delay(100, stoppingToken).ConfigureAwait(false); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.Extensions.Hosting; 5 | 6 | namespace TestWebApplication 7 | { 8 | public static class Program 9 | { 10 | public static void Main(string[] args) => CreateHostBuilder(args).Build().Run(); 11 | 12 | public static IHostBuilder CreateHostBuilder(string[] args) 13 | { 14 | return Host 15 | .CreateDefaultBuilder(args) 16 | #if WINDOWS && DEBUG 17 | .ConfigureDebugWindow( 18 | options => options.WindowTitle = "My Application DebugWindow Title", 19 | (window) => window.BackColor = Color.Red, 20 | (tab) => tab.BackColor = Color.Blue) 21 | #endif 22 | .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("8953327e-9c2f-4310-a17e-26f5612a77c3")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20331")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:50524", 8 | "sslPort": 44300 9 | } 10 | }, 11 | "profiles": { 12 | "WebApplication1": { 13 | "commandName": "Project", 14 | "launchBrowser": false, 15 | "launchUrl": "weatherforecast", 16 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.Extensions.Hosting; 7 | 8 | namespace TestWebApplication 9 | { 10 | public class Startup 11 | { 12 | public IConfiguration Configuration { get; } 13 | 14 | public Startup(IConfiguration configuration) 15 | { 16 | Configuration = configuration; 17 | } 18 | 19 | #pragma warning disable CA1822 // Mark members as static 20 | public void ConfigureServices(IServiceCollection services) 21 | #pragma warning restore CA1822 // Mark members as static 22 | { 23 | services.AddControllers(); 24 | 25 | services.AddHostedService(); 26 | } 27 | 28 | #pragma warning disable CA1822 // Mark members as static 29 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 30 | #pragma warning restore CA1822 // Mark members as static 31 | { 32 | if (env.IsDevelopment()) 33 | { 34 | app.UseDeveloperExceptionPage(); 35 | } 36 | 37 | app.UseHttpsRedirection(); 38 | 39 | app.UseRouting(); 40 | 41 | app.UseMiddleware(); 42 | 43 | app.UseAuthorization(); 44 | 45 | app.UseEndpoints(endpoints => endpoints.MapControllers()); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/TestWebApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | false 7 | false 8 | false 9 | 10 | 11 | 12 | net5.0-windows 13 | WINDOWS 14 | 15 | 16 | 17 | net5.0 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TestWebApplication 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime? Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string? Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "DebugWindow": { 4 | "ShowDebugWindow": true, 5 | "MinimizeToSystemTray": true, 6 | "LogLevel": { 7 | "Default": "Debug" 8 | } 9 | }, 10 | "LogLevel": { 11 | "Default": "Information", 12 | "Microsoft": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Information" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWebApplication/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWindowsService/MessageSpamBackgroundService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | using Microsoft.Extensions.Hosting; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace TestWindowsService 9 | { 10 | public class MessageSpamBackgroundService : BackgroundService 11 | { 12 | private readonly ILogger _Log; 13 | 14 | public MessageSpamBackgroundService(ILogger logger) 15 | { 16 | _Log = logger ?? throw new ArgumentNullException(nameof(logger)); 17 | } 18 | 19 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 20 | { 21 | int MessageIndex = 0; 22 | 23 | while (!stoppingToken.IsCancellationRequested) 24 | { 25 | _Log.LogInformation("Message {Index}. We're not in \"Kansas\" no' mo'!", MessageIndex++); 26 | 27 | await Task.Delay(100, stoppingToken).ConfigureAwait(false); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWindowsService/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace TestWindowsService 5 | { 6 | public static class Program 7 | { 8 | public static void Main(string[] args) => CreateHostBuilder(args).Build().Run(); 9 | 10 | public static IHostBuilder CreateHostBuilder(string[] args) 11 | { 12 | return Host.CreateDefaultBuilder(args) 13 | .ConfigureServices((hostContext, services) => services.AddHostedService()) 14 | #if WINDOWS && DEBUG 15 | .ConfigureDebugWindow() 16 | #endif 17 | .UseWindowsService(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWindowsService/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("4b5ee816-d8cb-4e43-8386-e3ac9453b609")] 9 | 10 | [assembly: AssemblyVersion("0.0.0.20331")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWindowsService/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "TestWindowsService": { 4 | "commandName": "Project", 5 | "environmentVariables": { 6 | "DOTNET_ENVIRONMENT": "Development" 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWindowsService/TestWindowsService.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | dotnet-TestWindowsService-4EBCCC36-B9E6-4521-ACE1-F23FE7A84DBE 5 | true 6 | false 7 | false 8 | false 9 | false 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | net5.0-windows 19 | WINDOWS 20 | 21 | 22 | 23 | net5.0 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWindowsService/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Debugging/Test/TestWindowsService/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Impersonation/Code/Macross.Windows.Impersonation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0-windows;netstandard2.1;netstandard2.0;net48 5 | True 6 | keypair.snk 7 | 8 | Macross Software Windows impersonation library. 9 | 10 | Provides an API for managing impersonation in Windows threads & processes. 11 | 12 | Macross.Windows.Impersonation 13 | true 14 | false 15 | false 16 | 0.0.1 17 | alpha1 18 | $(VersionPrefix) 19 | 20 | 21 | 22 | $(VersionPrefix) 23 | 24 | 25 | $(VersionPrefix)-$(VersionSuffix) 26 | 27 | 28 | 29 | ..\..\..\_build\DLLs\$(Configuration)\ 30 | ..\..\..\_build\DLLs\$(Configuration)\Macross.Windows.Impersonation.xml 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Impersonation/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("abfdf6e9-2b65-4aec-8de3-2a00aa5fa68b")] 9 | 10 | [assembly: AssemblyVersion("0.0.1.20011")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Impersonation/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Windows.Impersonation/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Impersonation/README.md: -------------------------------------------------------------------------------- 1 | # Macross Software Impersonation 2 | 3 | Macross.Windows.Impersonation is a .NET Standard 2.0+ library for augmenting what is provided by the framework for impersonation on Windows. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Permissions/Code/Macross.Windows.Permissions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0-windows;netstandard2.1;netstandard2.0 5 | True 6 | keypair.snk 7 | 8 | Macross Software Windows permissions library. 9 | 10 | Provides an API for managing Windows permissions. 11 | 12 | Commonly Used Types: 13 | Macross.Windows.Permissions.LocalSecurityAuthorityController 14 | 15 | Common Uses: 16 | Grant "logon as service" permission to a user on a specific Windows machine. 17 | 18 | Macross.Windows.Permissions 19 | true 20 | false 21 | false 22 | 0.0.1 23 | alpha1 24 | $(VersionPrefix) 25 | 26 | 27 | 28 | $(VersionPrefix) 29 | 30 | 31 | $(VersionPrefix)-$(VersionSuffix) 32 | 33 | 34 | 35 | ..\..\..\_build\DLLs\$(Configuration)\ 36 | ..\..\..\_build\DLLs\$(Configuration)\Macross.Windows.Permissions.xml 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Permissions/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("97eec3c2-2e9e-4a36-aeef-86fe325ac18e")] 9 | 10 | [assembly: AssemblyVersion("0.0.1.20011")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Permissions/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Windows.Permissions/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.Permissions/README.md: -------------------------------------------------------------------------------- 1 | # Macross Software Permissions 2 | 3 | Macross.Windows.Permissions is a .NET Standard 2.0+ library for augmenting what is provided by the framework for permissions on Windows. -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/Macross.Windows.ServiceManagement.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0-windows;netstandard2.1;netstandard2.0 5 | True 6 | keypair.snk 7 | 8 | Macross Software Windows service management library. 9 | 10 | Provides an API for managing Windows services. Operations inlcuded: create, delete, query, start, stop, pause, & continue. 11 | 12 | Contains similiar functionality to what is provided in System.ServiceProcess but also adds in Create & Delete operations to replace (in spirit) what ServiceProcessInstaller & ServiceInstaller from System.Configuration.Install provided in .NET Framework. 13 | 14 | Provides an asynchronous WaitForStatus method. 15 | 16 | Macross.Windows.ServiceManagement 17 | true 18 | false 19 | false 20 | 0.0.1 21 | alpha1 22 | $(VersionPrefix) 23 | 24 | 25 | 26 | $(VersionPrefix) 27 | 28 | 29 | $(VersionPrefix)-$(VersionSuffix) 30 | 31 | 32 | 33 | ..\..\..\_build\DLLs\$(Configuration)\ 34 | ..\..\..\_build\DLLs\$(Configuration)\Macross.Windows.ServiceManagement.xml 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: ComVisible(false)] 6 | [assembly: CLSCompliant(false)] 7 | 8 | [assembly: Guid("8983470e-ee87-4178-9db1-e58304a0499f")] 9 | 10 | [assembly: AssemblyVersion("0.0.1.20011")] -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/SafeServiceHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Win32.SafeHandles; 4 | 5 | namespace Macross.Windows.ServiceManagement 6 | { 7 | internal class SafeServiceHandle : SafeHandleZeroOrMinusOneIsInvalid 8 | { 9 | private SafeServiceHandle() 10 | : base(true) 11 | { 12 | } 13 | 14 | public SafeServiceHandle(IntPtr handle) 15 | : base(true) 16 | { 17 | SetHandle(handle); 18 | } 19 | 20 | protected override bool ReleaseHandle() => NativeMethods.CloseServiceHandle(handle); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/ServiceAccount.cs: -------------------------------------------------------------------------------- 1 | namespace Macross.Windows.ServiceManagement 2 | { 3 | /// Specifies a service's security context, which defines its logon type. 4 | public enum ServiceAccount 5 | { 6 | /// An account that acts as a non-privileged user on the local computer, and presents anonymous credentials to any remote server. 7 | LocalService, 8 | 9 | /// An account that provides extensive local privileges, and presents the computer's credentials to any remote server. 10 | NetworkService, 11 | 12 | /// An account, used by the service control manager, that has extensive privileges on the local computer and acts as the computer on the network. 13 | LocalSystem, 14 | 15 | /// An account defined by a specific user on the network. 16 | User, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/ServiceConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System.Security; 2 | 3 | namespace Macross.Windows.ServiceManagement 4 | { 5 | /// 6 | /// Describes the configuration of a Windows Service registered with Service Control Manager. 7 | /// 8 | public class ServiceConfiguration 9 | { 10 | /// 11 | /// Gets or sets the ServiceName of the service. 12 | /// 13 | public string? ServiceName { get; set; } 14 | 15 | /// 16 | /// Gets or sets the DisplayName of the service. ServiceName will be used if not specified. 17 | /// 18 | public string? DisplayName { get; set; } 19 | 20 | /// 21 | /// Gets or sets the Description of the service. 22 | /// 23 | public string? Description { get; set; } 24 | 25 | /// 26 | /// Gets or sets the of the service. Default value: . 27 | /// 28 | public ServiceStartMode StartMode { get; set; } = ServiceStartMode.Manual; 29 | 30 | /// 31 | /// Gets or sets the type of under which to run this service application. 32 | /// 33 | public ServiceAccount Account { get; set; } = ServiceAccount.User; 34 | 35 | /// 36 | /// Gets or sets the user account under which the service application will run when is used. 37 | /// 38 | public string? Username { get; set; } 39 | 40 | /// 41 | /// Gets or sets the password associated with the user account under which the service application will run when is used. 42 | /// 43 | public SecureString? Password { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/ServiceStartMode.cs: -------------------------------------------------------------------------------- 1 | namespace Macross.Windows.ServiceManagement 2 | { 3 | /// Indicates the start mode of the service. 4 | public enum ServiceStartMode 5 | { 6 | /// 7 | /// Indicates that the service is to be started (or was started) by the operating 8 | /// system, at system start-up. If an automatically started service depends on a 9 | /// manually started service, the manually started service is also started automatically 10 | /// at system startup. 11 | /// 12 | Automatic = 2, 13 | 14 | /// 15 | /// Indicates that the service is to be started (or was started) by the operating 16 | /// system, at system start-up, shortly after all other services designated as 17 | /// Automatic have been started. 18 | /// 19 | AutomaticDelayedStart = 100, 20 | 21 | /// Indicates that the service is started only manually, by a user (using the Service Control Manager) or by an application. 22 | Manual = 3, 23 | 24 | /// Indicates that the service is disabled, so that it cannot be started by a user or application. 25 | Disabled = 4, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/ServiceState.cs: -------------------------------------------------------------------------------- 1 | namespace Macross.Windows.ServiceManagement 2 | { 3 | /// Indicates the current state of the service. 4 | public enum ServiceState : int 5 | { 6 | /// The service is not running. 7 | Stopped = 1, 8 | 9 | /// The service is starting. 10 | StartPending = 2, 11 | 12 | /// The service is stopping. 13 | StopPending = 3, 14 | 15 | /// The service is running. 16 | Running = 4, 17 | 18 | /// The service continue is pending. 19 | ContinuePending = 5, 20 | 21 | /// The service pause is pending. 22 | PausePending = 6, 23 | 24 | /// The service is paused. 25 | Paused = 7 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/Code/keypair.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Macross-Software/core/a4ed6770099826af3cbfd07d1442af68bc664526/ClassLibraries/Macross.Windows.ServiceManagement/Code/keypair.snk -------------------------------------------------------------------------------- /ClassLibraries/Macross.Windows.ServiceManagement/README.md: -------------------------------------------------------------------------------- 1 | # Macross Software Service Management 2 | 3 | Macross.Windows.ServiceManagement is a .NET Standard 2.0+ library for augmenting what is provided by the framework for management of services on Windows. -------------------------------------------------------------------------------- /CodeAnalysis.ruleset: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | preview 4 | enable 5 | $(MSBuildThisFileDirectory)CodeAnalysis.ruleset 6 | git 7 | https://github.com/Macross-Software/core 8 | true 9 | true 10 | snupkg 11 | Macross Software 12 | Copyright © $([System.DateTime]::Now.ToString(yyyy)) 13 | MIT 14 | 15 | 16 | 17 | $(NoWarn);8600;8601;8602;8603;8604 18 | 19 | 20 | 21 | true 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Macross Software 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "allowPrerelease": false, 4 | "version": "6.0.101", 5 | "rollForward": "latestFeature" 6 | } 7 | } -------------------------------------------------------------------------------- /stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "indentation": { 5 | "useTabs": true 6 | }, 7 | "orderingRules": { 8 | "blankLinesBetweenUsingGroups": "require" 9 | } 10 | } 11 | } --------------------------------------------------------------------------------
13 | Request ID: @Model.RequestId 14 |
@Model.RequestId
19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |
22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |
Learn about building Web apps with ASP.NET Core.
Use this page to detail your site's privacy policy.