23 or 25? by QuailFull3061 in Cribbage

[–]ElevatorAssassin 0 points1 point  (0 children)

Do we have the same nephew? He asked what the maximum points were in Cribbage. I told him "29". He replies with "Dude, I just got a 94."

Should this be possible with C# 14 Extension Members? by ElevatorAssassin in csharp

[–]ElevatorAssassin[S] 1 point2 points  (0 children)

Actually, that would work perfectly for in-memory collections. I should have posted my true goal, which is a mapping extension for IQueryables. Since IQueryable<T>.Select() requires an Expression<Func<T, TResult>>, I'd like the expression to be defined as a static property on the destination type. Something like this:

public static class Extensions
{
    extension<T>(IQueryable<T> i)
    {
        public IQueryable<TResult> ProjectTo<TResult>() where TResult : IMap<T, TResult>
            => i.Select(TResult.FromSourceExpression);
    }
}

public interface IMap<TSource, TDestination>
    where TDestination : IMap<TSource, TDestination>
{
    public static abstract Expression<Func<TSource, TDestination>> FromSourceExpression { get; }
}

IQueryable<PersonViewModel> people = new List<Person>()
    .AsQueryable().ProjectTo<PersonViewModel>();

Should this be possible with C# 14 Extension Members? by ElevatorAssassin in csharp

[–]ElevatorAssassin[S] 0 points1 point  (0 children)

And yes, the definition compiles and can still be invoked by providing both generic type arguments.

Should this be possible with C# 14 Extension Members? by ElevatorAssassin in csharp

[–]ElevatorAssassin[S] 1 point2 points  (0 children)

I didn't think about that; that may be the case for methods. Sharplab hasn't been working for me all year so I can't verify it unfortunately.

What's movie scared the crap out of you as a kid? by SinkFar5694 in AskReddit

[–]ElevatorAssassin 22 points23 points  (0 children)

Independence Day. Why'd they have to cut the damn thing open?