Skip to content

Commit db69591

Browse files
create a new assembly primitives to act as a more of a common shared library of sorts, without any tendriles out into something that might make blazor unhappy
1 parent 58e3b28 commit db69591

33 files changed

+721
-336
lines changed

Directory.Packages.props

+179-178
Large diffs are not rendered by default.

LaunchPad.sln

+15
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Minimal.Tests", "tes
195195
EndProject
196196
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.Primitives", "src\Primitives\Rocket.Surgery.LaunchPad.Primitives.csproj", "{8E25E25B-622E-4A15-BE2F-13EA01AA8CA2}"
197197
EndProject
198+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.WebAssembly.Hosting", "src\WebAssembly.Hosting\Rocket.Surgery.LaunchPad.WebAssembly.Hosting.csproj", "{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}"
199+
EndProject
198200
Global
199201
GlobalSection(SolutionConfigurationPlatforms) = preSolution
200202
Debug|Any CPU = Debug|Any CPU
@@ -859,6 +861,18 @@ Global
859861
{8E25E25B-622E-4A15-BE2F-13EA01AA8CA2}.Release|x64.Build.0 = Release|Any CPU
860862
{8E25E25B-622E-4A15-BE2F-13EA01AA8CA2}.Release|x86.ActiveCfg = Release|Any CPU
861863
{8E25E25B-622E-4A15-BE2F-13EA01AA8CA2}.Release|x86.Build.0 = Release|Any CPU
864+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
865+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
866+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Debug|x64.ActiveCfg = Debug|Any CPU
867+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Debug|x64.Build.0 = Debug|Any CPU
868+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Debug|x86.ActiveCfg = Debug|Any CPU
869+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Debug|x86.Build.0 = Debug|Any CPU
870+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
871+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Release|Any CPU.Build.0 = Release|Any CPU
872+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Release|x64.ActiveCfg = Release|Any CPU
873+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Release|x64.Build.0 = Release|Any CPU
874+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Release|x86.ActiveCfg = Release|Any CPU
875+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3}.Release|x86.Build.0 = Release|Any CPU
862876
EndGlobalSection
863877
GlobalSection(SolutionProperties) = preSolution
864878
HideSolutionNode = FALSE
@@ -923,6 +937,7 @@ Global
923937
{75C5361A-B1E8-4194-8BBC-CD68D4FC62CA} = {5D11C19B-E8E4-4CE3-9C8A-1D368578EBCB}
924938
{3A72EB2F-D0C0-4AA4-9CCB-7EA04DC95C8D} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1}
925939
{8E25E25B-622E-4A15-BE2F-13EA01AA8CA2} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
940+
{6EA9A9C8-8AFC-46F6-84C0-1B97F4B59FC3} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
926941
EndGlobalSection
927942
GlobalSection(ExtensibilityGlobals) = postSolution
928943
SolutionGuid = {439897C2-CCBD-44FE-B2DC-A3E4670ADA59}

src/Foundation.NewtonsoftJson/NewtonsoftJsonDestructuringPolicy.cs

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
using Newtonsoft.Json.Linq;
2+
23
using Serilog.Core;
34
using Serilog.Events;
45

56
namespace Rocket.Surgery.LaunchPad.Foundation;
67

