Bug 28037 - Enum values must not shift by ulong
Summary: Enum values must not shift by ulong
Status: RESOLVED FIXED
Alias: None
Product: Objective Sharpie
Classification: Desktop
Component: General ()
Version: 2.0.3
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Aaron Bockover [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-03-14 15:37 UTC by Dave Dunkin
Modified: 2015-04-07 01:52 UTC (History)
1 user (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Dave Dunkin 2015-03-14 15:37:00 UTC
If an enum is a ulong and has a value set by shifts, the generated code shifts by a ulong, which is illegal. It should always shift by an int.

Example from Pop:
	[Native]
	public enum POPAnimationClampFlags : ulong
	{
		None = 0uL,
		Start = 0uL << 1uL,
		End = 1uL << 1uL,
		Both = kPOPAnimationClampEnd | kPOPAnimationClampStart
	}
Comment 1 Aaron Bockover [MSFT] 2015-03-15 12:15:55 UTC
Good catch. This is due to NRefactory's lame writing of literals - it always tacks on the 'u' and 'L' suffixes for uint, long, and ulong primitives.

I've overridden the writer for those primitives such that if a UInt32, Int64, or UInt64 can fit safely into an Int32, it will convert them to Int32 before writing.

This wasn't specific to the RHS of a shift, rather any primitive integer literal. The type of the literal is determined by the type of the encapsulating enum.