-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference Assembly Aliases are not passed to compiler #3069
Comments
|
@dupdob do you remember if during implementing support for reference alias if you actually saw references with alias in the format We did try to reproduce aliases on referenced assemblies directly instead of through package reference however the alias was not available in the analyzer result. |
I can't remember sorry. I am not even sure you can directly add reference to assemblies nowadays. |
just for completion: I looked at last year's issue: at that time, I am positive I was able to reproduce the issue (with referenced package) and I did meet this format. Beyond the fact that I remember it, I do not see how I would have been able to guess the appropriate syntax (alias = package) as documentation is lacking on this topic. My previous comment was referring to 'direct' assembly reference, i.e. pre nuget (for context, I started doing C# with Net V1.1 😉 ) |
Yes I thought so too, it's too specific to guess. We could not reproduce it but it made me hesitant to remove it. I also keep this issue open to investigate further. |
thinking about it: it may also be a change in how Buildalyzer reports them! |
I reproduced the issue with integration tests. The aliases are clearly dropped during analysis, either by Buildalyzer or even Roslyn. |
Buildalyzer reads the compiler command line arguments passed by msbuild iirc so Buildalyzer probably just doesn't read them correctly, they should be read before Roslyn even does anything. |
It looks like it is using a Roslyn component for C# project, whereas it parses the F# command line directly. |
Ah I see what you mean, yes it does seem like Buildalyzer uses a pre-made commandline argument parser supplied by Roslyn to parse the cmd arguments. |
yep, using this class has been introduced in april 24. It looks like parsing was done by Buildalyzer before. |
AnalysisC# nativeThe C# compiler supports aliases for assembly reference (including multiple aliases for the same assembly). The argument syntax is : BuildalyzerEarlier Buildalyzer version had no explicit support for aliases assemblies. As such, these were exposed in the form of Buildalyzer V7+ now uses CSharpCommandLineParser to parse the compiler command line. This class does support properly aliases which are exposed via a dedicated property. ConsequencesAs Buildalyzer never supported aliases in the first place, this property is not captured and even less reported. SolutionsThere are two possible approaches to fix this issue, none of them being quick: either by implementing the necessary logic in Stryker or creating a Buildalyzer's PR to fix that. Implementing it in StrykerIt may be quite simple: the compiler command line is provided as a property in Pros for this approach: Stryker team is autonomous on fixing it; this is probably the fastest way to get a fix. The Cons: there is a risk regarding which command line BuilAlyzer exposes; it means Stryker is more involved in the project analysis step than before. Implementing it in BuildAlyzerHere we have to sub possibilities Revert behaviorThat is, ensure that aliased reference are returned in the form of Pros: the fix is simple. No change are required on Stryker's end Adding proper support for aliases in BuildalyzerHere the main effort is to design a non breaking way to expose aliases in Pros: the cleanest way to do this; add a needed feature to Buildalyzer; strengthen the collaboration between both projects. Cons: will take a long time, as one needs to create the Buildalyzer PR, have it accepted; then wait for it to be released and then re implement alias support in Stryker. ConclusionUltimately, this is a matter of trust in Buildalyzer. If we trust the project team to move this issue swiftly and keep collaborating with Stryker; we should work on the last scenario. WDYT |
My preference would go to first implement this in Buildalyzer because ultimately we will want it fixed there. If integration takes too long we can decide to implement a temporary solution in Stryker, or we can also accept the current workaround which is that we take the alias from PackageReference and 'assume' that most all users will be using PackageReference anyway. Since in the total lifetime of stryker we have had one total user report needing reference aliases I think we can safely rely on the current behavior for a while. |
Agree. I will see how to expose aliases in BuildAlyzer. |
I opened issues #291 on Buildalyzer and provided a sample solution exhibiting the problem. Along the way I learned that:
Both make sense, but the second one gave me a hard time finding a way to use an alias for xunit. |
I opened PR 294 that adds alias support for Buildalyzer. Once it is released, we still had to update Stryker to use the newly added |
update: PR has been merged! So next Buildalyzer release will containt the fix for AzureFunctions and the support for aliases. |
Describe the bug
We recently added a package reference alias for a package in Stryker.Core. Mutation testing now fails on Stryker.Core because we don't correctly parse the reference alias.
Logs
Expected behavior
Stryker compiles with Reference Alias since we have support for this.
Additional context
At least currently the References returned from Buildalyzer do not contain references in the format that we try to parse to detect Aliases:
https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Initialisation/Buildalyzer/IAnalyzerResultExtensions.cs#L110
Instead PackageReferences does seem to include Aliases:
The text was updated successfully, but these errors were encountered: