ObservableEvents icon indicating copy to clipboard operation
ObservableEvents copied to clipboard

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

Open lighterhy opened this issue 3 years ago • 4 comments

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

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.

lighterhy avatar May 03 '22 09:05 lighterhy

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

glennawatson avatar May 03 '22 09:05 glennawatson

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.

mysteryx93 avatar Aug 02 '22 23:08 mysteryx93

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

glennawatson avatar Aug 03 '22 02:08 glennawatson

I think everyone got family issues lately.

mysteryx93 avatar Aug 03 '22 04:08 mysteryx93