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

[Generator] == on a type those a reference equals check. #19756

Merged

Conversation

mandel-macaque
Copy link
Member

Found this while writing some unit tests for the generator. The comparison between types uses a ReferenceEquals, that means that we should ensure that we have a EcmaType in both sides. When running this on unit tests, we have a RunTime vs a EcmaType comparison which results in an error.

Pay attention to the following:

  1. Changed the way we filter types so that we can use the set in several methods.
  2. Added a new compiler injected attribute to be ignored: 'Microsoft.CodeAnalysis.EmbeddedAttribute'
  3. Microsoft.CodeAnalysis.EmbeddedAttribute is added/present in more than one assembly, so do not throw when that happens, is a special case that is injected by the compiler.

I ran the generator diff between main and this commit and the output is:

diff --git a/old/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs b/new/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs
index ef5e2e112f..5ded00c3af 100644
--- a/old/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs
+++ b/new/dotnet/IDE/obj/common/bgen/bgen.AssemblyInfo.cs
@@ -13,7 +13,7 @@ using System.Reflection;
 [assembly: System.Reflection.AssemblyCompanyAttribute("bgen")]
 [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
 [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b60ee772c228723a5e01212471c1e8eb5c20ebb9")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ec8a6c261a68f6aee2ad2373cf45e3f001ac4679")]
 [assembly: System.Reflection.AssemblyProductAttribute("bgen")]
 [assembly: System.Reflection.AssemblyTitleAttribute("bgen")]
 [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/old/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json b/new/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json
index 5c5105e606..547bfb2dc4 100644
--- a/old/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json
+++ b/new/dotnet/IDE/obj/common/bgen/bgen.sourcelink.json
@@ -1 +1 @@
-{"documents":{"/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/*":"https://raw.githubusercontent.com/xamarin/xamarin-macios/b60ee772c228723a5e01212471c1e8eb5c20ebb9/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/external/api-tools/*":"https://raw.githubusercontent.com/rolfbjarne/api-tools/1fbbe003a141231439c08b23989d3dc910bd6182/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/external/macios-binaries/*":"https://raw.githubusercontent.com/xamarin/macios-binaries/7813391e75d7373ee073ef2d5716e3c607c8636a/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/external/MonoTouch.Dialog/*":"https://raw.githubusercontent.com/migueldeicaza/MonoTouch.Dialog/5898074d6e62109c85e587977230c1a521cb9bb2/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/external/opentk/*":"https://raw.githubusercontent.com/mono/opentk/396bc90c7ac2e7ce442840a5e8bd91e5e79b381e/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/external/Touch.Unit/*":"https://raw.githubusercontent.com/spouliot/Touch.Unit/92a072683b69b2f61f235a7a249c2c7f261236d4/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/tools/comparison/tmp/src/xamarin-macios/external/Xamarin.MacDev/*":"https://raw.githubusercontent.com/xamarin/Xamarin.MacDev/b454d454a687d9aa26a382ad16f1a9361b06b074/*"}}
\ No newline at end of file
+{"documents":{"/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/*":"https://raw.githubusercontent.com/xamarin/xamarin-macios/ec8a6c261a68f6aee2ad2373cf45e3f001ac4679/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/external/api-tools/*":"https://raw.githubusercontent.com/rolfbjarne/api-tools/1fbbe003a141231439c08b23989d3dc910bd6182/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/external/macios-binaries/*":"https://raw.githubusercontent.com/xamarin/macios-binaries/7813391e75d7373ee073ef2d5716e3c607c8636a/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/external/MonoTouch.Dialog/*":"https://raw.githubusercontent.com/xamarin/MonoTouch.Dialog/5898074d6e62109c85e587977230c1a521cb9bb2/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/external/opentk/*":"https://raw.githubusercontent.com/mono/opentk/396bc90c7ac2e7ce442840a5e8bd91e5e79b381e/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/external/Touch.Unit/*":"https://raw.githubusercontent.com/spouliot/Touch.Unit/92a072683b69b2f61f235a7a249c2c7f261236d4/*","/Users/mandel/Xamarin/xamarin-macios/xamarin-macios/external/Xamarin.MacDev/*":"https://raw.githubusercontent.com/xamarin/Xamarin.MacDev/b454d454a687d9aa26a382ad16f1a9361b06b074/*"}}
\ No newline at end of file

API should result in no changes.

Copy link
Contributor

github-actions bot commented Jan 5, 2024

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

Copy link
Member

@dalexsoto dalexsoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subtle

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13.0) passed 💻

All tests on macOS M1 - Mac Ventura (13.0) passed.

Pipeline on Agent
Hash: [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: 855b015c1dc252a238f7872621c5002d2e11f15f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent
Hash: [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS (no change detected)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)
Legacy Xamarin (stable) vs .NET

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 855b015c1dc252a238f7872621c5002d2e11f15f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

0 tests crashed, 2 tests failed, 233 tests passed.

Failures

❌ bcl tests

2 tests failed, 67 tests passed.
  • [xUnit] Mono Mac OS X BCL tests group 4/Mac Full/Debug: Failed (Test run failed.
    Tests run: 67883 Passed: 67876 Inconclusive: 0 Failed: 1 Ignored: 6)
  • [NUnit] Mono CorlibTests/watchOS 32-bits - simulator/Debug: Failed

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 6 tests passed. Html Report (VSDrops) Download
✅ monotouch: All 41 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 855b015c1dc252a238f7872621c5002d2e11f15f [PR build]

@mandel-macaque
Copy link
Member Author

Failures are unrelated to the change since they are bcc mono tests:

System.IO.Tests.FileSystemWatcherTests.FileSystemWatcher_StopCalledOnBackgroundThreadDoesNotDeadlock: Assert.True() Failure\nExpected: True\nActual: False

@mandel-macaque mandel-macaque merged commit f46633f into xamarin:main Jan 8, 2024
67 of 70 checks passed
@mandel-macaque mandel-macaque deleted the generator-reference-compare branch January 8, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants