Skip to content

EC#: [return: ...] attribute sometimes causes IndexOutOfRangeException in InternalList #137

@qwertie

Description

@qwertie

Example case:

[return: MaybeNull]
public static T LastOrDefault<T>(this IListAndListSource<T> list, [AllowNull] T defaultValue = default(T)) =>
	LastOrDefault((IList<T>)list, defaultValue);
[return: MaybeNull] // Causes internal error
public static T FirstOrDefault<T>(this IListAndListSource<T> list, [AllowNull] T defaultValue = default(T)) =>
	FirstOrDefault((IList<T>)list, defaultValue);

Remarkably the first one is fine but the second one causes an error. Workaround: use #rawText

[return: MaybeNull]
public static T LastOrDefault<T>(this IListAndListSource<T> list, [AllowNull] T defaultValue = default(T)) =>
	LastOrDefault((IList<T>)list, defaultValue);
#rawText("[return: MaybeNull]");
public static T FirstOrDefault<T>(this IListAndListSource<T> list, [AllowNull] T defaultValue = default(T)) =>
	FirstOrDefault((IList<T>)list, defaultValue);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions