Skip to content

Correctly handle multiple reference aliases#1905

Merged
david-driscoll merged 2 commits intoOmniSharp:masterfrom
laenas:master
Aug 21, 2020
Merged

Correctly handle multiple reference aliases#1905
david-driscoll merged 2 commits intoOmniSharp:masterfrom
laenas:master

Conversation

@laenas
Copy link
Copy Markdown
Contributor

@laenas laenas commented Aug 20, 2020

The element of a or supports multiple aliases. Currently, OmniSharp will flag attempted usings of these aliases as errors, despite the fact that they are valid and the project will still build without issue.
I can find no hard documentation of this specification, but have manually tested to confirm the three primary points of this PR:

  1. Multiple aliases are supported
  2. They are comma separated (semicolons trigger build errors)
  3. They are insensitive to both leading and trailing whitespace.

@dnfadmin
Copy link
Copy Markdown

dnfadmin commented Aug 20, 2020

CLA assistant check
All CLA requirements met.

Comment thread src/OmniSharp.MSBuild/ProjectManager.cs Outdated
if (!string.IsNullOrEmpty(projectReferenceAliases))
{
aliases = projectReferenceAliases.Split(';').ToImmutableArray();
var trimmed = projectReferenceAliases.Split(',');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if both , and ; are supported here, I'm not able to find much documentation however.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not - in the case that the element contains a semicolon-separated list of aliases, the build process will fail:

Roslyn\Microsoft.CSharp.Core.targets(70,5): error MSB6001: Invalid command line switch for "csc.dll". System.ArgumentException: MSB3053: The assembly alias "abc;def" on reference

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just write it in one line

!string.IsNullOrWhiteSpace(projectReferenceAliases)
                ? ImmutableArray.CreateRange(projectReferenceAliases.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.Trim()))
                : ImmutableArray<string>.Empty;

this is exactly what Roslyn uses internally

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - I erred on the side of trying to avoid LINQ for performance, but I do suppose this isn't directly in the hotpath.

Copy link
Copy Markdown
Member

@filipw filipw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@filipw
Copy link
Copy Markdown
Member

filipw commented Aug 21, 2020

@david-driscoll what do you think?

@david-driscoll
Copy link
Copy Markdown
Member

Seems good to me!

@david-driscoll david-driscoll merged commit 33a747e into OmniSharp:master Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants