-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VS Code support #38
Comments
I would like to, but currently it is not possible. |
So is this still blocked? Or is it now possible to make a VSCode Roslynator Add-in? |
I don't think it is possible yet, you can check that the issue mentioned above is still open. |
@josefpihrt I've tried following those instructions, but get:
I fixed that by "unblocking" the assemblies in Windows (7). Now I'm getting:
Any suggestions? |
Copying Roslynator.Workspaces.dll to your folder should solve the issue. I have recently move code dependent on Microsoft.CodeAnalysis.CSharp.Workspaces to new assembly Roslynator.Workspaces but I have not update documentation yet. |
Thanks! One other thing to note is that I needed to restart VS Code to get it to load the DLLs. Simply restarting the Omnisharp extension was not sufficient. Maybe that's only the case when there are problems reading assemblies, and it's not a general problem if you manage to get your configuration right on your first try.
|
I'm glad it works! I will update documentation accordingly. |
A PowerShell script to automate this process Write-Host "Download, unzip and enable Roslynator for Visual Studio Code"
$name = "josefpihrt.Roslynator2017"
$url = "https://marketplace.visualstudio.com/items?itemName=$name"
$currentDir = $PSScriptRoot
$file = "$currentDir\Roslynator.zip"
$pattern = "<script class=`"vss-extension`" defer=`"defer`" type=`"application\/json`">(.*?)<\/script>"
$regex = [regex]"(?m)$pattern"
Write-Host "Grab the home page of the $name."
$dom = (New-Object Net.WebClient).DownloadString($url);
if($dom -and $dom -match $pattern)
{
$matches = $regex.Match($dom)
$jsonText = $matches[0].Groups[1]
$json = ConvertFrom-Json $jsonText
$version = $Json.versions[0].version # Parse the json in the page for the latest version number
$parts = $name.Split(".")
$publisher = $parts[0]
$package = $parts[1]
# Assemble the url for the vsix package
$packageUrl = "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/$publisher/vsextensions/$package/$version/vspackage"
Write-Host "Download the vsix package: $packageUrl"
(New-Object Net.WebClient).DownloadFile($packageUrl, $file)
Write-Host "Using $currentDir as the current dir."
Write-Host "Unzip $file."
$shellApp = new-object -com shell.application
$zipFile = $shellApp.namespace($file)
$destination = $shellApp.namespace($currentDir)
$destination.Copyhere($zipFile.items(), 0x14) # overwrite and be silent
Write-Host "Delete VS specific files. Otherwise they will interfere with the MEF services inside OmniSharp."
Remove-Item "$currentDir\Roslynator.VisualStudio.Core.dll","$currentDir\Roslynator.VisualStudio.dll", "$currentDir\Roslynator.VisualStudio.pkgdef"
$omnisharpJsonFilePath = "$env:USERPROFILE\.omnisharp\omnisharp.json";
Write-Host "Create $omnisharpJsonFilePath file."
$omnisharpJson = @"
{{
"RoslynExtensionsOptions": {{
"LocationPaths": [
"{0}"
]
}}
}}
"@ -f $currentDir -Replace "\\","\\"
$omnisharpJson | Out-File "$omnisharpJsonFilePath" -Confirm
Write-Host "Done!"
}
else
{
Write-Host "Failed to find the packageUrl!"
} |
Are these DLLs .NET Standard? I mean, would that work with VS Code on Mac? |
Roslynator targets .NET Standard 1.3 |
I'll give it a try then, and report the results :) |
Roslyn analyzers and code fixes support was merged recently into omnisharp-roslyn so this should now be possible. Until a new preference and an updated stable release of omnisharp-roslyn gets shipped, you'll need to use
I've tested this recently and was able to get both analyzer warnings/errors as well as codefixes. |
Can we remove the blocked label at this point? |
Does anybody know how to pack roslyn libraries as VS Code extension? |
Roslynator for Visual Studio Code is here! https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator |
This is fantastic news! One thing. Currently user-level rules can be set by creating files at %LOCALAPPDATA%\JosefPihrt\Roslynator. This isn't possible for people running VS Code on non-Windows environments. I think you could just update roslyn/common/roslynator.config within the extension to include a couple of extra imports like:
and users would be able to create a config and ruleset in their home directory? |
I should not be necessary to add more paths to roslynator config. It should be sufficient to replace I do not have OSX or Linux installed on my machine but I found this page that lists all values:
|
Is anybody able to test that following code snippet will work on non-Windows environment? using System;
using System.IO;
using System.Diagnostics;
string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string path = @"%LOCALAPPDATA%\JosefPihrt\Roslynator\VisualStudioCode";
path = path.Replace("%LOCALAPPDATA%", localAppDataPath);
// normalize directory separator
path = Path.GetFullPath(path);
// LINUX
Debug.Assert(path == "/home/foo/.local/share/JosefPihrt/Roslynator/VisualStudioCode");
// OSX
Debug.Assert(path == "/Users/foo/.local/share/JosefPihrt/Roslynator/VisualStudioCode"); Thanks. |
When I replaced My Linux is some kind of Debian (9 I think) and my dotnet version is 2.2.300 |
@josefpihrt yes, your way is definitely better than adding more paths. As domints says, the directory normalizing isn't working. You could do something like
Or else I think just using forward slashes as directory separators will work across all platforms? |
You could use Path.PathSeparator for platform aware separators |
@sbmw that's not the good way :) I believe System.IO.Path has field specifying the correct path delimiter. It's I think @divinebovine |
There is Path.Combine to combine path parts. |
@domints you're right, my mistake |
yet it doesn't fix anything :) |
Realy, I haven't read back enough posts... According to this / should work on windows too: |
I think this should work: string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string path = @"%LOCALAPPDATA%/JosefPihrt/Roslynator/VisualStudioCode";
path = path.Replace("%LOCALAPPDATA%", localAppDataPath);
// "/home/foo/.local/share/JosefPihrt/Roslynator/VisualStudioCode" on Linux with user "foo"
Console.WriteLine(path); On Windows there will be mixed slashes but I have checked that it's fine. |
how can i get roslynator to work with macos |
Just install VS Code extension and modify one file according to readme on extension page |
Can’t find it
El El jue, 5 de septiembre de 2019 a la(s) 11:22 a. m., Dominik Szymański <
[email protected]> escribió:
… how can i get roslynator to work with macos
Just install VS Code extension and modify one file according to readme on
extension page
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#38>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACGJYYMVKRECN5ZJGHCAQFLQIEW4HANCNFSM4C7K25NQ>
.
|
Ok the assemblies seem to load but still doesnt work :( Can someone else confirm that works for mac |
I'm going to close this issue. Please file a new issue for anything related to VS Code. Thanks. |
It would great to have Roslynator as Visual Studio Code extension.
The text was updated successfully, but these errors were encountered: