Bug 29154 - Add default arguments or overloads for NSLayoutConstraint.Create
Summary: Add default arguments or overloads for NSLayoutConstraint.Create
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 2.0.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: master
Assignee: Chris Hamons
Depends on:
Reported: 2015-04-16 11:10 UTC by Aaron Bockover [MSFT]
Modified: 2016-02-24 20:55 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Aaron Bockover [MSFT] 2015-04-16 11:10:30 UTC
Constraints represent linear equations of the form view1.attr1 <relation> multiplier × view2.attr2 + constant.

Currently we have bound:

	NSLayoutConstraint Create (
		NSObject view1,
		NSLayoutAttribute attribute1,
		NSLayoutRelation relation,
		[NullAllowed] NSObject view2,
		NSLayoutAttribute attribute2,
		nfloat multiplier,
		nfloat constant)

I would like to specify default values for the last four arguments:

	NSLayoutConstraint Create (
		NSObject view1,
		NSLayoutAttribute attribute1,
		NSLayoutRelation relation,
		[NullAllowed] NSObject view2 = null,
		NSLayoutAttribute attribute2 = NSLayoutAttribute.NoAttribute,
		nfloat multiplier = 1,
		nfloat constant = 0)

The defaults for multiplier=1, constant=0 is common (e.g. setting view1's width to that of view2's). Regarding the view2 and attribute2 arguments, the docs specify "if the constraint you wish to express does not have a second view and attribute, use nil and NSLayoutAttributeNotAnAttribute."

Whether this is implemented as setting default arguments or new overloads doesn't matter to me, though I almost think at least for the (view2=null, attribute2=NSLayoutAttribute.NoAttribute) scenario it would be better to provide a full new overload since the _only_ valid value for attribute2 is NSLayoutAttribute.NoAttribute when view2 is null.

Comment 1 Timothy Risi 2016-02-24 20:55:19 UTC
Fixed on master / 19b0bb1adb863f2c5fce2689b5e44a1e925c1cbb