mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Add ICloneable support to ComponentNetworkGenerator (#5656)
This commit is contained in:
@@ -746,7 +746,17 @@ public partial class {componentName}{deltaInterface}
|
||||
|
||||
private static bool IsCloneType(ITypeSymbol type)
|
||||
{
|
||||
if (type is not INamedTypeSymbol named || !named.IsGenericType)
|
||||
if (type is not INamedTypeSymbol named)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ImplementsInterface(named, nameof(ICloneable)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!named.IsGenericType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -758,5 +768,18 @@ public partial class {componentName}{deltaInterface}
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
private static bool ImplementsInterface(ITypeSymbol type, string interfaceName)
|
||||
{
|
||||
foreach (var interfaceType in type.AllInterfaces)
|
||||
{
|
||||
if (interfaceType.ToDisplayString().Contains(interfaceName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user