mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Source gen reorganizations + component unpause generator. This commit (and subsequent commits) aims to clean up our Roslyn plugin (source gens + analyzers) stack to more sanely re-use common code I also built a new source-gen that automatically generates unpausing implementations for components, incrementing attributed TimeSpan field when unpaused. * Fix warnings in all Roslyn projects
29 lines
795 B
C#
29 lines
795 B
C#
using Microsoft.CodeAnalysis;
|
|
|
|
namespace Robust.Roslyn.Shared;
|
|
|
|
#nullable enable
|
|
|
|
public static class TypeSymbolHelper
|
|
{
|
|
public static bool ShittyTypeMatch(INamedTypeSymbol type, string attributeMetadataName)
|
|
{
|
|
// Doing it like this only allocates when the type actually matches, which is good enough for me right now.
|
|
if (!attributeMetadataName.EndsWith(type.Name))
|
|
return false;
|
|
|
|
return type.ToDisplayString() == attributeMetadataName;
|
|
}
|
|
|
|
public static bool ImplementsInterface(INamedTypeSymbol type, string interfaceTypeName)
|
|
{
|
|
foreach (var interfaceType in type.AllInterfaces)
|
|
{
|
|
if (ShittyTypeMatch(interfaceType, interfaceTypeName))
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|