Custom controls are not imported in .h file when generating XCode prj

Open
#242 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp, macos
Domain
cli, tooling

Research direction

Start by reproducing the issue with the xcsync generate command using the shown PrimaryButton outlet, then trace how it generates ViewController.h and determines imports. Done means the generated header imports the file defining PrimaryButton and a subsequent sync preserves the custom outlet.

Written by the indexing model from the issue text.

Description

Is there an existing issue for this?
  • I have searched the existing issues
Apple platform

macOS

Framework version

Other

Describe the bug

If I have such a custom control

    [Register("PrimaryButton")]
    public class PrimaryButton : NSButton
    {
        public PrimaryButton(NativeHandle handle) : base(handle)
        {
            Initialize();
        }

        private void Initialize()
        {
            SetButtonType(NSButtonType.MomentaryPushIn);
            UpdateBezelColor();
        }

        private void UpdateBezelColor() => BezelColor = Enabled ? NSColor.ControlAccent : null;

        public override bool Enabled
        {
            get => base.Enabled;
            set
            {
                base.Enabled = value;
                UpdateBezelColor();
            }
        }
    }

and later this code

namespace TestCustomControl
{
	[Register ("ViewController")]
	partial class ViewController
	{
		[Outlet]
		TestCustomControl.PrimaryButton CustomButton { get; set; }
		
		void ReleaseDesignerOutlets ()
		{
			if (CustomButton != null) {
				CustomButton.Dispose ();
				CustomButton = null;
			}
		}
	}
}

xcsync generate generates ViewController.h file without import PrimaryButton.

#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>


@interface ViewController : NSViewController {
	PrimaryButton *_CustomButton;
}

@property (nonatomic, retain) IBOutlet PrimaryButton *CustomButton;

@end

This breaks sync command because it cannot probably resolve the PrimaryButton object and it will generate ViewController without PrimaryButton outlet.

Expected Behavior

The .h file is generated with correct import files.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info
dotnet dotnet --info
.NET SDK:
 Version:           10.0.201
 Commit:            4d3023de60
 Workload version:  10.0.201
 MSBuild version:   18.3.0-release-26153-122+4d3023de6

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  26.4
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/10.0.201/

.NET workloads installed:
 [macos]
   Installation Source: SDK 10.0.200
   Manifest Version:    26.2.10217/10.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.sdk.macos/26.2.10217/WorkloadManifest.json
   Install Type:        FileBased

 [maui-maccatalyst]
   Installation Source: SDK 10.0.200
   Manifest Version:    10.0.20/10.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.sdk.maui/10.0.20/WorkloadManifest.json
   Install Type:        FileBased

 [maccatalyst]
   Installation Source: SDK 10.0.200
   Manifest Version:    26.2.10217/10.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.sdk.maccatalyst/26.2.10217/WorkloadManifest.json
   Install Type:        FileBased

 [wasm-tools-net6]
   Installation Source: SDK 10.0.200
   Manifest Version:    10.0.105/10.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/10.0.100/microsoft.net.workload.mono.toolchain.net6/10.0.105/WorkloadManifest.json
   Install Type:        FileBased
Anything else?

No response

Dominant language
C#
Stars
25
Forks
10
Avg merge
12h 50m
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/xcsync

All issues in dotnet/xcsync

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.