C# Source Generators create codefix suggested edit - code-generation

I have a source generator which creates a warning, I know how this warning would be fixed and could apply this fix automatically if given the opportunity.
https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.md seems to suggest it is possible or was at least in consideration at some point:
This works in the same way as analyzers and codefix testing. You add a class like the following:
Another hint that this should work is here
https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/
How do I ship my own Source Generator?
Source Generators can be shipped as NuGet packages, just like Analyzers today. In fact, they use the same “plumbing” as Analyzers. If you’ve ever shipped an Analyzer, then you can easily ship a Source Generator.
If you then read Visual Studio's documentation: https://learn.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2019
Hidden' severity versus 'None' severity
Hidden severity rules that are enabled by default differ from disabled or None severity rules in certain aspects.
If any code fix is registered for a Hidden severity rule, Visual Studio offers the fix as a light bulb code-refactoring action even if the hidden diagnostic isn't visible to the user. The fix isn't offered
if the severity rule is disabled as None. Hidden severity rules can be bulk configured by entries that set rule severity of multiple analyzer rules at once in an EditorConfig file. None severity rules can’t be configured this way. Instead, they must be configured through entries that set rule severity in an EditorConfig file for each rule ID.
Both of these bits of information about Visual Studios codefix's suggest you should be able to take a second diagnostic that includes the autocorrect replacement text but I can't find any information about how that is done as there would need to be some metadata to link them together?
Does anyone have more information on how this could be done?

Related

Is it possible to rank search results lower based on the file path in VS Code?

There are certain files that I'd like to always appear below other files in the search results. E.g. generated files and tests. I don't want to exclude them from the search results. Usually, I'd be searching for files that aren't generated or tests. There's a setting called "Search: Sort Order", but none of them work because the files I want to de-rank are interspersed with other files.
Is there a setting or extension that could work?
I'm not sure this is possible with the current LTS version of Visual Studio Code.
However, if you want the feature to be available, and many people also want it, you can make a new GitHub Issue with the tag feature-request. Microsoft might review it (if there are many people who want it too), and add the feature.
Edit: This link at Visual Studio Code might help. Click here for the documentation.

How can I show all non-theme extensions installed in VSCode?

I have many themes installed in visual studio code. Now and then, I want to be able to look at all the other extensions (everything that is not a theme) so that I might disable one or two.
How can I do this? The documentation shows how to use filters, but I don't see any way to tell it to NOT show something.
This filter shows me all the installed themes:
#installed #category:themes
I've tried using ~ and ! and NOT in various places, just guessing there might be a feature implemented to understand something like that, but they don't work.
This is a know issue, currently at the backlog waiting for development.
You can track it here.
This need has been raised here. Note in the last comment:
#49374 is tracking the feature of having exclusion filters for your scenario of seeing non theme extensions.

Test for compatibility in Matlab

I'm working with an open source Matlab toolbox which, according to its creators, is compatible for versions of Matlab over 7.6, i.e., R2008a. I tried to run it in R2011b and it threw the exception: Undefined variable "Simulink" or class "Simulink.Mask.create"
Since:
1- Simulink is installed and functional in this R2011b;
2- I have already run the same code in a R2014b successfully;
I conclude that this is a problem of compatibility -In contrast to their claim, their code is compatible for some version later than R2011b-.
I wish I could contribute with them by directly telling them, not only that their code is not compatible with Matlab 7.6, but also the earliest version in which the statement associated with Simulink.Mask.create would run.
So, in precise terms, MY QUESTION IS: Given a command, built-in function, namespace resolution sequence, or whatever feature that I can find in some version of Matlab, what is the way of knowing what is the earliest version in which that feature is active?
I have tried http://www.mathworks.com/help/simulink/release-notes.html which is not searchable or navigable the way I wish it was.
This is a common problem. This page talks of the same problem - claiming that there is no good solution... It does however come with a smart way of searching through the release notes:
Click on the bottommost unexpanded release, to expand the it.
Click on "expand all" all link to expand all link just below.
If any unexpanded releases remain goto 1.
Now use the browser search functionality (often ctrl+f) to search the fully expanded page.
Good luck!
EDIT:
To see older releases too you need to start with the following step:
0: Click the link in the bottom saying "View release notes for older releases".
And then continue like above.
I don't think there is a straightforward way to find what you want.
In my opinion you have to do it manually for each version of MATLAB
in order to find is certain feature supported or not.
Some feature may be obsolete or may exist a bug.
So the best way to do is :
A) Look at particular version of relase notes, for example ,let say R2011a
New Features, Bug Fixes, Compatibility Considerations
click on "expand all", then use find "your keyword" in your browser
( be careful about case sensitivity)
You also have "Compatibility Summary", search it, too.
B) If something is very important and you are sure there is an issue
just email to customer service and ask for further steps
and who may contact further.