78
internal class NewtonsoftJsonDestructuringPolicy : IDestructuringPolicy
89
{
9-
private static LogEventPropertyValue Destructure(JValue jv, ILogEventPropertyValueFactory propertyValueFactory)
10-
{
10+
private static LogEventPropertyValue Destructure(JValue jv, ILogEventPropertyValueFactory propertyValueFactory) =>
1111
// ReSharper disable once NullableWarningSuppressionIsUsed
12-
return propertyValueFactory.CreatePropertyValue(jv.Value!, true);
13-
}
12+
propertyValueFactory.CreatePropertyValue(jv.Value, true);
1413

15-
private static LogEventPropertyValue Destructure(JArray ja, ILogEventPropertyValueFactory propertyValueFactory)
14+
public static LogEventPropertyValue Destructure(JArray ja, ILogEventPropertyValueFactory propertyValueFactory)
1615
{
1716
var elems = ja.Select(t => propertyValueFactory.CreatePropertyValue(t, true));
1817
return new SequenceValue(elems);
@@ -44,7 +43,7 @@ private static LogEventPropertyValue Destructure(JObject jo, ILogEventPropertyVa
4443
return new StructureValue(props, typeTag);
4544
}
4645

47-
private static LogEventPropertyValue DestructureToDictionaryValue(JObject jo, ILogEventPropertyValueFactory propertyValueFactory)
46+
public static LogEventPropertyValue DestructureToDictionaryValue(JObject jo, ILogEventPropertyValueFactory propertyValueFactory)
4847
{
4948
var elements = jo.Properties().Select(
5049
prop =>
@@ -61,14 +60,25 @@ public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyV
6160
switch (value)
6261
{
6362
case JObject jo:
64-
result = Destructure(jo, propertyValueFactory);
65-
return true;
63+
{
64+
result = Destructure(jo, propertyValueFactory);
65+
return true;
66+
}
67+
6668
case JArray ja:
67-
result = Destructure(ja, propertyValueFactory);
68-
return true;
69+
{
70+
result = Destructure(ja, propertyValueFactory);
71+
return true;
72+
}
73+
6974
case JValue jv:
70-
result = Destructure(jv, propertyValueFactory);
71-
return true;
75+
{
76+
result = Destructure(jv, propertyValueFactory);
77+
return true;
78+
}
79+
80+
default:
81+
break;
7282
}
7383

7484
result = null;

src/Foundation.NewtonsoftJson/Rocket.Surgery.LaunchPad.Foundation.NewtonsoftJson.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ExportConventionsClassName>NewtonsoftJsonExports</ExportConventionsClassName>
88
</PropertyGroup>
99
<ItemGroup>
10-
<ProjectReference Include="..\Foundation\Rocket.Surgery.LaunchPad.Foundation.csproj" />
10+
<ProjectReference Include="..\Primitives\Rocket.Surgery.LaunchPad.Primitives.csproj" />
1111
</ItemGroup>
1212
<ItemGroup>
1313
<PackageReference Include="Newtonsoft.Json" />

src/Foundation/Conventions/FluentValidationConvention.cs

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using Rocket.Surgery.Conventions.DependencyInjection;
1212
using Rocket.Surgery.DependencyInjection.Compiled;
1313
using Rocket.Surgery.LaunchPad.Foundation.Validation;
14-
using Rocket.Surgery.LaunchPad.Primitives.Conventions;
1514

1615
namespace Rocket.Surgery.LaunchPad.Foundation.Conventions;
1716

@@ -28,7 +27,6 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions;
2827
[PublicAPI]
2928
[ExportConvention]
3029
[AfterConvention<MediatRConvention>]
31-
[AfterConvention<HealthChecksConvention>]
3230
[ConventionCategory(ConventionCategory.Core)]
3331
public class FluentValidationConvention(FoundationOptions? options = null) : IServiceConvention
3432
{

src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
</ItemGroup>
1717
<ItemGroup>
1818
<ProjectReference Include="..\Primitives\Rocket.Surgery.LaunchPad.Primitives.csproj" />
19-
<ProjectReference Include="..\Telemetry\Rocket.Surgery.LaunchPad.Telemetry.csproj" />
2019
<ProjectReference
2120
Include="..\Analyzers\Rocket.Surgery.LaunchPad.Analyzers.csproj"
2221
IncludeAssets="analyzers"
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System.Reflection;
21
using Microsoft.Extensions.Configuration;
3-
using Microsoft.Extensions.Hosting;
2+
43
using OpenTelemetry;
54
using OpenTelemetry.Resources;
5+
66
using Rocket.Surgery.Conventions;
77
using Rocket.Surgery.LaunchPad.Telemetry;
88

@@ -13,17 +13,5 @@ namespace Rocket.Surgery.LaunchPad.Hosting.Conventions;
1313
[ConventionCategory(ConventionCategory.Core)]
1414
internal class DefaultTelemetryConvention : IOpenTelemetryConvention
1515
{
16-
public void Register(IConventionContext context, IConfiguration configuration, IOpenTelemetryBuilder builder)
17-
{
18-
builder.ConfigureResource(
19-
z => z
20-
.AddTelemetrySdk()
21-
.AddService(
22-
configuration["OTEL_SERVICE_NAME"] ?? context.Get<IHostEnvironment>()?.ApplicationName ?? "unknown",
23-
"Syndicates",
24-
Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion,
25-
serviceInstanceId: configuration["WEBSITE_SITE_NAME"]
26-
)
27-
);
28-
}
16+
public void Register(IConventionContext context, IConfiguration configuration, IOpenTelemetryBuilder builder) => builder.ConfigureResource(z => z.AddTelemetrySdk().AddEnvironmentVariableDetector());// .AddService(// configuration["OTEL_SERVICE_NAME"] ?? context.Get<IHostEnvironment>()?.ApplicationName ?? "unknown",// "Syndicates",// Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion,// serviceInstanceId: configuration["WEBSITE_SITE_NAME"]// )
2917
}

src/Primitives/Conventions/HealthChecksConvention.cs src/Hosting/Conventions/HealthChecksConvention.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Rocket.Surgery.Conventions;
55
using Rocket.Surgery.Conventions.DependencyInjection;
66

7-
namespace Rocket.Surgery.LaunchPad.Primitives.Conventions;
7+
namespace Rocket.Surgery.LaunchPad.Hosting.Conventions;
88

99
/// <summary>
1010
/// EnvironmentLoggingConvention.

src/Hosting/Conventions/OpenTelemetryConvention.cs

-32
This file was deleted.

src/Hosting/Conventions/SerilogConsoleLoggingConvention.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ LoggerConfiguration loggerConfiguration
4545
c => c.Console(
4646
LogEventLevel.Verbose,
4747
_options.ConsoleMessageTemplate,
48-
formatProvider: CultureInfo.InvariantCulture
49-
,
50-
theme: AnsiConsoleTheme.Literate)
48+
CultureInfo.InvariantCulture,
49+
theme: AnsiConsoleTheme.Code
50+
)
5151
);
5252
}
5353
}

src/Hosting/Conventions/SerilogHostingConvention.cs

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
using App.Metrics;
21
using Microsoft.Extensions.Configuration;
32
using Microsoft.Extensions.DependencyInjection;
4-
using Microsoft.Extensions.Hosting;
5-
using Microsoft.Extensions.Logging;
3+
64
using Rocket.Surgery.Conventions;
75
using Rocket.Surgery.Conventions.DependencyInjection;
86
using Rocket.Surgery.Conventions.Hosting;
9-
using Rocket.Surgery.Hosting;
7+
108
using Serilog;
119
using Serilog.Core;
12-
using Serilog.Events;
1310
using Serilog.Extensions.Hosting;
14-
using Serilog.Extensions.Logging;
15-
using ILogger = Serilog.ILogger;
1611

1712
namespace Rocket.Surgery.LaunchPad.Hosting.Conventions;
1813

@@ -30,25 +25,6 @@ public class SerilogHostingConvention : IServiceConvention
3025
public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services)
3126
{
3227
ArgumentNullException.ThrowIfNull(context);
33-
34-
// removes default console loggers and such
35-
foreach (var item in services
36-
.Where(
37-
x =>
38-
{
39-
var type = x.IsKeyedService ? x.KeyedImplementationType : x.ImplementationType;
40-
return type?.FullName?.StartsWith("Microsoft.Extensions.Logging", StringComparison.Ordinal) == true
41-
&& type.FullName.EndsWith("Provider", StringComparison.Ordinal);
42-
}
43-
)
44-
.ToArray()
45-
)
46-
{
47-
services.Remove(item);
48-
}
49-
50-
services.ActivateSingleton<Logger>();
51-
services.ActivateSingleton<LoggerProviderCollection>();
5228
services.AddSingleton(sp => new DiagnosticContext(sp.GetRequiredService<Logger>()));
5329
services.AddSingleton<IDiagnosticContext>(sp => sp.GetRequiredService<DiagnosticContext>());
5430
}

