Provide a WholeProjectDecompiler constructor with no default parameter values#3903
Provide a WholeProjectDecompiler constructor with no default parameter values#3903ds5678 wants to merge 1 commit into
Conversation
| { | ||
| } | ||
|
|
||
| protected WholeProjectDecompiler( |
There was a problem hiding this comment.
isn't this a compile-time silent breaking change, since now anyone deriving from WholeProjectDecompiler using the protected ctor, will get exceptions in their face, if they relied on the default initialization of AssemblyReferenceClassifier and projectWriter?
There was a problem hiding this comment.
I'm not really sure how nullable annotations work for the repository (because of the reference assembly annotation package), but ideally it would go from maybe-null to not-null, so any callers who provide a maybe-null argument will get a warning at compile time.
There was a problem hiding this comment.
the reference annotator package just copies all the annotations from a given reference framework to the target framework of the decompiler (netstandard2.0) at build-time so Roslyn sees the annotated variants when compiling the decompiler project.
The only issue is that we haven't really invested in annotating everything and there's multiple reasons:
- It's a ton of work
- The old AST model used a null object pattern, making NRT somewhat useless
- Most transforms use a dataflow pattern, that's not really NRT friendly: fields are set in Run and are effectively non-null for the entire duration of the transform (and therefore safe), but this cannot be expressed nicely just by sprinkling
?and some extra attributes.
Given that the new AST model actively uses NRT, it might be worth asking Claude to try to annotate everything.
But as it stands now this is a somewhat ugly breaking change, also third-party users have no way of instantiating the project writer and classifier defaults, afaik...
There was a problem hiding this comment.
But as it stands now this is a somewhat ugly breaking change
I tried to make it as minimally breaking as possible, but I suspected that this might be the answer.
third-party users have no way of instantiating the project writer and classifier defaults, afaik...
The classifier is public, but yes the project writers are internal. Is it intended for them to be an implementation detail?
There was a problem hiding this comment.
I think we could make the project writer API public too... git history of the whole feature shows that all the other parts have been made public already. So... are we fine with just public or do we unseal at the same time?
There was a problem hiding this comment.
are we fine with just public or do we unseal at the same time?
I'm leaning towards not unsealing because that involves decisions about what the API should be. However, one of my implementations involved a fair bit of copy-pasting. Do you think it would benefit from inheritance?
I have another implementation for IProjectFileWriter. Do you think it should be included upstream?
There was a problem hiding this comment.
WriteFrameworkInfo sounds like a strong candidate for an extensibility point...
Ideas:
virtual void WriteCustomPropertyGroup(XmlTextWriter xml, ...);which allows adding one morePropertyGroup. And we'd probably need the same a customItemGroup?- maybe model properties and items using an object model that is then serialized to XML
I think the template method approach might be sufficient... might be a bit weird, if we want to avoid <PropertyGroup></PropertyGroup> if the method is not overridden.
Do you have a better idea perhaps?
Problem
I'm trying to trim types from my application, and I'm having issues with the NativeAOT compiler not realizing that my parameters are never null.
ILSpy/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs
Line 130 in 9898add
ILSpy/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs
Line 132 in 9898add
Solution
IAssemblyReferenceClassifierand replaced most uses ofAssemblyReferenceClassifierwith it.WholeProjectDecompilerconstructor to the second most one.ArgumentNullExceptionchecks to the most specificWholeProjectDecompilerconstructor.