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

RequiresAssemblyFilesAnalyzer throws InvalidCastException #59749

Closed
nagya opened this issue Feb 24, 2022 · 1 comment
Closed

RequiresAssemblyFilesAnalyzer throws InvalidCastException #59749

nagya opened this issue Feb 24, 2022 · 1 comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@nagya
Copy link

nagya commented Feb 24, 2022

Version Used: 6.0.200, bug is new in this version, i.e. was not present in 6.0.1

Steps to Reproduce:

  1. Test1.zip
  2. dotnet build

Expected Behavior:

No compile time exception and no warning.

Actual Behavior:

CSC : warning AD0001: Analyzer 'ILLink.RoslynAnalyzer.RequiresAssemblyFilesAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.TypeParameterSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'.'. 

Repro project details:

PublishSingleFile=true must be set in the project file, and both type constraints are needed in the source file.

Test1.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <PublishSingleFile>true</PublishSingleFile>
  </PropertyGroup>
</Project>

Class1.cs

namespace Test1;

public abstract class Class1<T> where T : Class1<T>, new() { }
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 24, 2022
@Youssef1313
Copy link
Member

This is not related to dotnet/roslyn. It should go in dotnet/linker instead where the implementation of this analyzer exists.

https://github.com/dotnet/linker/blob/2999a6a9dd884d554be18d3c86a4a9db4b61e156/src/ILLink.RoslynAnalyzer/RequiresAssemblyFilesAnalyzer.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants