-
Notifications
You must be signed in to change notification settings - Fork 5k
Refactor how diagnostics work in the interop generators #87700
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
Conversation
Update the diagnostics system to have the following characteristics: - Well known categories of diagnostics, such as "Not supported" or "Unnecessary data" are represented by a discriminated union. - Each generator provides diagnostic descriptors that fit specific formatting rules for each check (which all of our generators follow) - Slightly abstract out the concept of "diagnostic" locations so it can be shared better. - Split "create diagnostic" from "report diagnostic" to make it easier to share code. - Remove our exception type and move to a "generator and a collection of possibly fatal diagnostics" model to enable representing diagnostics that shouldn't stop source-generated interop codegen.
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsUpdate the diagnostics system to have the following characteristics:
|
Guess it's time to solve the dependency issue (consuming older generators with some live built componenets also included) |
… the generators from the LKG SDK.
If we don't pass any types from Microsoft.Interop.SourceGeneration between LibraryImportGenerator and ComInterfaceGenerator, we might be able to make the Microsoft.Interop.SourceGeneration project a shared project? Though that would make each assembly much larger. |
We want to eventually ship Microsoft.Interop.SourceGeneration as its own assembly/NuGet package, so we don't want to include it as source in the dependent projects. Also, we should solve these conflict issues anyway instead of continuing to punt them. If any of the task assemblies were actually using the generators, we would have pretty rough build breaks as both copies of the generator would try to generate code. |
…e condition, as this best describes what we actually want to check.
....Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/SymbolDiagnosticLocations.cs
Outdated
Show resolved
Hide resolved
@jkoritzinsky, FYI, noticed a failure in a mono outerloop test: $ ./build.sh mono+libs -keepnativesymbols true
$ pushd src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests
$ ~/projects/runtime/dotnet.sh build -t:Test -p:OuterLoop=true \
-p:XunitMethodName=LibraryImportGenerator.UnitTests.AttributeForwarding.InOutAttributes_Forwarded_To_ForwardedParameter
...
Discovering: LibraryImportGenerator.Unit.Tests (method display = ClassAndMethod, method display options = None)
Discovered: LibraryImportGenerator.Unit.Tests (found 1 of 187 test case)
Starting: LibraryImportGenerator.Unit.Tests (parallel test collections = on, max threads = 10)
LibraryImportGenerator.UnitTests.AttributeForwarding.InOutAttributes_Forwarded_To_ForwardedParameter [FAIL]
Assert.Collection() Failure
Collection: [int __a_native]
Error during comparison of item at index 0
Inner exception: Assert.Collection() Failure
Collection: []
Expected item count: 2
Actual item count: 0
Stack Trace:
/Users/am11/projects/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs(359,0): at LibraryImportGenerator.UnitTests.AttributeForwarding.<>c__DisplayClass6_0.<InOutAttributes_Forwarded_To_ForwardedParameter>b__1(IParameterSymbol param)
/Users/am11/projects/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs(358,0): at LibraryImportGenerator.UnitTests.AttributeForwarding.<>c.<InOutAttributes_Forwarded_To_ForwardedParameter>b__6_0(IMethodSymbol targetMethod, Compilation newComp)
/Users/am11/projects/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs(445,0): at LibraryImportGenerator.UnitTests.AttributeForwarding.GeneratedTargetPInvokeTest.VerifyFinalCompilation(Compilation compilation)
/Users/am11/projects/runtime/src/libraries/System.Runtime.InteropServices/tests/Common/Verifiers/CSharpSourceGeneratorVerifier.cs(154,0): at Microsoft.Interop.UnitTests.Verifiers.CSharpSourceGeneratorVerifier`1.Test.<GetProjectCompilationAsync>d__4[[Microsoft.Interop.LibraryImportGenerator, Microsoft.Interop.LibraryImportGenerator, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
/_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs(1117,0): at Microsoft.CodeAnalysis.Testing.AnalyzerTest`1.<GetSortedDiagnosticsAsync>d__82[[Microsoft.CodeAnalysis.Testing.Verifiers.XUnitVerifier, Microsoft.CodeAnalysis.Testing.Verifiers.XUnit, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
/_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs(1092,0): at Microsoft.CodeAnalysis.Testing.AnalyzerTest`1.<GetSortedDiagnosticsAsync>d__81[[Microsoft.CodeAnalysis.Testing.Verifiers.XUnitVerifier, Microsoft.CodeAnalysis.Testing.Verifiers.XUnit, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
/_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs(466,0): at Microsoft.CodeAnalysis.Testing.AnalyzerTest`1.<VerifyDiagnosticsAsync>d__69[[Microsoft.CodeAnalysis.Testing.Verifiers.XUnitVerifier, Microsoft.CodeAnalysis.Testing.Verifiers.XUnit, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
/_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs(219,0): at Microsoft.CodeAnalysis.Testing.AnalyzerTest`1.<RunImplAsync>d__64[[Microsoft.CodeAnalysis.Testing.Verifiers.XUnitVerifier, Microsoft.CodeAnalysis.Testing.Verifiers.XUnit, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
/_/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.Analyzer.Testing/AnalyzerTest`1.cs(188,0): at Microsoft.CodeAnalysis.Testing.AnalyzerTest`1.<RunAsync>d__63[[Microsoft.CodeAnalysis.Testing.Verifiers.XUnitVerifier, Microsoft.CodeAnalysis.Testing.Verifiers.XUnit, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()
/Users/am11/projects/runtime/src/libraries/System.Runtime.InteropServices/tests/LibraryImportGenerator.UnitTests/AttributeForwarding.cs(351,0): at LibraryImportGenerator.UnitTests.AttributeForwarding.InOutAttributes_Forwarded_To_ForwardedParameter()
--- End of stack trace from previous location ---
Finished: LibraryImportGenerator.Unit.Tests
=== TEST EXECUTION SUMMARY ===
LibraryImportGenerator.Unit.Tests Total: 1, Errors: 0, Failed: 1, Skipped: 0, Time: 2.612s (was passing until the previous commit on main: 82ed3dc) |
Opened an issue to track. I'll take a look next week. |
Update the diagnostics system to have the following characteristics: