Reputation: 5615
I have the following hierarchy of classes:
public abstract class SerializedDelegateBase<TDelegate, TTarget>
where TDelegate : class
where TTarget : class
{
...
}
public abstract class SerializedMBDelegateBase<TDelegate> : SerializedDelegateBase<TDelegate, MonoBehaviour> where TDelegate : class
{
...
}
public class ParameterizedSerializedDelegate<T> : SerializedMBDelegateBase<Action<T>> where T : EventArgs
{
...
}
And finally:
[Serializable]
public class OnTransitionArg : EventArgs
{
public string TransitionName { set; get; }
}
[Serializable]
public class OnTransitionDelegate : ParameterizedSerializedDelegate<OnTransitionArg> { }
Now for some strange reason, I'm getting "The non-generic type 'ParameterizedSerializedDelegate' cannot be used with type arguments" on my OnTransitionDelegate
when I'm inheriting from ParameterizedSerializedDelegate
I have no idea why.
Anybody?
Thanks!
EDIT:
I should probably mention that the classes are in different files. I just tried a minimal but similar setup in terms of the generic arguments in one file, it worked! - I don't know what's different about my real setup...
Upvotes: 1
Views: 6257
Reputation: 6902
@vexe's solution worked for me but I worked out what I did to reproduce it (explanation will use original question type names).
In VS2013, this can happen when you are using the CTRL-.
shortcut menu and not paying attention. Rather than choosing "Add << namespace >>", it is possible to select "Generate class for...", which will create a new stub class called ParameterizedSerializedDelegate
in the same folder as OnTransitionDelegate
.
What is confusing is that if you hit F12
(go to definition) on ParameterizedSerializedDelegate
in the example above, it will find the generic version of it and take you there - even if the namespace is not available in that file.
Upvotes: 0
Reputation: 5615
It seems that I was editing 'another' version of the ParameterizedSerializedDelegate
file - and so the one VS was looking at was different.
Upvotes: 2