44
55namespace CLRSharp
66{
7-
7+
88 public class CLRSharp_Environment : ICLRSharp_Environment
99 {
1010 public string version
1111 {
1212 get
1313 {
14- return "0.39.7Beta " ;
14+ return "0.43Beta " ;
1515 }
1616 }
1717 public ICLRSharp_Logger logger
@@ -46,6 +46,8 @@ public void LoadModule(System.IO.Stream dllStream, System.IO.Stream pdbStream, M
4646 {
4747 if ( moduleref . Contains ( ar . Name ) == false )
4848 moduleref . Add ( ar . Name ) ;
49+ if ( moduleref . Contains ( ar . FullName ) == false )
50+ moduleref . Add ( ar . FullName ) ;
4951 }
5052 }
5153 //mapModule[module.Name] = module;
@@ -54,7 +56,7 @@ public void LoadModule(System.IO.Stream dllStream, System.IO.Stream pdbStream, M
5456 foreach ( var t in module . Types )
5557 {
5658
57- mapType [ t . FullName ] = new Type_Common_CLRSharp ( this , t ) ;
59+ mapType [ t . FullName ] = new Type_Common_CLRSharp ( this , t ) ;
5860
5961 }
6062 }
@@ -149,7 +151,10 @@ public ICLRType GetType(string fullname)
149151 checkname = fullnameT . Substring ( lastsplitpos + 1 , i - lastsplitpos - 1 ) ;
150152 var subtype = GetType ( checkname ) ;
151153 subTypes . Add ( subtype ) ;
152- if ( subtype is ICLRType_Sharp ) subtype = GetType ( typeof ( CLRSharp_Instance ) ) ;
154+ if ( ! subtype . IsEnum ( ) && subtype is ICLRType_Sharp )
155+ {
156+ subtype = GetType ( typeof ( CLRSharp_Instance ) ) ;
157+ }
153158 outname += "[" + subtype . FullNameWithAssembly + "]" ;
154159 lastsplitpos = i ;
155160 }
@@ -172,7 +177,13 @@ public ICLRType GetType(string fullname)
172177 checkname = fullnameT . Substring ( lastsplitpos + 1 , i - lastsplitpos - 1 ) ;
173178 var subtype = GetType ( checkname ) ;
174179 subTypes . Add ( subtype ) ;
175- if ( subtype is ICLRType_Sharp ) subtype = GetType ( typeof ( CLRSharp_Instance ) ) ;
180+
181+ if ( ! subtype . IsEnum ( ) && subtype is ICLRType_Sharp )
182+ {
183+
184+ subtype = GetType ( typeof ( CLRSharp_Instance ) ) ;
185+ }
186+
176187 outname += "[" + subtype . FullNameWithAssembly + "]," ;
177188 lastsplitpos = i ;
178189 }
@@ -215,11 +226,31 @@ public ICLRType GetType(string fullname)
215226 }
216227 }
217228 }
229+
218230 if ( t != null )
219231 {
232+ //之所以做这么扭曲的设计,是因为Unity的Type.Fullname 实现错误,导致在Unity环境Type.FullName不一致
233+ if ( t . FullName . Contains ( "CLRSharp.CLRSharp_Instance" ) == false )
234+ {
235+ b = mapType . TryGetValue ( t . FullName , out type ) ;
236+ if ( b )
237+ {
238+ //mapType[fullname] = type;
239+ return type ;
240+ }
241+ type = new Type_Common_System ( this , t , subTypes . ToArray ( ) ) ;
242+ mapType [ t . FullName ] = type ;
243+ return type ;
244+ }
245+ else
246+ {
247+
248+ }
220249 type = new Type_Common_System ( this , t , subTypes . ToArray ( ) ) ;
250+ mapType [ fullname ] = type ;
251+ //mapType[t.FullName] = type;
221252 }
222- mapType [ fullname ] = type ;
253+
223254 }
224255 return type ;
225256 }
@@ -231,7 +262,7 @@ public ICLRType GetType(System.Type systemType)
231262 bool b = mapType . TryGetValue ( systemType . FullName , out type ) ;
232263 if ( ! b )
233264 {
234- type = new Type_Common_System ( this , systemType , null ) ;
265+ type = new Type_Common_System ( this , systemType , null ) ;
235266 mapType [ systemType . FullName ] = type ;
236267 }
237268 return type ;
0 commit comments