Eclipse Custom Content Assist Based on Default Java Content Assist results

I'm in the process of implementing a task tool. As a part of this I'm making an Eclipse plug-in to reflect certain code level issues.
In the Eclipse plug-in my aim is to attach some visual aids to different Java elements according to their host task's status. I've been successful in adding multi-colored markers to the vertical ruler of the default Java editor as well as the resource icons displayed by the Overview. However, I have not been able to change the icons in the Java content assist.
At first I thought that by using the extension point org.eclipse.ui.decorators and having its enablement set as org.eclipse.jdt.core.IJavaElement, the content assistant would also be affected, as this was the case with element icons in the Overview. I've tried several other enablement classes ranging all the way to ICompletionProposal.
Since this approach, a bunch of others and extending the default Java content assist, won't work. I've decided to implement my own content assist.
The idea now is to somehow take the default Java content assist's results and run some checks on the proposed elements and in case of a match change the icon displayed in the content assist, to reflect the associated task's level.
I've tried to look through the source for Eclipse's default Java editor and the Mylyn project, but I can't understand how they provide their Java content assists and how to access / redo them.
The end result I'm looking to get: LINK
The actual question
When providing a new content assist (category) for the default Java editor in Eclipse, how does one get a list of proposals that the default Java content assistant would produce for that point?
My first question and certainly a long intro, please let me know if I should edit this in any way and most importantly thanks for all the help in advance!
-J3lly
Take a look at the following extension point : org.eclipse.jdt.ui.javaCompletionProposalComputer
To implement your own Content Assist you have to write a class that implements org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer. In your case, since you want to modify the behavior of the default Java Content Assist, you should override one of the internal implementations org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer, org.eclipse.jdt.internal.ui.text.java.JavaAllCompletionProposalComputer or any other implementation depending on which Content Assist you want to modify.
Now all you have to do is override the method computeCompletionProposals which returns the list of completion proposals. The overridden method should call super.computeCompletionProposals(...) to get the default completion proposals, then you can modify them according to your needs.

Exclude ReSharper error for "Resource not found" inside Views

I have an MVC2 application and use ReSharper 6.1 - I've heavily customised the Code Inspection Severity and edited what it decides to show as errors, warnings, suggestions and hints, but I cannot seem to stop it from telling me that a specific resource is missing when utilising a HTMLHelper.
So, for instance:
<img src="<%:Url.Content("~/Resources/Image12345.jpg")%>" />
I get an error on every line similar to the above telling me that the path above does not exist - which at design time it does not, but during the build process all of these views are XCOPY'd to a location which contains all of the resources, such as the images, so at the point of running the application all of this path resolution is correct. Because of working in a team of people, some of which are new to ReSharper, I wanted to exclude this error from appearing as it may cause colleagues of mine to start fiddling with something that isn't broken.
ReSharper obviously doesn't know that this isn't an issue and it has no way of knowing which is why I want to turn off this specific bit of analysis. I've found on the whole that ReSharper is massively customizable and in version 6.1 under Inspection Severity there are some new MVC options, which have proved useful - but I can see no way of turning off the inspection for this.
Anybody have any ideas?
There are few options, press ALT+ENTER.
Suppress inspection "Path Error" with comment. You can suppress whole block of code, not only each of tag.
Suppress inspection "Path Error" at all at whole project.
There is new feature of 6.1 - path mapping, but it seems broken in conjunction with MVC.
Set to ignore that specific error by:
Open Soultion Errors Window by ReSharper->Windows->Soultion Errors Window.
Right-click annoying error and select Ignore Error.
See answer for another error for more explanation.
Well - It seems that this particular type of inspection is not currently catered for. I'll see if I can request it with JetBrains and hopefully more granular MVC inspection will be included in the future.
Cheers guys