BeerAndMala
BeerAndMala
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
Solved. Turns out that my TrimmerRootDescriptor file wasn't enough, the publishing process still stripped all parameter names from the DLLs (confirmed by extracting and decompiling the published files). Only if I explicitly add TrimmerRootAssembly¹ entries for the assemblies I care about THEN the information will be retained. This was quite a painful journey... ①: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-8-0#root-assemblies
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
See, my confusion is not about things breaking. But how they break makes no sense. There's no exception here, just missing information. Worse, it works with a different sink (I can log to the console for example, which uses the same "I don't support trimming" - but my project excludes that file anyway - serilog.settings.configuration code to do the reflection and matching. I'm hoping someone here is more familiar with weird and confusing edge cases, hence the question
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
https://github.com/serilog/serilog-settings-configuration/blob/dev/src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs#L485 this is the code that works with standard reflection types, doesn't throw, has access to methods (the two listed), concats the parameter names (again without throwing, parameter count is correct if I compare it to the methods I want to get here). It's just that the .Name is empty and then lists EventLog(, , ...) instead of EventLog(loggerConfigration, source, logName, ...) https://github.com/serilog/serilog-sinks-eventlog/blob/master/src/Serilog.Sinks.EventLog/LoggerConfigurationEventLogExtensions.cs#L49
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
No, it's not an exception. It's literally working reflection, then LINQ to go through (working, as in .. accessible, reachable) ParameterInfos, then joining their .Name properties (again, working code) as string.Join(", ", ...) .. to get that output. None of that throws. It just doesn't return the parameter names
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
Basically I expected trimming to either break stuff (MethodNotFound or something) or work. Here I see something that looks closer to .. symbol stripping of sorts. And those would be in Serilog.Sinks.EventLog, an assembly that I exclude from trimming.
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
Let me try to exclude the reflection types from trimming too
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
<linker>
<assembly fullname="Serilog" />
<assembly fullname="Serilog.Settings.Configuration" />
<assembly fullname="Serilog.Sinks.Console" />
<assembly fullname="Serilog.Sinks.EventLog" />
</linker>
<linker>
<assembly fullname="Serilog" />
<assembly fullname="Serilog.Settings.Configuration" />
<assembly fullname="Serilog.Sinks.Console" />
<assembly fullname="Serilog.Sinks.EventLog" />
</linker>
I don't trim that file at all though. Unless .. trimming somehow removes/shims the ParameterInfo.Name? 🤔
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
.. I did look at that. It's not related to/doesn't document the issue I'm seeing. I'm reaching out here, hoping that someone knows about weird edge cases. Serilog doesn't explicitly break this and no part of the documentation - your link included - explains what is going on as far as I can tell
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
I'm not using AOT I did open an issue for Serilog, but I doubt it's on them - I literally talk about MethodInfo.GetParameters().All(p => p.Name == string.Empty) being a weird issue here
26 replies
CC#
Created by BeerAndMala on 1/11/2024 in #help
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
That's not quite what I'm looking for. Reflection does work here (it finds the methods/MethodInfo instances) and fails to see any (reasonable) Name for GetParameters() - and THAT is rather odd. Plus, I actually explicitly disabled trimming for that assembly specifically with a custom TrimmingRoots.xml. Something, somewhere, somehow (why??) kills access to the parameter names here it seems.
26 replies