I'm coding Dart/Flutter in VSCode.
How to fix the problem where VSCode did not rename all import when I rename .dart file?
Is this the extensions bug or it's an unimplemented feature?
This is an unimplemented feature.
Originally the APIs in VS Code and the Dart analysis server were not compatible (VS Code would only tell us after the file was renamed, but the Dart server needed to know before the rename to create the correct edits).
This has recently changed - VS Code now has APIs that allow us to hook into the rename before it happens, but it hasn't been implemented in the Dart extension yet.
For notification when it is implemented, you can subscribe to this Dart-Code issue (otherwise, it'll be included in the release notes when it's done).
Related
I have recently switch from Android Studio to VS Code to work on my Flutter projects but I have an issue with it.
VS Code keeps adding "prefix0." before all classes as soon as I am using auto-completion and I didn't find a way to get rid of it.
I have seen that some VS extensions for CSS can auto-prefix some parts of code but I do not have any CSS extensions.
Thanks
It's a bug in Dart Code that happened because it failed to understand another import already exported the class used.
A typical example is, flutter/material.dart was already imported. But by typing Widget, it'd import flutter/widget.dart and with a prefix.
https://github.com/Dart-Code/Dart-Code/issues/1847
This has been fixed. Upgrading your Dart Code and flutter SDK should fix the issue.
The issue is caused by there being one or more duplicates of class names. Check that you do not have classes with the same name imported that may conflict with each other.
Is it possible to interact with the CSharp syntax tree from my own VS code extension? I have an extension which I made in Visual Studio proper which uses the Roslyn Syntax Tree to do a variety of code editing and sorting tasks and I want to migrate it to VS Code.
My naive assumption is that if I can get access to the OmnisharpServer object by reaching into the Omnisharp VS Code Extension I might be able to pull the relevant information out of there. I can get access to the extension itself by calling:
let csextension = vscode.extensions.getExtension('ms-vscode.csharp')
But the extension itself doesn't expose much so I'm wondering if this is the correct methodology? If so, how do I get access to the running server from my own extension?
The only other strategy I have is to run a .net core exe which uses Roslyn to do the analysis, but this seems to be duplicating a problem which must be solved somewhere in the stack.
I don't think there's any way to do this without going through the Omnisharp VSCode Extension / its extension API (unless perhaps the server implements some custom interface). If an API doesn't already exist, you could consider creating a feature request on the issue tracker?
Seems like there is no way to automatically create and manage resx files in VS Code now. Does someone know extension for it?
P.S. Yeah, I know that I can edit resx file as bare xml, but it`s not a right way.
The problem with resx is that it uses a Visual Studio "Custom Tool" to generate the code for the resources, and so requires Visual Studio to function fully.
I've been working on a replacement to resx that should also work from VS Code. It uses json rather than xml to define the resources, but otherwise behaves much like a resx file. The json resources file uses a ".resj" extension, and has a very simple structure. It currently only supports string resources that can be defined either inline in the json, or in an external file reference.
The project is open source on GitHub here:
https://github.com/MarkPflug/Elemental.JsonResource/
This is available as a nuget package "Elemental.JsonResource", currently only pre-release. Simply add this package to your project to enable using resj files. It doesn't add a runtime dependency to your project, everything is done at build-time. My hope is to provide feature-parity with what a resx file can do, but it could be useful even in its current state.
Is it possible to refactor the name of the files in a project and automatically update all the imports, without caring about breaking something each time a file name is changed?
In the same manner as in the JetBrains' products. You change the file name and everything is automatically updated.
Actually you can. Natively on Visual Studio Code (>= v1.28) with import path renaming:
Or with some extension like Move TS.
Sorry, but the answer is just simple: No, you can't.
At least not currently. It's up to the authors of the language modes to implement such things. There is support for the occasional variable refactoring here and thereā¦ And there are some additional extensions in the JavaScript space that support method extraction and stuff, but none of them handles filename refactoring.
This should be easier with VSCode 1.53 (Jan. 2021):
Improved Refactor Participants UI
Extension can participant when use create, move, rename, or delete files.
This is useful to automatically run refactorings, e.g. when renaming a Java file you also need to rename its public class.
There is now unified UI for these participants which allows you to accept, skip, and preview additional changes an extension is making.
I'm using VS Code several days as MonoDevelop replacement in Unity3D on Mac OS. I installed mono via homebrew as suggested to let VS Code to parse system assemblies. Everything works almost great, but I can't navigate definitions that are not part of my code. For example I can't go to definition of System.String or UnityEngine.Vector3 to see methods signatures. MonoDevelop has Assembly browser but I miss it in VS Code. Does anybody know if VS Code has such feature? Maybe I need to setup something for that?
PS: I've posted feature request. If you're interested in this feature vote for it, please.
https://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/14698887-implement-net-assembly-browser
It seems VS Code now can do that with the new extension ms-vscode for C# support. Previously it was recommended to use Legacy C# Support for Unity3D. I don't know exactly if this recommendation is still valid, but I tried to uninstall legacy and to install normal one. After some background work OmniSharp parsed my files and now it can open classes from assemblies! Look at this picture, it has open AnimationCurve class as [metadata]!
I'm trying it with Unity3D 5.5.0b2 beta now, so I'm not sure if this will work with production release of Unity3D. By the way I also removed VSCode plugin from dotBunny out of project as Unity3D 5.5 supports Visual Studio Code self.