Skip to content

Add API Compilation.ClassifyCommonConverstion#27093

Merged
gafter merged 1 commit intodotnet:masterfrom
gafter:master-ClassifyCommonConversion
May 26, 2018
Merged

Add API Compilation.ClassifyCommonConverstion#27093
gafter merged 1 commit intodotnet:masterfrom
gafter:master-ClassifyCommonConversion

Conversation

@gafter
Copy link
Copy Markdown
Member

@gafter gafter commented May 24, 2018

Also add

Note that a preliminary review of drafts of this API were in #26719
This is the version of the API approved by CodeAnalysis review group 2018-05-23.

@dotnet/roslyn-compiler Please review.
/cc @dotnet/roslyn-ide for removal of no-longer-needed APIs.

Also add
- CommonConversion.IsImplicit
- Compilation.HasImplicitConversion
Fixes dotnet#9461
@gafter gafter added Concept-API This issue involves adding, removing, clarification, or modification of an API. Area-Compilers labels May 24, 2018
@gafter gafter added this to the 15.8 milestone May 24, 2018
@gafter gafter self-assigned this May 24, 2018
@gafter gafter requested review from a team May 24, 2018 00:45
/// either <paramref name="fromType"/> or <paramref name="toType"/> is null, or
/// if no such conversion exists.
/// </summary>
public bool HasImplicitConversion(ITypeSymbol fromType, ITypeSymbol toType)
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.

We're not super consistent, but the common pattern in Compilation appears to be throwing if parameters are null. Why not here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because this is what is most useful for clients of this API. I submit that bool-returning methods can be resilient against null (no conversion exists to or from no type):

        public new bool ContainsSyntaxTree(SyntaxTree syntaxTree)
        {
            return syntaxTree != null && _syntaxAndDeclarations.GetLazyState().RootNamespaces.ContainsKey(syntaxTree);
        }

Unfortunately, C# and VB do not always agree (e.g. on this API).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See #27095

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like this method should either go away entirely, or just be an extension method... doesn't seem like it really needs to be in Compilation. Your call :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was moved into Compilation during the API review. There are no extension methods on Compilation in the CodeAnalysis assembly, because such methods can just be placed in the API.

@333fred
Copy link
Copy Markdown
Member

333fred commented May 24, 2018

Done review pass (iteration 1)

@gafter
Copy link
Copy Markdown
Member Author

gafter commented May 24, 2018

@333fred Do you have any further comments? (Your API question is one that was discussed and agreed at the API design review yesterday).

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

I like this appraoch a lot :)

@gafter
Copy link
Copy Markdown
Member Author

gafter commented May 24, 2018

test windows_release_unit32_prtest please

@gafter
Copy link
Copy Markdown
Member Author

gafter commented May 24, 2018

@dotnet/roslyn-compiler May I please have a couple of reviews of the implementation of this new compilation API?

@gafter gafter requested a review from cston May 25, 2018 17:42
@gafter
Copy link
Copy Markdown
Member Author

gafter commented May 25, 2018

@dotnet/roslyn-ide Can I please have a review of the IDE changes in this PR?

Copy link
Copy Markdown
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (Iteration 1)

@gafter gafter merged commit 0d83995 into dotnet:master May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved to merge Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants