From f17cea771e008970e479241b8fa2edbf3cd6f5fa Mon Sep 17 00:00:00 2001 From: James Frowen Date: Sun, 19 Apr 2020 20:12:37 +0100 Subject: [PATCH] using IsDerivedFrom instead of while loop (#1739) --- Assets/Mirror/Editor/Weaver/Weaver.cs | 44 ++++++++------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/Assets/Mirror/Editor/Weaver/Weaver.cs b/Assets/Mirror/Editor/Weaver/Weaver.cs index 4889a444c..e93a08399 100644 --- a/Assets/Mirror/Editor/Weaver/Weaver.cs +++ b/Assets/Mirror/Editor/Weaver/Weaver.cs @@ -417,38 +417,20 @@ static bool WeaveSyncObject(TypeDefinition td) bool modified = false; - // are ANY parent classes SyncListStruct - TypeReference parent = td.BaseType; - while (parent != null) + if (td.IsDerivedFrom(SyncListType)) { - if (parent.FullName.StartsWith(SyncListType.FullName, StringComparison.Ordinal)) - { - SyncListProcessor.Process(td); - modified = true; - break; - } - if (parent.FullName.StartsWith(SyncSetType.FullName, StringComparison.Ordinal)) - { - SyncListProcessor.Process(td); - modified = true; - break; - } - if (parent.FullName.StartsWith(SyncDictionaryType.FullName, StringComparison.Ordinal)) - { - SyncDictionaryProcessor.Process(td); - modified = true; - break; - } - try - { - parent = parent.Resolve().BaseType; - } - catch (AssemblyResolutionException) - { - // this can happen for pluins. - //Console.WriteLine("AssemblyResolutionException: "+ ex.ToString()); - break; - } + SyncListProcessor.Process(td); + modified = true; + } + else if (td.IsDerivedFrom(SyncSetType)) + { + SyncListProcessor.Process(td); + modified = true; + } + else if (td.IsDerivedFrom(SyncDictionaryType)) + { + SyncDictionaryProcessor.Process(td); + modified = true; } // check for embedded types