Skip to content

Simplify our use of an extension.#26670

Merged
jasonmalinowski merged 5 commits intodotnet:masterfrom
CyrusNajmabadi:simplifyExtensions
May 11, 2018
Merged

Simplify our use of an extension.#26670
jasonmalinowski merged 5 commits intodotnet:masterfrom
CyrusNajmabadi:simplifyExtensions

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 7, 2018 04:17
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

Tagging @dotnet/roslyn-ide @jcouv

}

public TService GetLanguageService<TService>() where TService : class, ILanguageService
=> this.Document.GetLanguageService<TService>();
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.

Is this really needed? This only saves about 9 characters.

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.

The benefit here is mostly around the confusion that i run into a lot when trying to use this 'extension' on a 'document' that turns out to actually be a SemanticDocument. i.e. i do:

document.GetLanguageService<ISyntaxFactsService>();

it doesn't work.

i try to add using. it doesn't work. i think something is broken. I then have to poke aaround and realize "oh right, it's this strange type called 'XXXDocument' which isn't actually a Document :)

I personally think it's worth it just for the annoyance factor.

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 personally think every time you have a SemanticDocument you should name it semanticDocument rather than document to avoid the confusion. It's still a different thing a you need to be aware of that.

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.

I prefer this solution.

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 guess I just don't see this as a sustainable approach. Are we going to copy all methods and extensions that Document has and forward them?

Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi CyrusNajmabadi May 7, 2018

Choose a reason for hiding this comment

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

Are we going to copy all methods and extensions that Document has and forward them?

If there are other extensions that we commonly run into problems with? Sure.

It's less an issue with non-extensions because, of course, intellisense just works.

I guess I just don't see this as a sustainable approach.

We can address things on a case by case basis. This is an internal API and we can define it to be as pleasant as necessary for our own use cases.

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'm with @Neme12: if your semanticDocuments are called document, fix that. 😄

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.

@jcouv jcouv self-assigned this May 7, 2018
@jcouv jcouv added the Area-IDE label May 7, 2018
@jcouv jcouv added this to the 15.8 milestone May 7, 2018
@etbyrd etbyrd added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label May 7, 2018
<PackageReference Include="System.Threading.Tasks.Extensions" Version="$(SystemThreadingTasksExtensionsVersion)" />
</ItemGroup>
<ItemGroup>
<Folder Include="RemoveUnusedMembers\" />
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.

Seems odd.

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.

Hrmm.. strange. That was work in another branch. i wonder how that happened. Will address.

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.

Fixed.

Copy link
Copy Markdown
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

The code looks OK, but I despise these sorts of forwarders as they create a maintenance burden. Invoking find references on the "real" method or the extension now will find probably half of all of the hits instead of all of them. I've lost more time on these than they've ever saved me.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

The code looks OK, but I despise these sorts of forwarders as they create a maintenance burden. Invoking find references on the "real" method or the extension now will find probably half of all of the hits instead of all of them. I've lost more time on these than they've ever saved me.

Ok. will remove.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

@jasonmalinowski Have removed forwarding methods. Renamed vars to "semanticDocument" as appropriate.

{
return s => CodeGenerationSymbolFactory.CreateParameterSymbol(
default(ImmutableArray<AttributeData>), RefKind.None, isParams, GetTypeSymbol(s.Compilation, typeFullName, typeArrayRank), parameterName,
default, RefKind.None, isParams, GetTypeSymbol(s.Compilation, typeFullName, typeArrayRank), parameterName,
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.

Not against this, but I do have to admit the old form actually was clearer: it was clear we were creating a parameter with no attributes, as opposed to, well, now it's a default...something?

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.

will fix up!

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.

Have tweaked things.

@jinujoseph
Copy link
Copy Markdown
Contributor

test windows_release_vs-integration_prtest

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

@jinujoseph @jasonmalinowski this can be merged in.

@jasonmalinowski
Copy link
Copy Markdown
Member

@jinujoseph: ask mode approval for this?

@jinujoseph
Copy link
Copy Markdown
Contributor

Approved to merge for 15.8.Preview2

@jasonmalinowski jasonmalinowski merged commit 290ecf5 into dotnet:master May 11, 2018
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

Thanks!

@CyrusNajmabadi CyrusNajmabadi deleted the simplifyExtensions branch May 11, 2018 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved to merge Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants