Skip to content

Commit dcf4e90

Browse files
committed
Initial commit
0 parents  commit dcf4e90

File tree

8 files changed

+139
-0
lines changed

8 files changed

+139
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

readme.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Overview
2+
3+
This repository serves as a minimal reproduction for a bug I found with Source Generators.
4+
5+
6+
# Steps
7+
8+
- Run `dotnet build` in the `src` folder
9+
- In `src\TestGenerator\TestGenerator.cs` change the type name from `TestGenerator1` to `TestGenerator2`
10+
- Run `dotnet clean` in the `src` folder (otherwise the build does not re-run)
11+
- Run `dotnet build` in the `src` folder
12+
13+
# Expected result
14+
15+
- The build finishes without a warning
16+
17+
# Actual result
18+
19+
- There is a warning:
20+
```
21+
CSC : warning CS8032: An instance of analyzer TestGenerator.TestGenerator2 cannot be created from <localPath>\src\TestGenerator\bin\Debug\netstandard2.0\TestGenerator.dll : Could not load type 'TestGenerator.TestGenerator4' from assembly 'TestGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.. [<localPath>\src\TestGenerator.Tests\TestGenerator.Tests.csproj]
22+
```
23+
- When I manually check the dll in the location via ILSpy, the requested type is there

src/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.idea/
2+
.vs/
3+
.vscode/
4+
5+
*.suo
6+
*.user
7+
[Bb]in/
8+
[Oo]bj/
9+
_UpgradeReport_Files/
10+
[Pp]ackages/
11+
12+
Thumbs.db
13+
Desktop.ini
14+
.DS_Store
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<LangVersion>latest</LangVersion>
9+
</PropertyGroup>
10+
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\TestGenerator\TestGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
14+
</ItemGroup>
15+
16+
</Project>

src/TestGenerator.sln

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.6.33723.286
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestGenerator", "TestGenerator\TestGenerator.csproj", "{A76F357E-C854-4700-8BA3-6B529DC541EE}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestGenerator.Tests", "TestGenerator.Tests\TestGenerator.Tests.csproj", "{22DD81A6-63E2-4E13-A0A4-8ECEAF40E7AA}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{A76F357E-C854-4700-8BA3-6B529DC541EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{A76F357E-C854-4700-8BA3-6B529DC541EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{A76F357E-C854-4700-8BA3-6B529DC541EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{A76F357E-C854-4700-8BA3-6B529DC541EE}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{22DD81A6-63E2-4E13-A0A4-8ECEAF40E7AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{22DD81A6-63E2-4E13-A0A4-8ECEAF40E7AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{22DD81A6-63E2-4E13-A0A4-8ECEAF40E7AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{22DD81A6-63E2-4E13-A0A4-8ECEAF40E7AA}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{C3BE2060-4F2B-4EC5-9B3E-8CCB42EFE7CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{C3BE2060-4F2B-4EC5-9B3E-8CCB42EFE7CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{C3BE2060-4F2B-4EC5-9B3E-8CCB42EFE7CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{C3BE2060-4F2B-4EC5-9B3E-8CCB42EFE7CC}.Release|Any CPU.Build.0 = Release|Any CPU
28+
EndGlobalSection
29+
GlobalSection(SolutionProperties) = preSolution
30+
HideSolutionNode = FALSE
31+
EndGlobalSection
32+
GlobalSection(ExtensibilityGlobals) = postSolution
33+
SolutionGuid = {C575BC69-AA58-4457-ADC8-9CAC63182A48}
34+
EndGlobalSection
35+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"Generators": {
5+
"commandName": "DebugRoslynComponent",
6+
"targetProject": "../CSVBindingsGenerator.IntegrationTests/CSVBindingsGenerator.IntegrationTests.csproj"
7+
}
8+
}
9+
}

src/TestGenerator/TestGenerator.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Text.RegularExpressions;
8+
using Microsoft.CodeAnalysis;
9+
using Microsoft.CodeAnalysis.Text;
10+
11+
namespace TestGeneratorNamespace
12+
{
13+
[Generator]
14+
public class TestGenerator1 : ISourceGenerator
15+
{
16+
public void Initialize(GeneratorInitializationContext context)
17+
{
18+
}
19+
20+
public void Execute(GeneratorExecutionContext context)
21+
{
22+
}
23+
}
24+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<LangVersion>latest</LangVersion>
7+
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0" PrivateAssets="all" />
13+
</ItemGroup>
14+
15+
16+
</Project>

0 commit comments

Comments
 (0)