From f19ba3eb3053e59a3a7a2ca7c167b466bcbe0fb8 Mon Sep 17 00:00:00 2001 From: walon Date: Tue, 5 Nov 2024 18:19:13 +0800 Subject: [PATCH] [fix] fix the bug in GenericReferenceWriter where _systemTypePattern did not properly escape the '.' in type names. This caused issues when compiler-generated anonymous types and functions contained string sequences like 'System-Int', incorrectly matching them to 'System.Int', resulting in runtime exceptions. --- Editor/AOT/GenericReferenceWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Editor/AOT/GenericReferenceWriter.cs b/Editor/AOT/GenericReferenceWriter.cs index 20612c4..1b6021f 100644 --- a/Editor/AOT/GenericReferenceWriter.cs +++ b/Editor/AOT/GenericReferenceWriter.cs @@ -39,7 +39,7 @@ namespace HybridCLR.Editor.AOT { _typeSimpleNameMapping.Add(e.Key.FullName, e.Value); } - _systemTypePattern = new Regex(string.Join("|", _typeSimpleNameMapping.Keys.Select (k => $@"\b{k}\b"))); + _systemTypePattern = new Regex(string.Join("|", _typeSimpleNameMapping.Keys.Select (k => $@"\b{Regex.Escape(k)}\b"))); } public string PrettifyTypeSig(string typeSig)