mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Weaver: add explanations for Is vs. IsDerivedFrom
This commit is contained in:
parent
4c0c5e74d3
commit
859138f137
@ -12,8 +12,18 @@ public static bool Is(this TypeReference td, Type type) =>
|
||||
? td.GetElementType().FullName == type.FullName
|
||||
: td.FullName == type.FullName;
|
||||
|
||||
// check if 'td' is exactly of type T.
|
||||
// it does not check if any base type is of <T>, only the specific type.
|
||||
// for example:
|
||||
// NetworkConnection Is NetworkConnection: true
|
||||
// NetworkConnectionToClient Is NetworkConnection: false
|
||||
public static bool Is<T>(this TypeReference td) => Is(td, typeof(T));
|
||||
|
||||
// check if 'tr' is derived from T.
|
||||
// it does not check if 'tr' is exactly T.
|
||||
// for example:
|
||||
// NetworkConnection IsDerivedFrom<NetworkConnection>: false
|
||||
// NetworkConnectionToClient IsDerivedFrom<NetworkConnection>: true
|
||||
public static bool IsDerivedFrom<T>(this TypeReference tr) => IsDerivedFrom(tr, typeof(T));
|
||||
|
||||
public static bool IsDerivedFrom(this TypeReference tr, Type baseClass)
|
||||
@ -266,7 +276,7 @@ public static AssemblyNameReference FindReference(this ModuleDefinition module,
|
||||
|
||||
// Takes generic arguments from child class and applies them to parent reference, if possible
|
||||
// eg makes `Base<T>` in Child<int> : Base<int> have `int` instead of `T`
|
||||
// Originally by James-Frowen under MIT
|
||||
// Originally by James-Frowen under MIT
|
||||
// https://github.com/MirageNet/Mirage/commit/cf91e1d54796866d2cf87f8e919bb5c681977e45
|
||||
public static TypeReference ApplyGenericParameters(this TypeReference parentReference,
|
||||
TypeReference childReference)
|
||||
@ -306,7 +316,7 @@ public static TypeReference ApplyGenericParameters(this TypeReference parentRefe
|
||||
}
|
||||
|
||||
// Finds the type reference for a generic parameter with the provided name in the child reference
|
||||
// Originally by James-Frowen under MIT
|
||||
// Originally by James-Frowen under MIT
|
||||
// https://github.com/MirageNet/Mirage/commit/cf91e1d54796866d2cf87f8e919bb5c681977e45
|
||||
static TypeReference FindMatchingGenericArgument(TypeReference childReference, string paramName)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user