Skip to content

Change the [NotImplemented] attribute to something more descriptive: [ReadOnly] #8481

Open
@rolfbjarne

Description

@rolfbjarne

Sometimes Apple provides an immutable class and a mutable subclass. Example: AVMetadataItem and AVMutableMetadataItem. If a developer creates an instance of an AVMetadataItem and tries to set a property, a NotImplementedException will be thrown:

[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
public virtual NSString? MetadataIdentifier {
	[Export ("identifier")]
	get {
            ...
	}
	[NotImplemented ()]
	set {
		throw new NotImplementedException ();
	}
}

This is confusing for developers, every now and then we get bug reports about it:

Idea: change the generated code to throw something else with a better description:

[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
public virtual NSString? MetadataIdentifier {
	[Export ("identifier")]
	get {
            ...
	}
	[NotImplemented ()]
	set {
		throw new NotSupportedException ("This member is read-only. Use an instance of the mutable subclass AVMutableMetadataItem instead.");
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThe issue or pull request is an enhancementgeneratorIssues affecting the generatorhelp wantedThis is an issue or pull request where we request help from the community to fix or completeiOSIssues affecting iOSmacOSIssues affecting macOS

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions