Replies: 2 comments 2 replies
-
We consider If you want to expose these methods you can always create a method to do so explicitly (you can also generate these methods with source generators if you want): public void EmitMySignal()
{
OnMySignal();
} You can also use C# reflection to access non-public methods: var obj = new MyClass();
var emitMySignal = typeof(MyClass).GetMethod("OnMySignal", BindingFlags.NonPublic | BindingFlags.Instance);
emitMySignal.Invoke(obj, null); Or using var obj = new MyClass();
EmitMySignal(obj);
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = "OnMySignal")]
extern static void EmitMySignal(MyClass obj); |
Beta Was this translation helpful? Give feedback.
-
I'm not sure that the current approach is idiomatic C#. Signals are right now defined with the I get the workaround, but the major disadvantage right now is that the |
Beta Was this translation helpful? Give feedback.
-
I just started using the newly generated
On{SignalName}
functions introduced by #68233. They make emitting signals a lot nicer (type safety, enum types,null
, ...).These functions are
protected virtual
in accordance with the C# guidelines. However, this does not align with the scope ofEmitSignal
which ispublic
. The latter makes sense in situations where signals are emitted outside of the signal defining class (e.g., when using some kind of EventBus).I think it might be worth considering to make the generated function
public virtual
to be more in line with the currentEmitSignal
implementation.Beta Was this translation helpful? Give feedback.
All reactions