Comments (14)
I bring it up because compiler has UseArityForGenericTypes as an internal option currently.
from roslyn.
in cases like this, where you're making a domain-specific key, our recommendation usually becomes: figure out what your domain needs, and extract out of the symbols. We're unlikely to add a feature (like for methods) that nothing else uses. We end up just chasing how the feature works, as opposed to some facility intrinsic to what the language is modeling.
from roslyn.
Exactly, that's what I'm doing. 👍 I'll close this as I think I have what I need.
from roslyn.
@ericstj I'm not quite getting the use case. CAn you flesh out the example more, including where generics are used today, and why the actual type argument values are a problem?
from roslyn.
Here are two cases:
https://github.com/dotnet/sdk/blob/26854d4fe75c45af1c17e696d98ca4c8b509f170/src/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompatibility/Comparing/SymbolEqualityComparer.cs#L40
https://github.com/dotnet/roslyn-analyzers/blob/b07c100bfc66013a8444172d00cfa04c9ceb5a97/src/PublicApiAnalyzers/Core/Analyzers/DeclarePublicApiAnalyzer.cs#L74
It's actually non-breaking to change the name of a type parameter, however we'd like to make that an optional rule that folks can enable. To do this we'd like to have a symbol representation that omits the generic parameter names, but still represents the arity. That way we can create a key that represents the API without including non-essential information (parameter names). It's a similar scenario to the format of typeof
and the docID syntax - which both omit the generic parameter names. If there's an existing API we should be using here I can also investigate changing how we produce the key string.
from roslyn.
I'd probably prefer emitting as List`1
. So something about wanting emitting the rarity instead.
from roslyn.
I'm not picky on the precise format here. It just needs to represent the number of generic parameters and not their names.
from roslyn.
Maybe we can just use GetDocumentationCommentId. That does format like we'd want. I might give it a try and see if its' reasonable.
from roslyn.
One downside I see for swapping to different methods for this is that we call it a lot. So much that I've been thinking about adding a cache for these strings. It would be nice if ISymbol would cache some of these. Maybe we should wrap all the ISymbol interfaces and add caching for the methods/properties we call the most.
from roslyn.
Looks like GetDocumentationCommentId isn't sufficient as this omits return value. I think exposing UseArityForGenericTypes would work for us.
from roslyn.
Ok I tested out using UseArityForGenericTypes
by setting through reflection. This worked well for classes, but not methods. I would also like a similar setting for methods.
from roslyn.
I was able to make this work by combining the DocId with the DocID of the type/return-value for members. This gives me what I need.
from roslyn.
Actually, I see there's a SymbolDisplayParts API, that might be a better way to handle this. I'll experiment with that.
from roslyn.
And with the SymbolDisplayParts, you can see which are TypeParameter symbols. And you could elide those or transform them into anything you want.
from roslyn.
Related Issues (20)
- No completion for lambda parameter type if attribute is present
- Wrong IDE0055 in combination with CRLF, XML comment and preprocessor directive HOT 2
- Completion tooltips are not displayed sometimes HOT 2
- IDE0200 recommends change that increases allocation HOT 8
- Inlining collection expression local into a spread could inline more aggressively HOT 1
- How to have deterministic build inside git? HOT 4
- The assembly update failed. HOT 8
- Prefix "extension" for "extension method" in Japanese must be "拡張", not "拡張子" HOT 4
- Narrowing conversion required for future `Option Strict On` should not be marked as redundant when `Option Strict Off` at least by default HOT 14
- C# Dictionary key initializer statement can throw a surprising KeyNotFoundException (by omitting 'new T') HOT 3
- Extract New Class Refactoring Request
- RegisterAdditionalFileAction doesn't seem to fire when such a file is frontmost HOT 2
- Debug assertion failure in MethodSymbol.AsMember when called from Binder.UnwrapCollectionExpressionIfNullable
- Debug assertion failure in MethodSymbol.AsMember when called from NullableWalker.GetNullableOfTValueSlot HOT 2
- Include Runtime information in S_COMPILE3 HOT 1
- [Automated] PRs inserted in VS build main-34822.156
- Adjust `CompoundUseSiteInfo<TAssemblySymbol>.MergeAndClear` for discarding diagnostic bag
- Cache contains wrong information about COM interop after changes in the COM interfaces HOT 5
- Confusing warning and unintuitive behavior of `is` operator applied to an instance of a `ref struct` HOT 1
- [Automated] PRs inserted in VS build feature.debugger.main-34823.102
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roslyn.