src/Hosting/Conventions/SerilogTelemetryConvention.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ namespace Rocket.Surgery.LaunchPad.Hosting.Conventions;
1111
/// Defines serilog telemetry configuration
1212
/// </summary>
1313
[PublicAPI]
14-
[ExportConvention]
1514
[ConventionCategory(ConventionCategory.Core)]
15+
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "Getting string values")]
1616
public partial class SerilogTelemetryConvention : ISerilogConvention
1717
{
1818
/// <inheritdoc />
19-
[RequiresUnreferencedCode("Serilog")]
2019
public void Register(IConventionContext context, IConfiguration configuration, IServiceProvider services, LoggerConfiguration loggerConfiguration) =>
2120
loggerConfiguration.WriteTo.OpenTelemetry(_ => { }, configuration.GetValue<string>);
2221
}
File renamed without changes.

src/Primitives/Rocket.Surgery.LaunchPad.Primitives.csproj

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
<PackageDescription />
55
<PackageTags>$(PackageTags)</PackageTags>
66
</PropertyGroup>
7+
<ItemGroup>
8+
<None Include="build/*.*" Pack="true" PackagePath="build" />
9+
<None Include="buildMultiTargeting/*.*" Pack="true" PackagePath="buildMultiTargeting" />
10+
<None Include="buildTransitive/*.*" Pack="true" PackagePath="buildTransitive" />
11+
</ItemGroup>
712
<ItemGroup>
813
<PackageReference Include="Microsoft.Extensions.Configuration" />
914
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
10-
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
1115
<PackageReference Include="Microsoft.Extensions.Logging" />
1216
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
1317
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
@@ -25,5 +29,6 @@
2529
</ItemGroup>
2630
<ItemGroup>
2731
<ProjectReference Include="..\Serilog\Rocket.Surgery.LaunchPad.Serilog.csproj" />
32+
<ProjectReference Include="..\Telemetry\Rocket.Surgery.LaunchPad.Telemetry.csproj" />
2833
</ItemGroup>
2934
</Project>

