I want to write a new project with Roslyn Analyzer in .NET 7 My purpose is that to find all references for a method in a project as programmatically.
I loaded the solution like the below code.
_workspace = MSBuildWorkspace.Create();
_workspace.LoadMetadataForReferencedProjects = true;
var solution = await _workspace.OpenSolutionAsync(solutionFilenamePath, cancellationToken: cancellationToken);
_workspace.TryApplyChanges(solution);
After this operation, I can see all of the project in the solution. But I cannot see documents in these projects.
My references:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="17.5.0" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.5.0" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.5.0" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.5.0" />
</ItemGroup>
</Project>
What is my issue? I could not find.
Is Roslyn still not supported in .Net 7?
BTW, I worked successfully with .NET Framework 4.8