kreativjos / csharpextensions Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jchannon/csharpextensions
C# Extensions for Visual Studio Code
License: MIT License
This project forked from jchannon/csharpextensions
C# Extensions for Visual Studio Code
License: MIT License
How do you invoke initialize ctor
from the editor? I can't see how it is done fromm the gif.
Template classes require unit tests
Hi, when I try to create a class, controller or any other thing from submenu it can't because "Weird, but the extension you are currently using could not be found".
OS: EndeavourOS 5.14.2-arch1-2
VSCodium: 1.60 (but the same thing happened with previous versions)
C# Extensions: v1.4.2
I'm a VS Codium user, a FLOSS version of VS Code, it's the same code but without the Microsoft's telemetry and branding.
I want to request if possible to add the C# Extensions extension on the open-vsx.org market to us doesn't need to works with the Microsoft marketplace as is unclear if it's legal to use it on VS Code forks, see here.
Additional info:
Issue Type: Bug
I am not sure what is the source of this performance difficulties but after updating VS Code and running the dotnet run my system get very slow or even locked the screen totally. I am using Omnisharp Extension for C# and also .NET SDK 6.0.200 too which is responsible for executing the dotnet run command in my ubuntu.
Extension version: 1.6.0
VS Code version: Code 1.65.0 (b5205cc8eb4fbaa726835538cd82372cc0222d43, 2022-03-02T11:12:36.248Z)
OS version: Linux x64 5.13.0-30-generic
Restricted Mode: No
Item | Value |
---|---|
CPUs | Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz (4 x 2365) |
GPU Status | 2d_canvas: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off opengl: enabled_on rasterization: disabled_software skia_renderer: enabled_on video_decode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | 5, 5, 3 |
Memory (System) | 3.64GB (0.11GB free) |
Process Argv | --unity-launch --crash-reporter-id 020e1364-b40c-422c-98be-c370c1a3b40a |
Screen Reader | no |
VM | 0% |
DESKTOP_SESSION | ubuntu |
XDG_CURRENT_DESKTOP | Unity |
XDG_SESSION_DESKTOP | ubuntu |
XDG_SESSION_TYPE | x11 |
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
pythonvspyl392:30443607
pythontb:30283811
pythonvspyt551:30345470
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
testflightcf:30433671
vsc1dst:30438360
pythonvs932:30410667
wslgetstartedc:30433508
vsclayoutctrt:30448491
vsrem710:30416614
dsvsc009:30440023
pythonvsnew555cf:30442237
vsbas813:30436447
vscscmwlcmc:30438804
vscgsvidc:30447482
helix:30440343
I didn't tested but I think this MVCProject.Models
will generate an compiler error for everybody.
Originally posted by @PoLaKoSz in #30 (comment)
Optimize the code for a more current version of the vscode extension api.
Currently, template classes cannot really be unit tested, because UI input & IO is done in internal functions.
These parts should be separated (if possible, SOLID).
Log output:
[2021-10-27 01:08:48.597] [exthost] [error] Error: Illegal value for `line`
at a._lineAt (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:1174)
at Object.lineAt (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:95)
at e.default.findConstructorBodyStart (%USERPROFILE%\.vscode\extensions\kreativ-software.csharpextensions-1.5.2\dist\extension.js:2:112512)
at e.default.getInitializeFromCtorCommand (%USERPROFILE%\.vscode\extensions\kreativ-software.csharpextensions-1.5.2\dist\extension.js:2:112187)
at o (%USERPROFILE%\.vscode\extensions\kreativ-software.csharpextensions-1.5.2\dist\extension.js:2:107606)
at e.default.provideCodeActions (%USERPROFILE%\.vscode\extensions\kreativ-software.csharpextensions-1.5.2\dist\extension.js:2:107678)
at T.provideCodeActions (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:172424)
at %USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:196984
at xe._withAdapter (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:191024)
at xe.$provideCodeActions (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:196960)
at i._doInvokeHandler (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:13802)
at i._invokeHandler (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:13486)
at i._receiveRequest (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:12097)
at i._receiveOneMessage (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:10826)
at %USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:8922
at a.fire (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
at l.fire (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:15990)
at %USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:30514
at a.fire (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
at l.fire (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:15990)
at u._receiveMessage (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:21260)
at %USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:18138
at a.fire (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
at w.acceptChunk (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:13351)
at %USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:12699
at Socket.v (%USERPROFILE%\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:13465)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
Caused somewhere in codeActionProvider (a new Position
call)
Via code action / context menu / command.
When a new C# element (class/interface/enum etc...) is created, the end of line/file is always set to CRLF. It would be nice whether the new element maintains what currently is set globally for the IDE (in my case LF).
Test scripts were removed because of optimization of extension load time. They should be fixed and re-added.
Some integration tests are required, to ensure existing features keep working.
I'm using VSCode with WSL2 Remote Host in my Windows10.
When I try to run New C# Class and insert the filename in the input text I have the problem below and the new class are not created.
For me, this problem doesn't happen in windows without wsl.
[2020-04-03 10:50:13.059] [exthost] [error] [kreativ-software.csharpextensions] provider FAILED
[2020-04-03 10:50:13.061] [exthost] [error] Error: Illegal argument: line must be non-negative
at Object.t.illegalArgument (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:11:190)
at new f (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:395:168)
at new f (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:394:558)
at CodeActionProvider.getInitializeFromCtorCommand (/home/mayconfsbrito/.vscode-server/extensions/kreativ-software.csharpextensions-1.3.2/out/src/codeActionProvider.js:172:63)
at addInitalizeFromCtor (/home/mayconfsbrito/.vscode-server/extensions/kreativ-software.csharpextensions-1.3.2/out/src/codeActionProvider.js:18:30)
at CodeActionProvider.provideCodeActions (/home/mayconfsbrito/.vscode-server/extensions/kreativ-software.csharpextensions-1.3.2/out/src/codeActionProvider.js:22:9)
at /home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:605:864
at /home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:54:345
at new Promise (<anonymous>)
at Object.t.asPromise (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:54:317)
at D.provideCodeActions (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:605:835)
at /home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:628:631
at V._withAdapter (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:623:832)
at V.$provideCodeActions (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:628:609)
at p._doInvokeHandler (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:707:464)
at p._invokeHandler (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:707:156)
at p._receiveRequest (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:705:766)
at p._receiveOneMessage (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:704:623)
at /home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:702:791
at l.fire (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:48:845)
at v.fire (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:191:325)
at /home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:870:104
at l.fire (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:48:845)
at v.fire (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:191:325)
at t.PersistentProtocol._receiveMessage (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:195:717)
at /home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:192:897
at l.fire (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:48:845)
at p.acceptChunk (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:188:897)
at /home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:188:249
at Socket.t (/home/mayconfsbrito/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/server/remoteExtensionHostProcess.js:197:232)
at Socket.emit (events.js:200:13)
at addChunk (_stream_readable.js:294:12)
at readableAddChunk (_stream_readable.js:275:11)
at Socket.Readable.push (_stream_readable.js:210:10)
at TCP.onStreamRead (internal/stream_base_commons.js:166:17)
After the update, the extension is giving an error when trying to create a new .cs file.
I'm using Linux [Debian 11]
Create a gif in the readme for enum generation.
If the project has enabled ImplicitUsings, do not include the optional usings (because they are included implicitly).
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
hello
i have a problem
when i click the button to create new class for c# in visual studio code
nothing happen
how can i solve this problem?
thank you for support.
It would be nice to have a new menu item in 'New C# -> Test Class` when a folder in a test project is selected.
The test class should be comply to the test framework used.
Hi, there's an interesting project for API creation in ASP.NET 6. Here's the link to the Visual Studio Extension which creates a few files needed for that. I think it would be worth adding it to our menu as "FastEndpoint". So all it does is it creates 4 files in the folder. Here's how it looks in Visual Studio
Split replacement of ${namespaces}
into mandatory and optional in template.ts.
in the cshtmlTemplate.ts
const cshtmlFilePath = ${pathWithoutExtension}.xaml
;
const csFilePath = ${pathWithoutExtension}.xaml.cs
;
Causes a razor file format problem to be created
Created based on this issue: #19
Which will result in all newlines being replaced by 'auto'.
Extract all regular expressions from their functions.
Hey guys,
please implement a configuration for RootNamespace detection. All my (50+) repositories are organized in a structure like that:
+ [src]
+ [ProjectName]
- Program.cs
- ProjectName.csproj
- ProjectName.sln
When creating a new c# File in Folder "ProjectName" the Namespace is always set to src.ProjectName. In the past, this repositories worked perfectly and the extension detected the correct Namespace ProjectName.
This issues forces me to add the RootNameSpace Tag in every csproj file in all my repositories! Please solve this!
regards,
marcel
Find out why the extension loads slower than others and improve on the startup time.
ty.♥
please can you add option to create new controller and views
"This extension traverses up the folder tree to find the project.json or *.csproj and uses that as the parent folder to determine namespaces."
Seems it doesn't work anymore.
Hi all!
The past 6 months have been a bit busy in my life, and I am not the best in communicating these things.
I have tried to review a few pull-requests, but I cannot get the vscode test platform running in a correct way since Oktober 2020.
If someone knows enough about nodejs and vscode extensions to review pull-requests, I'd gladly give them access to do so.
The extension.ts file is getting a bit too complicated / bloated.
It should be refactored into multiple files, with the extension.ts only containing extension contributions (without their content)
Hi KreativJos,
Thanks for updating this lovely extension.
I encountered a problem where the namespace becomes a dot when the class name is the same or begins with the project name.
Could you please take a look at this issue?
https://www.youtube.com/watch?v=ciikZLQM2hk
Thanks and Regards
Hi,
First, I am using vscode in linux (Ubuntu 20.04) The extension does not work anymore. When I try to create any kind of file (class, interface, etc), I get an error message:
Errot trying to create file '/pathtofile/file' from template '/pathtotemplate/template.tmpl'
The original extension from jchannon still works.
Thanks!
I have few projects in one solution that import common settings from the same file.
For example SomeProject1.csproj
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\Configurations.targets" />
<!-- Other project-specific settings -->
</Project>
Configurations.targets
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>Enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<!-- Other common settings -->
</Project>
Extension in this configuration of projects don't detect .Net 6.0 and parameter "csharpextensions.useFileScopedNamespace" doesn't work as expected
Working with .NET, sometimes you want to copy a certain file, or files, to the output directory so they can be read or used at runtime. This is particularly useful in unit tests or for runtime assets etc.
This is typically done by adding the following code to the project file:
<ItemGroup>
<None Update="file.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
In Visual Studio, this can be easily added with the properties dialog, as here https://stackoverflow.com/a/10828462/6939988.
But, I always forget this syntax and have to look it up on StackOverflow everytime.
Therefore, it would be nice if this extension provided a simple menu item that is available upon right-clicking on a file in the workspace i.e. "Copy to output directory" which has another list to select "Always", "PreserveNewest" or "Never", and clicking it adds the relevant code (like above) to the project file.
Happy to do the PR for this if you think it adds value/makes sense for this extension.
.csproj
file allows to specify default namespace. For example:
<RootNamespace>My.Namespace</RootNamespace>
When it's specified then Visual Studio (not Code) will use this namespace when new class or interface is created. Would be nice if csharpextensions
will support this setting as well.
It show "Error trying to create file" while trying to create razor page
Unit test all used settings:
Test for:
Thank you for being part of the Open VSX community by adding your extensions to the Open VSX Registry. Please note that the service was recently transferred to the Eclipse Foundation and urgent action on your part is needed so we can continue to list your extensions. To ensure uninterrupted service, please sign the Eclipse Publisher Agreement as soon as possible.
Regrettably, if not soon, your extensions will be delisted and will no longer appear on the site nor be available via the API. If you sign at a later date, your extensions will then be re-activated. The signing process is explained in the Wiki (steps 1 and 2).
Please also note that all extensions MUST have a license in order to be listed.
Claiming ownership of the namespace for your extension(s): We also recommend you do this. To find out how to do this, see:
https://github.com/eclipse/openvsx/wiki/Namespace-Access
Useful links:
Eclipse Publisher Agreement
Eclipse Foundation Open VSX Registry Frequently Asked Questions (FAQ)
More details are in these recent blog posts:
https://blogs.eclipse.org/post/brian-king/open-vsx-registry-under-new-management
https://blogs.eclipse.org/post/brian-king/new-era-open-vsx-registry
Today, there’s growing momentum around open source tools and technologies that support Visual Studio (VS) Code extensions. Leading global organizations are adopting these tools and technologies. This momentum has spurred demand for a marketplace without restrictions and limitations. Thanks for joining us on this journey as we continue to build the Open VSX community.
We look forward to continued innovation from you in 2021!
In order to coordinate with the styleguide on my team, it's often necessary to convert var
s in my code to explicit types and vice versa, that I don't always get right on my first try.
It would be very useful to have a quickfix for toggling this.
Desired behaviour: If the cursor is over a var
type in a declaration, pressing ctrl + .
will offer to make its type explicit.
(I see that the reverse, turning an explicit type into var, is already being offered by something, the Microsoft C# extension I think.)
The vscode test framework should be updated to the most recent version.
https://code.visualstudio.com/api/working-with-extensions/testing-extension
[warning] [Deprecation Warning] 'CodeActionProvider.provideCodeActions - return commands' is deprecated. Return 'CodeAction' instances instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.