Skip to content

Commit

Permalink
Solution refactorization (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Djoums authored Apr 29, 2024
1 parent b21415e commit b4fbfce
Show file tree
Hide file tree
Showing 57 changed files with 177 additions and 273 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
- run: dotnet restore NuGetOnly.slnf
- run: dotnet build NuGetOnly.slnf -c Release --no-restore
- run: dotnet pack NuGetOnly.slnf -c Release --no-build
- run: dotnet test NuGetOnly.slnf -c Release --no-build --logger "trx;LogFileName=test_results.trx"
- run: dotnet restore TestsOnly.slnf
- run: dotnet build TestsOnly.slnf -c Release --no-restore
- run: dotnet test TestsOnly.slnf -c Release --no-build --logger "trx;LogFileName=test_results.trx"
- uses: actions/upload-artifact@v4
if: always() # Ensure this step runs even if the test step fails
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/create-tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ jobs:
enableCrossOsArchive: true
- run: dotnet restore NuGetOnly.slnf
- run: dotnet build NuGetOnly.slnf -c Release --no-restore
- run: dotnet test NuGetOnly.slnf -c Release --no-build --logger "trx;LogFileName=test_results.trx"
- run: dotnet pack NuGetOnly.slnf -c Release --no-build -o ./nupkg -p:Version=${{ needs.versioning.outputs.tag }}
- uses: actions/cache/save@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.9.3184" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageVersion Include="MSTest.TestFramework" Version="3.3.1" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.2" />
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.2" />
<PackageVersion Include="Roslynator.CodeFixes" Version="4.12.2" />
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.2" />
</ItemGroup>
</Project>
7 changes: 2 additions & 5 deletions NuGetOnly.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
"solution": {
"path": "ecoCode-csharp.sln",
"projects": [
"src\\EcoCode.Analyzers\\EcoCode.Analyzers.csproj",
"src\\EcoCode.CodeFixes\\EcoCode.CodeFixes.csproj",
"src\\EcoCode.Package\\EcoCode.Package.csproj",
"src\\EcoCode.Shared\\EcoCode.Shared.csproj",
"src\\EcoCode.Tests\\EcoCode.Tests.csproj"
"src\\EcoCode.Core\\EcoCode.Core.csproj",
"src\\EcoCode.Package\\EcoCode.Package.csproj"
]
}
}
9 changes: 9 additions & 0 deletions TestsOnly.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"solution": {
"path": "ecoCode-csharp.sln",
"projects": [
"src\\EcoCode.Core\\EcoCode.Core.csproj",
"src\\EcoCode.Tests\\EcoCode.Tests.csproj"
]
}
}
4 changes: 1 addition & 3 deletions VsixOnly.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"solution": {
"path": "ecoCode-csharp.sln",
"projects": [
"src\\EcoCode.Analyzers\\EcoCode.Analyzers.csproj",
"src\\EcoCode.CodeFixes\\EcoCode.CodeFixes.csproj",
"src\\EcoCode.Shared\\EcoCode.Shared.csproj",
"src\\EcoCode.Core\\EcoCode.Core.csproj",
"src\\EcoCode.Vsix\\EcoCode.Vsix.csproj"
]
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
52 changes: 27 additions & 25 deletions ecoCode-csharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,43 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34408.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Analyzers", "src\EcoCode.Analyzers\EcoCode.Analyzers.csproj", "{95076571-CC7F-44E9-B9AA-FFBD7AE5355E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.CodeFixes", "src\EcoCode.CodeFixes\EcoCode.CodeFixes.csproj", "{F9F5157B-D5B5-4682-804C-1BD366BEC5B9}"
ProjectSection(ProjectDependencies) = postProject
{95076571-CC7F-44E9-B9AA-FFBD7AE5355E} = {95076571-CC7F-44E9-B9AA-FFBD7AE5355E}
EndProjectSection
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Core", "src\EcoCode.Core\EcoCode.Core.csproj", "{95076571-CC7F-44E9-B9AA-FFBD7AE5355E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Package", "src\EcoCode.Package\EcoCode.Package.csproj", "{45D880DC-011C-415A-9266-EB69FF5D5A1E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Tests", "src\EcoCode.Tests\EcoCode.Tests.csproj", "{09A6D27B-AF9E-49D7-92A9-3BB3A5E09D99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Shared", "src\EcoCode.Shared\EcoCode.Shared.csproj", "{0C55B22C-8266-4B3B-9A66-E4A753A5282C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EcoCode.Vsix", "src\EcoCode.Vsix\EcoCode.Vsix.csproj", "{628DAC2E-06FE-49BA-8873-18C8034DD16B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{810939C8-2A48-4F56-84C3-E433CDB923EE}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml
CONTRIBUTING.md = CONTRIBUTING.md
.github\workflows\create-manual-vsix-release.yml = .github\workflows\create-manual-vsix-release.yml
.github\workflows\create-tag-release.yml = .github\workflows\create-tag-release.yml
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
global.json = global.json
icon.jpeg = icon.jpeg
LICENCE.md = LICENCE.md
NOTICE.md = NOTICE.md
NuGet.Config = NuGet.Config
NuGetOnly.slnf = NuGetOnly.slnf
README.md = README.md
SharedAssemblyInfo.cs = SharedAssemblyInfo.cs
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{5FDA07DE-D474-40F1-8C21-2B56FDEBD236}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml
.github\workflows\create-tag-release.yml = .github\workflows\create-tag-release.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Assets", "Assets", "{D10E2FE2-04EB-4F54-90E6-2E0BBA562041}"
ProjectSection(SolutionItems) = preProject
assets\CONTRIBUTING.md = assets\CONTRIBUTING.md
assets\icon.jpeg = assets\icon.jpeg
assets\LICENCE.md = assets\LICENCE.md
assets\NOTICE.md = assets\NOTICE.md
assets\README.md = assets\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Filters", "Filters", "{7230C2B8-8611-4946-A3BD-1BFD26C3833A}"
ProjectSection(SolutionItems) = preProject
NuGetOnly.slnf = NuGetOnly.slnf
TestsOnly.slnf = TestsOnly.slnf
VsixOnly.slnf = VsixOnly.slnf
EndProjectSection
EndProject
Expand All @@ -48,10 +53,6 @@ Global
{95076571-CC7F-44E9-B9AA-FFBD7AE5355E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95076571-CC7F-44E9-B9AA-FFBD7AE5355E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95076571-CC7F-44E9-B9AA-FFBD7AE5355E}.Release|Any CPU.Build.0 = Release|Any CPU
{F9F5157B-D5B5-4682-804C-1BD366BEC5B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9F5157B-D5B5-4682-804C-1BD366BEC5B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9F5157B-D5B5-4682-804C-1BD366BEC5B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9F5157B-D5B5-4682-804C-1BD366BEC5B9}.Release|Any CPU.Build.0 = Release|Any CPU
{45D880DC-011C-415A-9266-EB69FF5D5A1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45D880DC-011C-415A-9266-EB69FF5D5A1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45D880DC-011C-415A-9266-EB69FF5D5A1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -60,10 +61,6 @@ Global
{09A6D27B-AF9E-49D7-92A9-3BB3A5E09D99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09A6D27B-AF9E-49D7-92A9-3BB3A5E09D99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09A6D27B-AF9E-49D7-92A9-3BB3A5E09D99}.Release|Any CPU.Build.0 = Release|Any CPU
{0C55B22C-8266-4B3B-9A66-E4A753A5282C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C55B22C-8266-4B3B-9A66-E4A753A5282C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C55B22C-8266-4B3B-9A66-E4A753A5282C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C55B22C-8266-4B3B-9A66-E4A753A5282C}.Release|Any CPU.Build.0 = Release|Any CPU
{628DAC2E-06FE-49BA-8873-18C8034DD16B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{628DAC2E-06FE-49BA-8873-18C8034DD16B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{628DAC2E-06FE-49BA-8873-18C8034DD16B}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -72,6 +69,11 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5FDA07DE-D474-40F1-8C21-2B56FDEBD236} = {810939C8-2A48-4F56-84C3-E433CDB923EE}
{D10E2FE2-04EB-4F54-90E6-2E0BBA562041} = {810939C8-2A48-4F56-84C3-E433CDB923EE}
{7230C2B8-8611-4946-A3BD-1BFD26C3833A} = {810939C8-2A48-4F56-84C3-E433CDB923EE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25BE75DE-AF1B-480D-B27C-6F411621E246}
EndGlobalSection
Expand Down
19 changes: 0 additions & 19 deletions src/EcoCode.Analyzers/EcoCode.Analyzers.csproj

This file was deleted.

7 changes: 0 additions & 7 deletions src/EcoCode.Analyzers/GlobalUsings.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions src/EcoCode.CodeFixes/EcoCode.CodeFixes.csproj

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace EcoCode.Analyzers;

/// <summary>Analyzer for don't call loop invariant functions in loop conditions.</summary>
/// <summary>EC69: Don't call loop invariant functions in loop conditions.</summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class DontCallFunctionsInLoopConditionsAnalyzer : DiagnosticAnalyzer
public sealed class DontCallFunctionsInLoopConditions : DiagnosticAnalyzer
{
private static readonly ImmutableArray<SyntaxKind> SyntaxKinds = [
SyntaxKind.ForStatement,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace EcoCode.Analyzers;

/// <summary>Analyzer for don't execute SQL commands in loops.</summary>
/// <summary>EC72: Don't execute SQL commands in loops.</summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class DontExecuteSqlCommandsInLoopsAnalyzer : DiagnosticAnalyzer
public sealed class DontExecuteSqlCommandsInLoops : DiagnosticAnalyzer
{
private static readonly ImmutableArray<SyntaxKind> Invocations = [SyntaxKind.InvocationExpression];

/// <summary>The diagnostic descriptor.</summary>
public static DiagnosticDescriptor Descriptor { get; } = new(
Rule.Ids.EC72_DontExecuteSqlCommandsInLoops,
Expand Down Expand Up @@ -38,7 +40,7 @@ symbol.Name is "ExecuteNonQuery" or "ExecuteScalar" or "ExecuteReader" &&
{
context.ReportDiagnostic(Diagnostic.Create(Descriptor, context.Node.GetLocation()));
}
}, SyntaxKind.InvocationExpression);
}, Invocations);
});
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace EcoCode.Analyzers;

/// <summary>Analyzer for don't concatenate strings in loops.</summary>
/// <summary>EC75: Don't concatenate strings in loops.</summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class DontConcatenateStringsInLoopsAnalyzer : DiagnosticAnalyzer
public sealed class DontConcatenateStringsInLoops : DiagnosticAnalyzer
{
private static readonly ImmutableArray<SyntaxKind> SyntaxKinds = [
SyntaxKind.ForStatement,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace EcoCode.CodeFixes;
namespace EcoCode.Analyzers;

/// <summary>The code fix provider for use struct layout.</summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SpecifyStructLayoutCodeFixProvider)), Shared]
public sealed class SpecifyStructLayoutCodeFixProvider : CodeFixProvider
/// <summary>EC81 fixer: Use struct layout.</summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SpecifyStructLayoutFixer)), Shared]
public sealed class SpecifyStructLayoutFixer : CodeFixProvider
{
/// <inheritdoc/>
public override ImmutableArray<string> FixableDiagnosticIds => _fixableDiagnosticIds;
private static readonly ImmutableArray<string> _fixableDiagnosticIds = [SpecifyStructLayoutAnalyzer.Descriptor.Id];
private static readonly ImmutableArray<string> _fixableDiagnosticIds = [SpecifyStructLayout.Descriptor.Id];

/// <inheritdoc/>
public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace EcoCode.Analyzers;

/// <summary>Analyzer for specify struct layout.</summary>
/// <summary>EC81: Specify struct layout.</summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class SpecifyStructLayoutAnalyzer : DiagnosticAnalyzer
public sealed class SpecifyStructLayout : DiagnosticAnalyzer
{
private static readonly ImmutableArray<SymbolKind> SymbolKinds = [SymbolKind.NamedType];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Microsoft.CodeAnalysis.Formatting;

namespace EcoCode.CodeFixes;
namespace EcoCode.Analyzers;

/// <summary>The code fix provider for variable can be made constant.</summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(VariableCanBeMadeConstantCodeFixProvider)), Shared]
public sealed class VariableCanBeMadeConstantCodeFixProvider : CodeFixProvider
/// <summary>EC82 dixer: Variable can be made constant.</summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(VariableCanBeMadeConstantFixer)), Shared]
public sealed class VariableCanBeMadeConstantFixer : CodeFixProvider
{
/// <inheritdoc/>
public override ImmutableArray<string> FixableDiagnosticIds => _fixableDiagnosticIds;
private static readonly ImmutableArray<string> _fixableDiagnosticIds = [VariableCanBeMadeConstantAnalyzer.Descriptor.Id];
private static readonly ImmutableArray<string> _fixableDiagnosticIds = [VariableCanBeMadeConstant.Descriptor.Id];

/// <inheritdoc/>
public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace EcoCode.Analyzers;

/// <summary>Analyzer for variable can be made constant.</summary>
/// <summary>EC82: Variable can be made constant.</summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class VariableCanBeMadeConstantAnalyzer : DiagnosticAnalyzer
public sealed class VariableCanBeMadeConstant : DiagnosticAnalyzer
{
private static readonly ImmutableArray<SyntaxKind> SyntaxKinds = [SyntaxKind.LocalDeclarationStatement];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Microsoft.CodeAnalysis.Operations;
namespace EcoCode.Analyzers;

namespace EcoCode.CodeFixes;

/// <summary>The code fix provider for replace enum ToString with nameof.</summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(ReplaceEnumToStringWithNameOfCodeFixProvider)), Shared]
public sealed class ReplaceEnumToStringWithNameOfCodeFixProvider : CodeFixProvider
/// <summary>EC83 fixer: Replace enum ToString with nameof.</summary>
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(ReplaceEnumToStringWithNameOfFixer)), Shared]
public sealed class ReplaceEnumToStringWithNameOfFixer : CodeFixProvider
{
/// <inheritdoc/>
public override ImmutableArray<string> FixableDiagnosticIds => _fixableDiagnosticIds;
private static readonly ImmutableArray<string> _fixableDiagnosticIds = [ReplaceEnumToStringWithNameOfAnalyzer.Descriptor.Id];
private static readonly ImmutableArray<string> _fixableDiagnosticIds = [ReplaceEnumToStringWithNameOf.Descriptor.Id];

/// <inheritdoc/>
public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
Expand Down
Loading

0 comments on commit b4fbfce

Please sign in to comment.