Xamarin-macios: VS Mac tries to register a class that already exists under a different namespace

Created on 3 Sep 2020  路  10Comments  路  Source: xamarin/xamarin-macios

Steps to Reproduce

  1. Create a Window Controller class with the following namespace: [DefaultNameSpace].[A_Directory_Name]
  2. Launch Xcode using storyboard and create a view controller and assign the custom class you created. Using Custom Class/Class
  3. Go back to Visual Studio:
    a. A warning message box pops up saying "A class named '[DefaultNameSpace].[Class_name] already exists but is registered as [Class_name]'. Would you like to update the [Register] attribute?
    b. Doesn't matter if I clicked yes or no, it will create a new class for me, even though it already exist.
  4. It will try to create a class that I just assigned with the default namespace: For ex: If my original class was Desktop.Settings.Password now it will try to register a new class called Password using Desktop namespace. The new class will be Desktop.Password.
  5. As you can imagine this is a huge problem, we have lots of classes that are using different namespaces and VS Mac will try to register and add a replacement for all of them. Because of the duplicate classes, the project will not build and run
  6. This was not an issue a few months ago, it happened with the 8.7, I believe.

Expected Behavior

VS Xamarin.MacIos should not try to see if the class exist with a different namespace and should skip that file

Actual Behavior

It creates classes that already exist for me.

Environment

=== Visual Studio Community 2019 for Mac ===

Version 8.7.4 (build 38)
Installation UUID: d17cc651-c982-431e-93b9-5d29d753e293
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

    Package version: 612000090

=== Mono Framework MDK ===

Runtime:
    Mono 6.12.0.90 (2020-02/d3daacdaa80) (64-bit)
    Package version: 612000090

=== Roslyn (Language Service) ===

3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878

=== NuGet ===

Version: 5.7.0.6702

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.401/Sdks
SDK Versions:
    3.1.401
    3.1.302
    3.1.301
    3.1.300
    3.1.200
    2.1.202
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    3.1.7
    3.1.6
    3.1.5
    3.1.4
    3.1.2
    2.1.21
    2.1.20
    2.1.19
    2.1.18
    2.1.17
    2.0.9

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 11.0.2.0 (Visual Studio Community)
Commit: xamarin-android/d16-7/025fde9
Android SDK: /Users/seyfettinkulgu/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        7.1 (API level 25)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/seyfettinkulgu/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.7.0.13
Hash: 8380518
Branch: remotes/origin/d16-7~2
Build date: 2020-08-19 22:18:28 UTC

=== Android Device Manager ===

Version: 16.7.0.24
Hash: bb090a3
Branch: remotes/origin/d16-7
Build date: 2020-08-19 22:18:52 UTC

=== Apple Developer Tools ===

Xcode 11.6 (16141)
Build 11E801a

=== Xamarin.Mac ===

Version: 6.20.2.2 (Visual Studio Community)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:44:59-0400

=== Xamarin Designer ===

Version: 16.7.0.492
Hash: f5afe667d
Branch: remotes/origin/d16-7-vsmac
Build date: 2020-07-10 18:42:54 UTC

=== Xamarin.iOS ===

Version: 13.20.2.2 (Visual Studio Community)
Hash: 817b6f72a
Branch: d16-7
Build date: 2020-07-18 18:45:00-0400

=== Build Information ===

Release ID: 807040038
Git revision: 7f322926a2e0a5fa0c1e3833215a191883f7514a
Build date: 2020-08-20 10:10:20-04
Build branch: release-8.7
Xamarin extensions: 7f322926a2e0a5fa0c1e3833215a191883f7514a

=== Operating System ===

Mac OS X 10.15.6
Darwin 19.6.0 Darwin Kernel Version 19.6.0
    Thu Jun 18 20:49:00 PDT 2020
    root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64


Build Logs

Example Project (If Possible)

VS bug #1193735

external-visual-studio-for-mac

Most helpful comment

Thanks, @whitneyschmidt I can verify that 8.7.5.19 fixes the issue.

All 10 comments

Moving this to VSMac area path since it is related to IDE/Xcode integration.

@sayfee That's great! I'll close out this issue and note that it is fixed in 8.6 :)

Well, the only problem is that 8.6 is the previous version. I was on 8.7.4. So, I don't know how this is a fix?
To me, it's still broken because something broke it after 8.7

Fair point - I read this too quickly!

I've notified the IDE team and I'll share this additional information with them.

@sayfee It looks like a fix was checked into 8.7.5.10 - can you try updating to that and let us know whether it is fixed?

It looks like this is a duplicate of: https://github.com/xamarin/xamarin-macios/issues/9372

Hi @whitneyschmidt
I checked out downloads page for Visual Studio for Mac, it looks like the latest release was stable 8.7.4. I didn't see 8.7.5.
And it looks like bet releases jumped from 8.7 to 8.8. I do want to use only stable versions.
Thanks for you help!

@sayfee Can you double-check whether it is available through the VS updater?

I'm able to see VS 8.7.5.19 available in the updater, which I can access with these steps: Visual Studio > Check for updates > Update channel dropdown > Select "Stable" > Download + update VS

Let us know whether that give you access to the stable version!

Thanks, @whitneyschmidt I can verify that 8.7.5.19 fixes the issue.

@sayfee That's great news! Thank you for closing the issue :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chamons picture chamons  路  4Comments

Mikilll94 picture Mikilll94  路  4Comments

wcoder picture wcoder  路  3Comments

therealjohn picture therealjohn  路  3Comments

sharmashiv picture sharmashiv  路  4Comments