src/Serilog/Conventions/LoggerConvention.cs

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
using App.Metrics;
1+
using App.Metrics;
2+
23
using Microsoft.Extensions.Configuration;
34
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.Logging;
6+
57
using Rocket.Surgery.Conventions;
68
using Rocket.Surgery.Conventions.DependencyInjection;
79
using Rocket.Surgery.Conventions.Hosting;
10+
811
using Serilog;
912
using Serilog.Core;
1013
using Serilog.Extensions.Logging;
@@ -43,19 +46,13 @@ public void Register(IConventionContext context, IConfiguration configuration, I
4346
services.Remove(item);
4447
}
4548

46-
#pragma warning disable CA2000
49+
#pragma warning disable CA2000
4750
var loggerProviderCollection = new LoggerProviderCollection();
48-
#pragma warning restore CA2000
51+
#pragma warning restore CA2000
4952
var loggerConfiguration = new LoggerConfiguration();
5053

5154
if (context.Get<ILogger>() is { } logger) loggerConfiguration.WriteTo.Logger(logger);
52-
services.AddSingleton(
53-
serviceProvider =>
54-
{
55-
loggerConfiguration.ApplyConventions(context, configuration, serviceProvider);
56-
return loggerConfiguration.CreateLogger();
57-
}
58-
);
55+
services.AddSingleton(serviceProvider => loggerConfiguration.ApplyConventions(context, configuration, serviceProvider).CreateLogger());
5956
services.AddSingleton<ILogger>(serviceProvider => serviceProvider.GetRequiredService<Logger>());
6057
services.AddSingleton<ILoggerFactory>(
6158
serviceProvider => new SerilogLoggerFactory(
@@ -65,7 +62,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I
6562
)
6663
);
6764

68-
services.AddSingleton<LoggerProviderCollection>(
65+
services.AddSingleton(
6966
serviceProvider =>
7067
{
7168
var loggerProviders = serviceProvider.GetServices<ILoggerProvider>();
@@ -80,4 +77,4 @@ public void Register(IConventionContext context, IConfiguration configuration, I
8077
}
8178
);
8279
}
83-
}
80+
}

0 commit comments

Comments
 (0)