Comments (14)
Can you clarify what type of feature you're looking to write? It's helpful to have motivation so we can ensure we actually meet your (imagined) needs.
from roslyn.
If you respond to a workspace event by starting the work for some plug-in, you won't be competing with background compilation. Background compilation is built to respond to the same events by accessing the same API's you would, causing the compilations to be built. If your plug-in calls the same API's, you'll get the same compilation instance. Just make sure you are not blocking the async API's and are responsive to cancelling your work in progress when then next workspace event occurs, and possibly for expensive work to start it after a delay so it doesn't interfere with typing.
from roslyn.
For one project I'm working on called Code Connect we display a static call graph to the user at design-time. As the user adds/removes invocations, the call graph updates automatically.
RegisterCodeBlockEndAction looks like it might be useful for this purpose. Currently we've had to build a custom differencing engine to find the differences between two files and then look within method bodies for added/removed invocations.
RegisterSyntaxNodeAction Might also be useful as well. It would allow us to operate only on MethodDeclarationSyntax and completely ignore changes to things like Fields and Comments (for which the WorkspaceChanged event still fires).
I guess it feels like there's a lack of granularity to the changes we can listen to.
from roslyn.
@mattwar My fears about performance might have been misplaced. (We haven't run into any issues with performance or anything).
from roslyn.
The analysis engine is one of those expensive work items that gets kicked off so the IDE can eventually tell you about diagnostics. It would be perfectly reasonable to subvert the use an analyzer to feed information to your plug-in, its just not the typical use for an analyzer. The workspace events are not meant to convey that level of detail, since it does require much additional work to determine. They are there to tell you about changes to the workspace model itself, changes to projects and documents, but not to the level of detail of the semantic changes in your source code.
from roslyn.
The workspace events are not meant to convey that level of detail, since it does require much additional work to determine.
That's understandable. Truth be told, I don't know of any other extensions (other than diagnostics) that would actually need this kind of information and be displaying it in a real-time fashion (ie. reacting to WorkspacedChanged events).
from roslyn.
workspace event still gives you old and new snapshots of the solution which has a way to give you diff. we also provide a way to diff syntax tree so in a sense it provides all the detail, only difference, I think in actual consumption of data, is that analyzer does many plumbing work for you but workspace just give you data and tool, but it is still you who have to do all the plumbing to get to actual information you are interested in.
I guess, we could have another central event mechanism which do things like register for type added, deleted, a kind of node added, removed and etc. so user doesnt need to do all those plumbing himself. and do bunch of performance work to make sure it doesn't affect typing.
from roslyn.
@heejaechang Would the incremental analyzer stuff be good enough for what he wants?
from roslyn.
I think he wanted the simplicity of analyzer API where you just register for a particular kind of event, and these events might be when a declaration node is changed, added or removed. So the incremental analyzer stuff, which is a more general plug-in abstraction that the IDE diagnostic analyzer engine is built on is probably not the right level of abstraction, directly, but may be the right place to build out another engine that does what he wants.
from roslyn.
probably it requires some changes (since it currently loses diff info quite early) but could be supported. but regardless where it is implemented, it seems good thing to support centrally since diff is expensive. if multiple people do diffing themselves, we might waste a lot CPU just for diffing.
from roslyn.
@heejaechang I agree that independent diffing seems like a waste.
However, this should probably only be implemented if other extension creators actually need this functionality. If I'm the only one asking for it, it may not be worth the development time. :)
from roslyn.
I would like to chime in and say that having the ability to know when a document has compiled (event) would be very useful for my process as well.
I'm also developing a hybrid VS-Extension and Diagnostic Analyzer application.
Basically I need to know when it's safe (low performance hit) to use CompilationWithAnalyzers
to determine which of my Analyzers have found Diagnostics and then dress them up.
from roslyn.
@suprak, what does it mean to have a document be compiled? Do you mean when all other analyzers have run? Typically as much work is avoided as possible on individual compilations as new ones are created each keystroke. All semantics (including diagnostics) are computed only on request, asynchronously. The diagnostics engine that VS uses (similar to CompilationWithAnalyzers), is typically the one that asks, but it is built to delay asking until the user is no longer typing.
from roslyn.
Closing this out. We have no plan on doing this and we woudl need a solid API proposal (or even a reasonable sketch), along with a good discussion that shows that such an API can be implemented efficiently and will cause no scaling issues in the sizes of projects roslyn works with.
from roslyn.
Related Issues (20)
- Missing nullability warning for spreads of maybe-null collections HOT 1
- Codegen for spreading a null array does not throw NullReferenceException HOT 9
- [Automated] PRs inserted in VS build main-35206.64
- Collection Expression Generated Types miss the [CompilerGenerated] attribute HOT 4
- Stack overflow when compiling incorrectly formed attribute argument string HOT 3
- Partial properties on struct warn about field ordering HOT 1
- [Automated] PRs inserted in VS build main-35207.120
- False positive IDE0001 when using extern alias
- The [InterceptsLocation] attribute generates a different "data" string for big-endian platforms HOT 7
- Synthesized collection types may result in empty unnecessary `<PrivateImplementationDetails>` class HOT 3
- Generator vs xaml generated files (the "*.g.i.cs") HOT 2
- [Automated] PRs inserted in VS build main-35208.78
- Default literals should not contribute their type from initial binding to best-type in nullable analysis
- CA1003 does not take the return value of an event handler into account
- Visual Studio did not auto fill complete after typing Property in VB.net HOT 4
- Fix formatting not using tabs HOT 2
- Refactor "Move type to file" should re-evaluate file header template
- Decompiled sources resolve wrong type.
- C# compiler integration with new System.Runtime.InteropServices.ExtendedLayoutAttribute
- [Automated] PRs inserted in VS build feature.debugger.main-35209.61
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.