@@ -37,7 +37,8 @@ public sealed partial class PInvokeGenerator : IDisposable
3737        private  readonly  Dictionary < NamedDecl ,  string >  _cursorNames ; 
3838        private  readonly  Dictionary < ( NamedDecl  namedDecl ,  bool  truncateForFunctionParameters ) ,  string >  _cursorQualifiedNames ; 
3939        private  readonly  Dictionary < ( Cursor  cursor ,  Cursor  context ,  Type  type ) ,  ( string  typeName ,  string  nativeTypeName ) >  _typeNames ; 
40-         private  readonly  Dictionary < string ,  HashSet < string > >  _validNameRemappings ; 
40+         private  readonly  Dictionary < string ,  HashSet < string > >  _allValidNameRemappings ; 
41+         private  readonly  Dictionary < string ,  HashSet < string > >  _traversedValidNameRemappings ; 
4142        private  readonly  Dictionary < CXXMethodDecl ,  uint >  _overloadIndices ; 
4243        private  readonly  Dictionary < Cursor ,  uint >  _isExcluded ; 
4344        private  readonly  Dictionary < string ,  bool >  _isTopLevelClassUnsafe ; 
@@ -100,13 +101,14 @@ public PInvokeGenerator(PInvokeGeneratorConfiguration config, Func<string, Strea
100101            _cursorNames  =  new  Dictionary < NamedDecl ,  string > ( ) ; 
101102            _cursorQualifiedNames  =  new  Dictionary < ( NamedDecl ,  bool ) ,  string > ( ) ; 
102103            _typeNames  =  new  Dictionary < ( Cursor ,  Cursor ,  Type ) ,  ( string ,  string ) > ( ) ; 
103-             _validNameRemappings  =  new  Dictionary < string ,  HashSet < string > > ( )  { 
104+             _allValidNameRemappings  =  new  Dictionary < string ,  HashSet < string > > ( )  { 
104105                [ "intptr_t" ]  =  new  HashSet < string > ( )  {  "IntPtr" ,  "nint"  } , 
105106                [ "ptrdiff_t" ]  =  new  HashSet < string > ( )  {  "IntPtr" ,  "nint"  } , 
106107                [ "size_t" ]  =  new  HashSet < string > ( )  {  "UIntPtr" ,  "nuint"  } , 
107108                [ "uintptr_t" ]  =  new  HashSet < string > ( )  {  "UIntPtr" ,  "nuint"  } , 
108109                [ "_GUID" ]  =  new  HashSet < string > ( )  {  "Guid"  } , 
109110            } ; 
111+             _traversedValidNameRemappings  =  new  Dictionary < string ,  HashSet < string > > ( ) ; 
110112            _overloadIndices  =  new  Dictionary < CXXMethodDecl ,  uint > ( ) ; 
111113            _isExcluded  =  new  Dictionary < Cursor ,  uint > ( ) ; 
112114            _isTopLevelClassUnsafe  =  new  Dictionary < string ,  bool > ( ) ; 
@@ -1239,7 +1241,7 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s
12391241
12401242                if  ( _config . LogPotentialTypedefRemappings ) 
12411243                { 
1242-                     foreach  ( var  kvp  in  _validNameRemappings ) 
1244+                     foreach  ( var  kvp  in  _traversedValidNameRemappings ) 
12431245                    { 
12441246                        var  name  =  kvp . Key ; 
12451247                        var  remappings  =  kvp . Value ; 
@@ -1248,7 +1250,14 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s
12481250                        { 
12491251                            AddDiagnostic ( DiagnosticLevel . Info ,  $ "Potential missing remapping '{ name } '. { GetFoundRemappingString ( name ,  remappings ) } ") ; 
12501252                        } 
1251-                         else  if  ( ! remappings . Contains ( remappedName )  &&  ( name  !=  remappedName )  &&  ! _config . ForceRemappedNames . Contains ( name ) ) 
1253+                     } 
1254+ 
1255+                     foreach  ( var  kvp  in  _allValidNameRemappings ) 
1256+                     { 
1257+                         var  name  =  kvp . Key ; 
1258+                         var  remappings  =  kvp . Value ; 
1259+ 
1260+                         if  ( _config . RemappedNames . TryGetValue ( name ,  out  var  remappedName )  &&  ! remappings . Contains ( remappedName )  &&  ( name  !=  remappedName )  &&  ! _config . ForceRemappedNames . Contains ( name ) ) 
12521261                        { 
12531262                            AddDiagnostic ( DiagnosticLevel . Info ,  $ "Potential invalid remapping '{ name } ={ remappedName } '. { GetFoundRemappingString ( name ,  remappings ) } ") ; 
12541263                        } 
@@ -1258,7 +1267,7 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s
12581267                    { 
12591268                        var  remappedName  =  _config . RemappedNames [ name ] ; 
12601269
1261-                         if  ( ! _validNameRemappings . ContainsKey ( name )  &&  ( name  !=  remappedName )  &&  ! _config . ForceRemappedNames . Contains ( name ) ) 
1270+                         if  ( ! _allValidNameRemappings . ContainsKey ( name )  &&  ( name  !=  remappedName )  &&  ! _config . ForceRemappedNames . Contains ( name ) ) 
12621271                        { 
12631272                            AddDiagnostic ( DiagnosticLevel . Info ,  $ "Potential invalid remapping '{ name } ={ remappedName } '. No remappings were found.") ; 
12641273                        } 
0 commit comments