Skip to content

Wrong OfType<T, TResult> signature? #333

Open
@ShenCiao

Description

@ShenCiao

Version

R3 1.3, installed by NuGet and used in a Godot project.

Issue

The observable extension function OfType takes two class parameters<T, TResult>, but the "T" is unnecessary. And the documented operator list shows it should be OfType<TResult>.

Image

Where

The method is defined in the file ObservableExtensions.cs.

Activity

jskang-cle

jskang-cle commented on May 16, 2025

@jskang-cle

You need generic parameter T to extend the Observable<T>. Otherwise the method won't compile.

ShenCiao

ShenCiao commented on May 17, 2025

@ShenCiao
Author

You need generic parameter T to extend the Observable<T>. Otherwise the method won't compile.

// "this" is a godot control
this.SignalAsObservable<InputEvent>(Control.SignalName.GuiInput)
        .OfType<InputEvent, InputEventMouseButton>()
        .Where(button => button.ButtonIndex == MouseButton.Left);

This is the actual code I'm writing, the SignalAsObservable gives the T.

jskang-cle

jskang-cle commented on May 19, 2025

@jskang-cle

Yes, the user doesn't have to specify the generic parameters. However, the method definition needs every generic parameter declared.

You cannot compile something like this,

public static Observable<TResult> OfType<TResult>(this Observable<T> source)
{
    // ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ShenCiao@jskang-cle

        Issue actions

          Wrong `OfType<T, TResult>` signature? · Issue #333 · Cysharp/R3