Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Comparing Enum to Object crashes ItemComparer #15263

Merged
merged 1 commit into from
May 31, 2022
Merged

Conversation

fntc
Copy link
Contributor

@fntc fntc commented Mar 28, 2022

Description of Change

When an different types are used via Bindings on a Collectionview the ItemComparer can crash the application.

Issues Resolved

When valueA passed to ItemComparer is and Enum and valueB is an object, the Enum.CompareTo will throw an exception.

Sample:

var a=FooEnum.One;
var b = new CrazyObject();
	
ItemComparer.AreEquals(a,b);
// -> ArgumentException: Object must be the same type as the enum. The type passed in was 'CrazyObject'; the enum type was 'FooEnum'.

API Changes

None

Platforms Affected

  • iOS

Behavioral/Visual Changes

None (no Exception in Renderer, thus no crash)

Before/After Screenshots

Not applicable

Testing Procedure

See Code sample above, code can be unittested.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

When valueA passed to ItemComparer is and Enum and valueB is an object, the Enum.CompareTo will throw an exception.

Sample:
var a=FooEnum.One;
var b = new CrazyObject();
	
ItemComparer.AreEquals(a,b);
// -> ArgumentException: Object must be the same type as the enum. The type passed in was 'CrazyObject'; the enum type was 'FooEnum'.
@fntc
Copy link
Contributor Author

fntc commented Mar 28, 2022

Bug #15264

@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis jfversluis merged commit 6fa6d9f into xamarin:5.0.0 May 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants