فعالسازی امکانات Refactoring افزونهی Roslynator در VSCode
نویسنده: وحید نصیری
تاریخ: ۱۳۹۶/۱۱/۲۲ ۱۳:۴۵
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
%USERPROFILE%/.omnisharp
{
"RoslynExtensionsOptions": {
"LocationPaths": [
"C:\\lib\\roslynator"
]
}
}
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!"
} PS D:\Prog\1396\RoslynatorVSCode> .\update.ps1 Download, unzip and enable Roslynator for Visual Studio Code Grab the home page of the josefpihrt.Roslynator2017. Download the vsix package: https://marketplace.visualstudio.com/_apis/public/gallery/publishers/josefpihrt/vsextensions/Roslynator2017/1.7.0/vspackage Using D:\Prog\1396\RoslynatorVSCode as the current dir. Unzip D:\Prog\1396\RoslynatorVSCode\Roslynator.zip. Delete VS specific files. Otherwise they will interfere with the MEF services inside OmniSharp. Create C:\Users\Vahid\.omnisharp\omnisharp.json file. Confirm Are you sure you want to perform this action? Performing the operation "Output to File" on target "C:\Users\Vahid\.omnisharp\omnisharp.json". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Done!
{
"RoslynExtensionsOptions": {
"EnableAnalyzersSupport": true,
"LocationPaths": [
]
}
}
روش فعالسازی آن در تنظیمات VSCode
"omnisharp.enableRoslynAnalyzers": true
%USERPROFILE%\.omnisharp
{
"RoslynExtensionsOptions": {
"enableDecompilationSupport": true,
"enableAnalyzersSupport": true,
"enableImportCompletion": true,
"enableAsyncCompletion": true,
"documentAnalysisTimeoutMs": 600000,
"LocationPaths": [
"c:/Users/Vahid/.vscode/extensions/josefpihrt-vscode.roslynator-3.2.2/roslyn/common",
"c:/Users/Vahid/.vscode/extensions/josefpihrt-vscode.roslynator-3.2.2/roslyn/analyzers",
"c:/Users/Vahid/.vscode/extensions/josefpihrt-vscode.roslynator-3.2.2/roslyn/refactorings",
"c:/Users/Vahid/.vscode/extensions/josefpihrt-vscode.roslynator-3.2.2/roslyn/fixes"
]
}
}