PS Plumbing - in a collaboration of nugets, which nugets need which PS nuget? #9
-
Some time back, we built a system that included a semi-weird logging process. A fairly large subset of method calls was intercepted, signatures analyzed, resulting details added to a repository for later processing. The system was implemented on .NET Framework, and this audit was built as a custom [Log] aspect. It works well, well enough that I haven't thought about the details of which libraries need to be in what components in awhile. Now we have a need for a similar system aimed at a different data set, but the same auditing requirements. I would like to apply a similar aspect. This new system is in .NET 8, and we have had good luck porting common components of the old system that are still useful to .NET Standard 2.0 and sharing between the old and new. I have not had as much luck with the aspect. I think I am not remembering some of the basics of the post-compiler. If I have an aspect derived from OnMethodBoundaryAspect in the Log.nupkg, and I have methods that read and write data and need annotated with [Log] in Repo.nupkg, and I have an application that invokes repository code in App.exe, where do I need to include the PostSharp.nupkg so that all three of the solutions make appropriate use of the post-compiler? In the best of all possible worlds I could port the current [Log] to .NET Standard 2.0 and have the old and new systems share the same aspect. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The PostSharp NuGet package adds the postcompiler to the project's build. So anytime your code is annotated with an aspect (anytime there is [Log] used in your code in your case), you need the PostSharp NuGet package referenced. Apps referencing the code, but not having any aspect in their own code, don't need the PostSharp NuGet package installed. If the PostSharp NuGet package is installed in such case, you'd get a warning that there are no aspects and that PostSharp can be disabled. In these apps, you may need to reference PostSharp.Redist NuGet package, that comes with the run-time libraries required to run the app. See https://doc.postsharp.net/il/introduction/overview/postsharp-components |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
The PostSharp NuGet package adds the postcompiler to the project's build. So anytime your code is annotated with an aspect (anytime there is [Log] used in your code in your case), you need the PostSharp NuGet package referenced.
Apps referencing the code, but not having any aspect in their own code, don't need the PostSharp NuGet package installed. If the PostSharp NuGet package is installed in such case, you'd get a warning that there are no aspects and that PostSharp can be disabled. In these apps, you may need to reference PostSharp.Redist NuGet package, that comes with the run-time libraries required to run the app.
See https://doc.postsharp.net/il/introduction/overview/postsharp-comp…