Closed tipa closed 1 year ago
@marek-safar could you please tag the owners of the Xamarin custom steps (macOS)?
The custom step is effectively calling AnnotationStore.IsMarked(null)
which will crash the linker.
@tipa would it be possible get access to your project, or a test project we can use to reproduce this?
@rolfbjarne I was able to reproduce the problem by simply adding this piece of code to an otherwise empty app:
new NSView().HeightAnchor.ConstraintEqualTo(1);
Are you able to reproduce it? I can otherwise try to create a demo project. The problem just started to appear recently. I am using .NET7 and the preview Xamarin SDKs (Xamarin.Mac Version: 9.0.0.27)
@tipa
@rolfbjarne I was able to reproduce the problem by simply adding this piece of code to an otherwise empty app:
new NSView().HeightAnchor.ConstraintEqualTo(1);
Are you able to reproduce it? I can otherwise try to create a demo project. The problem just started to appear recently. I am using .NET7 and the preview Xamarin SDKs (Xamarin.Mac Version: 9.0.0.27)
I tried dotnet new macos
and then adding that line of code somewhere, but that works fine.
Could you try to create a repro project and also get a binary build log from a failing build? The log will show the exact versions you're using, which should make sure I'm testing the same thing you're using.
Here's the demo project + binlog: Archive.zip
I can reproduce now.
For a workaround, reference the NSAnchorLayout.Item property:
var anchor = new NSView().HeightAnchor;
anchor.ConstraintEqualTo(1);
var item = anchor.Item; // prevents the problem
Thanks for the workaround. Unfortunately it's not really an option for me to use it as I am using this method call several hundred times in each of my apps. Hope it will get resolved in one of the next .NET7 service releases :)
You only need to access NSAnchorLayout.Item once anywhere in your app (in a way that the linker doesn't remove the field).
Yes, this is fixed.
I am trying to built a .NET7 macOS app using
dotnet publish -c Release
. Throws this error:Let me know if you need any additional info.