Skip to content

Commit aab6a9e

Browse files
committed
Software Factory no longer occurs of the BoundedLoggingDestructuringPolicyTemplate is not included.
1 parent 116aa1b commit aab6a9e

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

Modules/Intent.Modules.AspNetCore.Logging.Serilog/FactoryExtensions/SerilogStartupConfigurationExtension.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using System;
2-
using System.Linq;
3-
using System.Threading;
4-
using System.Threading.Tasks.Dataflow;
51
using Intent.Engine;
62
using Intent.Modules.AspNetCore.Logging.Serilog.Settings;
73
using Intent.Modules.AspNetCore.Logging.Serilog.Templates;
4+
using Intent.Modules.AspNetCore.Logging.Serilog.Templates.BoundedLoggingDestructuringPolicy;
85
using Intent.Modules.Common;
96
using Intent.Modules.Common.CSharp.AppStartup;
107
using Intent.Modules.Common.CSharp.Builder;
@@ -16,6 +13,10 @@
1613
using Intent.Plugins.FactoryExtensions;
1714
using Intent.RoslynWeaver.Attributes;
1815
using Intent.Templates;
16+
using System;
17+
using System.Linq;
18+
using System.Threading;
19+
using System.Threading.Tasks.Dataflow;
1920

2021
[assembly: DefaultIntentManaged(Mode.Fully)]
2122
[assembly: IntentTemplate("Intent.ModuleBuilder.Templates.FactoryExtension", Version = "1.0")]
@@ -85,10 +86,19 @@ private static void RegisterSerilogConfiguration(IApplication application)
8586
programTemplate.ProgramFile.ConfigureHostBuilderChainStatement("UseSerilog", ["context", "services", "configuration"],
8687
(lambdaBlock, parameters) =>
8788
{
88-
lambdaBlock.WithExpressionBody(new CSharpMethodChainStatement("configuration")
89-
.AddChainStatement("ReadFrom.Configuration(context.Configuration)")
90-
.AddChainStatement("ReadFrom.Services(services)")
91-
.AddChainStatement($"Destructure.With(new {programTemplate.GetBoundedLoggingDestructuringPolicyTemplateName()}())"));
89+
if (programTemplate.OutputTarget.FindTemplateInstance(BoundedLoggingDestructuringPolicyTemplate.TemplateId) != null)
90+
{
91+
lambdaBlock.WithExpressionBody(new CSharpMethodChainStatement("configuration")
92+
.AddChainStatement("ReadFrom.Configuration(context.Configuration)")
93+
.AddChainStatement("ReadFrom.Services(services)")
94+
.AddChainStatement($"Destructure.With(new {programTemplate.GetBoundedLoggingDestructuringPolicyTemplateName()}())"));
95+
}
96+
else
97+
{
98+
lambdaBlock.WithExpressionBody(new CSharpMethodChainStatement("configuration")
99+
.AddChainStatement("ReadFrom.Configuration(context.Configuration)")
100+
.AddChainStatement("ReadFrom.Services(services)"));
101+
}
92102
});
93103
}, 10);
94104
}

Modules/Intent.Modules.AspNetCore.Logging.Serilog/Intent.Modules.AspNetCore.Logging.Serilog.imodspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package>
33
<id>Intent.Modules.AspNetCore.Logging.Serilog</id>
4-
<version>5.3.1</version>
4+
<version>5.3.2-pre.0</version>
55
<supportedClientVersions>[4.3.0-a, 5.0.0-a)</supportedClientVersions>
66
<releaseNotes>release-notes.md</releaseNotes>
77
<summary>Provides Serilog logging for ASP.NET Core.</summary>

Modules/Intent.Modules.AspNetCore.Logging.Serilog/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Version 5.3.2
2+
3+
- Fixed: Software Factory no longer occurs of the `BoundedLoggingDestructuringPolicyTemplate` is not included.
4+
15
### Version 5.3.1
26

37
- Fixed: Added the missing `[assembly: DefaultIntentManaged(Mode.Fully)]` to the `BoundedLoggingDestructuringPolicy` template.

0 commit comments

Comments
 (0)