Skip to content
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

Migrate scripts to PowerShell #1111

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Guidelines for contributing to the Roslynator repo.
## Coding Style

* **DO** follow [.NET Runtime Coding Style](https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/coding-style.md) (except using `s_` and `t_` prefix for field names).
* **DO** install [Roslynator for Visual Studio](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2019) and follow suggestions.
* **DO** install extension for VS/VS Code and follow suggestions.
* As an alternative you can run script `tools/cli_fix.ps1`.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- [CLI] Bump Roslyn to 4.6.0 ([#1106](https://github.com/josefpihrt/roslynator/pull/1106)).
- Migrate all scripts to PowerShell ([#1111](https://github.com/josefpihrt/roslynator/pull/1111)).

### Fixed

Expand Down
33 changes: 22 additions & 11 deletions src/CommandLine.DocumentationGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,33 @@ private static void Main(params string[] args)
"Roslynator Command-line Tool",
commands.OrderBy(f => f.Name, StringComparer.InvariantCulture));

string destinationDirectoryPath = null;
string dataDirectoryPath = null;

if (Debugger.IsAttached)
{
destinationDirectoryPath = (args.Length > 0) ? args[0] : @"..\..\..\..\..\docs\cli";
dataDirectoryPath = @"..\..\..\data";
}
else
if (args.Length < 2)
{
destinationDirectoryPath = args[0];
dataDirectoryPath = @"..\src\CommandLine.DocumentationGenerator\data";
Console.WriteLine("Invalid number of arguments");
return;
}

string destinationDirectoryPath = args[0];
string dataDirectoryPath = args[1];

string[] ignoredCommandNames = (args.Length > 2)
? Regex.Split(args[2], ",")
: Array.Empty<string>();

destinationDirectoryPath = Path.GetFullPath(destinationDirectoryPath);
dataDirectoryPath = Path.GetFullPath(dataDirectoryPath);

Console.WriteLine($"Destination directory: {destinationDirectoryPath}");
Console.WriteLine($"Data directory: {dataDirectoryPath}");

foreach (Command command in application.Commands)
{
if (ignoredCommandNames.Contains(command.Name))
{
Console.WriteLine($"Skip command '{command.Name}'");
continue;
}

string commandFilePath = Path.GetFullPath(Path.Combine(destinationDirectoryPath, $"{command.Name}-command.md"));

using (var sw = new StreamWriter(commandFilePath, append: false, Encoding.UTF8))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"CommandLine.DocumentationGenerator": {
"commandName": "Project",
"commandLineArgs": "\"../../../../../docs/cli\" \"../../../data\""
}
}
}
8 changes: 8 additions & 0 deletions src/Core/DiagnosticIdPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public static string GetPrefix(string id)
{
return IL;
}
else if (HasPrefix(ISB))
{
return ISB;
}

break;
}
Expand Down Expand Up @@ -120,6 +124,10 @@ public static string GetPrefix(string id)
{
return SX;
}
else if (HasPrefix(SYSLIB))
{
return SYSLIB;
}

break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Core/WellKnownDiagnosticIdPrefixes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal static class WellKnownDiagnosticIdPrefixes
public const string ENC = nameof(ENC);
public const string IDE = nameof(IDE);
public const string IL = nameof(IL);
public const string ISB = nameof(ISB);
public const string RCS = nameof(RCS);
public const string ROS = nameof(ROS);
public const string RECS = nameof(RECS);
Expand All @@ -30,6 +31,7 @@ internal static class WellKnownDiagnosticIdPrefixes
/// </summary>
public const string SX = nameof(SX);

public const string SYSLIB = nameof(SYSLIB);
public const string U2U = nameof(U2U);
public const string VB = nameof(VB);
public const string VSSDK = nameof(VSSDK);
Expand Down
3 changes: 2 additions & 1 deletion src/Documentation/Extensions/SymbolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ public static ImmutableArray<SymbolDisplayPart> ToDisplayParts(this ISymbol symb
if (name.StartsWith("op_", StringComparison.Ordinal)
&& i < length - 2
&& parts[i + 1].IsSpace()
&& parts[i + 2].Kind == SymbolDisplayPartKind.MethodName)
&& parts[i + 2].Kind == SymbolDisplayPartKind.Operator
&& parts[i + 2].Symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator })
{
parts = parts.Replace(parts[i + 2], SymbolDisplayPartFactory.MethodName(name.Substring(3), parts[i + 2].Symbol));
parts = parts.RemoveRange(i, 2);
Expand Down
3 changes: 2 additions & 1 deletion src/Documentation/SymbolDefinitionWriterHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ public static (IMethodSymbol accessor1, IMethodSymbol accessor2) GetAccessors(IS
case "operator":
{
if (Peek(j + 1).IsSpace()
&& Peek(j + 2).Kind == SymbolDisplayPartKind.MethodName)
&& Peek(j + 2).Kind == SymbolDisplayPartKind.Operator
&& Peek(j + 2).Symbol is IMethodSymbol { MethodKind: MethodKind.UserDefinedOperator })
{
j += 3;
return (i, j, parts[j].Symbol);
Expand Down
21 changes: 21 additions & 0 deletions src/Roslynator.Analyzers.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"solution": {
"path": "Roslynator.sln",
"projects": [
"Analyzers.CodeFixes\\Analyzers.CodeFixes.csproj",
"Analyzers\\Analyzers.csproj",
"CSharp.Workspaces\\CSharp.Workspaces.csproj",
"CSharp\\CSharp.csproj",
"CodeAnalysis.Analyzers.CodeFixes\\CodeAnalysis.Analyzers.CodeFixes.csproj",
"CodeAnalysis.Analyzers\\CodeAnalysis.Analyzers.csproj",
"Common\\Common.csproj",
"Core\\Core.csproj",
"Formatting.Analyzers.CodeFixes\\Formatting.Analyzers.CodeFixes.csproj",
"Formatting.Analyzers\\Formatting.Analyzers.csproj",
"VisualBasic.Workspaces\\VisualBasic.Workspaces.csproj",
"VisualBasic\\VisualBasic.csproj",
"Workspaces.Common\\Workspaces.Common.csproj",
"Workspaces.Core\\Workspaces.Core.csproj"
]
}
}
28 changes: 0 additions & 28 deletions src/Roslynator.slnf

This file was deleted.

16 changes: 11 additions & 5 deletions src/Tools/CodeGenerator/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ if an analyzer is enabled but required option is not set. ROS0003 is disabled by

## Default Configuration

If you want to configure Roslynator on a user-wide basis you have to use Roslynator config file.
Default configuration file can be used with extension for Visual Studio or VS code.
If you want to configure Roslynator on a user-wide basis you have to use Roslynator config file (`.roslynatorconfig`).

### Format of Default Configuration File
**IMPORTANT:** Default configuration file can be used only with VS extension or VS code extension.

### Format

Format of the file is same as format of [global AnalyzerConfig](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig).
It essentially means that file must contain top-level entry `is_global = true` and cannot contain section headers (such as `[*.cs]`).
Namely, file must contain top-level entry `is_global = true` and cannot contain section headers (such as `[*.cs]`), For example:

```ini
is_global = true
roslynator_analyzers.enabled_by_default = true
```

### Location of Default Configuration File
### Location

Configuration file is located at `%LOCALAPPDATA%/JosefPihrt/Roslynator/.roslynatorconfig`.
Location of `%LOCALAPPDATA%` depends on the operating system:
Expand Down
4 changes: 0 additions & 4 deletions src/Tools/CodeGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ private static void Main(string[] args)
{
if (args is null || args.Length == 0)
{
#if DEBUG
args = new[] { @"..\..\..\..\.." };
#else
args = new string[] { Environment.CurrentDirectory };
#endif
}

string rootPath = args[0];
Expand Down
8 changes: 8 additions & 0 deletions src/Tools/CodeGenerator/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"CodeGenerator": {
"commandName": "Project",
"commandLineArgs": "\"../../../../..\""
}
}
}
4 changes: 0 additions & 4 deletions src/Tools/MetadataGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ private static async Task Main(string[] args)
{
if (args is null || args.Length == 0)
{
#if DEBUG
args = new[] { @"..\..\..\..\.." };
#else
args = new string[] { Environment.CurrentDirectory };
#endif
}

string rootPath = args[0];
Expand Down
8 changes: 8 additions & 0 deletions src/Tools/MetadataGenerator/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"MetadataGenerator": {
"commandName": "Project",
"commandLineArgs": "\"../../../../..\""
}
}
}
Loading