[Mono-dev] Bug #360455
Stefan Noack
noackstefan at googlemail.com
Sun May 17 11:21:04 EDT 2009
I've been trying to fix https://bugzilla.novell.com/show_bug.cgi?id=360455.
"(g)mcs erroneously raises "x is never used" warning CS0067 with public events"
This happens when the containing class is generic but the event does not use the
generic type in it's signature. Therre is another test case that
reproduces the bug
without generics but contains a class with an abstract event and a derived class
implementing and using it. Here the warning is uttered erroneously, too.
I looked into the mcs code but I could not quite find out, what's
going on here, though.
I believe the interesting part may be that one:
ecore.cs: line 5651, constructor of EventExpr class
public EventExpr (EventInfo ei, Location loc)
{
EventInfo = ei;
// uninteresting code here
if (EventInfo is MyEventBuilder){
MyEventBuilder eb = (MyEventBuilder) EventInfo;
type = eb.EventType;
eb.SetUsed (); // here the event is
flagged as used
} else
type = EventInfo.EventHandlerType;
}
Here the event is flagged as used in the constructor of the EventExpr
that refers to it.
This is very elegant but as you can see there is nothing that sets the
flag in the
else branch of the second if clause. Looks to me like in the special
cases that trigger
the bug EventInfo is not a MyEventBuilder. (MyEventBuilder is declared
in class.cs,
you may want to look there and see what it does.)
I don't know how to cleanly set the flag in that case. Any Ideas?
Maybe I am completely wrong and the error is somewhere else in the code...
Best Regards,
Stefan
More information about the Mono-devel-list
mailing list