Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObservableEvents do not work with generic classes like ObservableCollection<T>. #117

Open
lighterhy opened this issue May 3, 2022 · 4 comments

Comments

@lighterhy
Copy link

lighterhy commented May 3, 2022

ObservableEvents do not work with generic classes like ObservableCollection.

Build the following code:

public class Class1<T>
{
    public event EventHandler TestEvent;

    void TestMethod()
    {
        ObservableCollection<Class1<int>> collection = new();

        Class1<int> c = new();
        c.Events().TestEvent.Subscribe();
        collection.Events().PropertyChangedEventHandler.Subscribe(x => { });
    }
}

will cause error:
1>CSC : warning CS8785: Generator 'EventGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName 'SourceClassClassLibrary1.Class1<System.Int32>-InstanceEvents.SourceGenerated.cs' contains an invalid character '<' at position 31. 1>C:\Projects\ClassLibrary1\ClassLibrary1\Class1.cs(5,7,5,22): error CS0246: The type or namespace name 'ReactiveMarbles' could not be found (are you missing a using directive or an assembly reference?)

I think this is because '<' is not a valid character for Windows paths.

@glennawatson
Copy link
Member

That makes sense, I'll see if I can get some time this weekend to fix it for you. Otherwise can accept a PR.

@mysteryx93
Copy link

Tried this library in a generic class, in JetBrains Rider.

I add this, fine.

 using ReactiveMarbles.ObservableEvents;

as soon as I type this.Events()., Events turns red and ReactiveMarbles is no longer a recognized namespace.

@glennawatson
Copy link
Member

Yeah, let me see if I can solve this one for you on the weekend. I've been having some family issues the last couple of months but hope to get some time this weekend to

@mysteryx93
Copy link

I think everyone got family issues lately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants