Skip to content
Merged
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
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
- id: compute-version
name: Compute version
run: |
$(Invoke-WebRequest "https://www.nuget.org/api/v2/package/Meziantou.Analyzer/").BaseResponse.RequestMessage.RequestUri -match "meziantou\.analyzer\.2\.0\.([0-9]+).nupkg"
$NewVersion = "2.0.$([int]$Matches.1 + 1)"
$(Invoke-WebRequest "https://www.nuget.org/api/v2/package/Meziantou.Analyzer/").BaseResponse.RequestMessage.RequestUri -match "meziantou\.analyzer\.3\.0\.([0-9]+).nupkg"
$NewVersion = "3.0.$([int]$Matches.1 + 1)"
if ($env:GITHUB_REF -ne 'refs/heads/main') {
$NewVersion = $NewVersion + '-build.${{ github.run_id }}'
}
Expand All @@ -66,9 +66,6 @@ jobs:

- run: dotnet run --project src/ListDotNetTypes/ListDotNetTypes.csproj -- src/Meziantou.Analyzer/Resources/

- run: dotnet build src/Meziantou.Analyzer/Meziantou.Analyzer.csproj --configuration Release /p:RoslynVersion=roslyn3.8 /p:Version=${{ needs.compute_package_version.outputs.package_version }} /bl:Meziantou.Analyzer.roslyn3.8.binlog
- run: dotnet build src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj --configuration Release /p:RoslynVersion=roslyn3.8 /p:Version=${{ needs.compute_package_version.outputs.package_version }} /bl:Meziantou.Analyzer.CodeFixers.roslyn3.8.binlog

- run: dotnet build src/Meziantou.Analyzer/Meziantou.Analyzer.csproj --configuration Release /p:RoslynVersion=roslyn4.2 /p:Version=${{ needs.compute_package_version.outputs.package_version }} /bl:Meziantou.Analyzer.roslyn4.2.binlog
- run: dotnet build src/Meziantou.Analyzer.CodeFixers/Meziantou.Analyzer.CodeFixers.csproj --configuration Release /p:RoslynVersion=roslyn4.2 /p:Version=${{ needs.compute_package_version.outputs.package_version }} /bl:Meziantou.Analyzer.CodeFixers.roslyn4.2.binlog

Expand Down Expand Up @@ -137,7 +134,7 @@ jobs:
matrix:
runs-on: [ ubuntu-latest ]
configuration: [ Release ]
roslyn-version: [ 'roslyn3.8', 'roslyn4.2', 'roslyn4.4', 'roslyn4.6', 'roslyn4.8', 'roslyn4.14', 'default' ]
roslyn-version: [ 'roslyn4.2', 'roslyn4.4', 'roslyn4.6', 'roslyn4.8', 'roslyn4.14', 'default' ]
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down
13 changes: 0 additions & 13 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@
</PropertyGroup>

<Choose>
<When Condition="$(RoslynVersion) == 'roslyn3.8'">
<ItemGroup >
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" />
<PackageReference Update="Microsoft.CodeAnalysis.Workspaces.Common" Version="3.8.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.8.0" />
</ItemGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);ROSLYN_3_8</DefineConstants>
<DefineConstants>$(DefineConstants);CSHARP9_OR_GREATER</DefineConstants>
<NoWarn>$(NoWarn);nullable</NoWarn>
</PropertyGroup>
</When>

<When Condition="$(RoslynVersion) == 'roslyn4.2'">
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Operations;

#if ROSLYN_3_8
using System.Linq;
#endif

namespace Meziantou.Analyzer.Rules;

[ExportCodeFixProvider(LanguageNames.CSharp), Shared]
Expand Down
3 changes: 0 additions & 3 deletions src/Meziantou.Analyzer.Pack/Meziantou.Analyzer.Pack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

<None Include="configuration/*.editorconfig" Pack="true" PackagePath="configuration" />

<None Include="$(MSBuildThisFileDirectory)\..\Meziantou.Analyzer\bin\roslyn3.8\$(Configuration)\netstandard2.0\Meziantou.Analyzer.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn3.8/cs/" />
<None Include="$(MSBuildThisFileDirectory)\..\Meziantou.Analyzer.CodeFixers\bin\roslyn3.8\$(Configuration)\netstandard2.0\Meziantou.Analyzer.CodeFixers.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn3.8/cs/" />

<None Include="$(MSBuildThisFileDirectory)\..\Meziantou.Analyzer\bin\roslyn4.2\$(Configuration)\netstandard2.0\Meziantou.Analyzer.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.2/cs/" />
<None Include="$(MSBuildThisFileDirectory)\..\Meziantou.Analyzer.CodeFixers\bin\roslyn4.2\$(Configuration)\netstandard2.0\Meziantou.Analyzer.CodeFixers.dll" Pack="true" PackagePath="analyzers/dotnet/roslyn4.2/cs/" />

Expand Down
32 changes: 1 addition & 31 deletions src/Meziantou.Analyzer/Internals/CompilationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#if ROSLYN_3_8
using System.Collections.Immutable;
#endif
using System.Diagnostics;
using System.Diagnostics;
using Microsoft.CodeAnalysis;

namespace Meziantou.Analyzer.Internals;
Expand All @@ -15,33 +12,6 @@ public static bool IsNet9OrGreater(this Compilation compilation)
return version.Major >= 9;
}

#if ROSLYN_3_8
public static ImmutableArray<INamedTypeSymbol> GetTypesByMetadataName(this Compilation compilation, string typeMetadataName)
{
var result = ImmutableArray.CreateBuilder<INamedTypeSymbol>();
var symbol = compilation.Assembly.GetTypeByMetadataName(typeMetadataName);
if (symbol != null)
{
result.Add(symbol);
}

foreach (var reference in compilation.References)
{
var assemblySymbol = compilation.GetAssemblyOrModuleSymbol(reference) as IAssemblySymbol;
if (assemblySymbol == null)
continue;

symbol = assemblySymbol.GetTypeByMetadataName(typeMetadataName);
if (symbol != null)
{
result.Add(symbol);
}
}

return result.ToImmutable();
}
#endif

// Copy from https://github.com/dotnet/roslyn/blob/d2ff1d83e8fde6165531ad83f0e5b1ae95908289/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/CompilationExtensions.cs#L11-L68
/// <summary>
/// Gets a type by its metadata name to use for code analysis within a <see cref="Compilation"/>. This method
Expand Down
5 changes: 0 additions & 5 deletions src/Meziantou.Analyzer/Internals/OperationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ public static IOperation.OperationList GetChildOperations(this IOperation operat
{
return operation.ChildOperations;
}
#elif ROSLYN_3_8
public static IEnumerable<IOperation> GetChildOperations(this IOperation operation)
{
return operation.Children;
}
#endif

public static LanguageVersion GetCSharpLanguageVersion(this IOperation operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;

#if ROSLYN_3_8
using System.Linq;
#endif

namespace Meziantou.Analyzer.Rules;

[DiagnosticAnalyzer(LanguageNames.CSharp)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,6 @@ private async Task<Diagnostic[]> GetSortedDiagnosticsFromDocuments(IList<Diagnos
var diags = await compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync(CancellationToken.None).ConfigureAwait(false);
foreach (var diag in diags)
{
#if ROSLYN_3_8
if (diag.IsSuppressed)
continue;
#endif

if (diag.Location == Location.None || diag.Location.IsInMetadata || !diag.Location.IsInSource)
{
diagnostics.Add(diag);
Expand Down