答案 0 :(得分:3)
如果using System;
是递归的,那么,仅在“mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089”程序集中,这将是您将获得的类型冲突列表:
__过滤器,__ HLesults,<> c,<> c__DisplayClass11_0,<> c__DisplayClass4_0,AsyncCausalityStatus,AsyncReplySink,BIND_OPTS,BINDPTR,CALLCONV,CausalityRelation,CausalitySynchronousWork,CausalityTraceLevel,ChannelInfo,ConfiguredTaskAwaiter,CONNECTDATA,ContractHelper,DebugView ,Decoder,DESCKIND,DESCUNION,DictionaryEnumerator,Disposition,DISPPARAMS,ELEMDESC,Encoder,Entry,Enumerator,Environment,EventData,EXCEPINFO,ExplicitlySet,FILETIME,FUNCDESC,FUNCFLAGS,FUNCKIND,Getter,IDLDESC,IDLFLAG,IEnumerable,IEnumerator,IExpando,IMPLTYPEFLAGS ,InternalPartitionEnumerable,InternalPartitionEnumerator,INVOKEKIND,IReflect,KeyCollection,Keywords,LIBFLAGS,MdSigCallingConvention,NameInfo,Node,NodeEnumerator,OpFlags,PARAMDESC,PARAMFLAG,ParseFailureKind,Reader,RemoteAppEntry,Segment,SerializationMask,SinkStack,State,STATSTG,SYSKIND,Tasks,TokenType ,TYPEATTR,TYPEDESC,TypeEntry,TYPEFLAGS,TypeInfo,TypeKind,TYPEKIND,TYPELIBATTR,Un safeNativeMethods,ValueCollection,VARDESC,VARFLAGS,Variant,Win32
在我打开的当前项目中,加载了14个程序集,我将有792种类型的碰撞(定义了14,251种类型)。
这就是为什么它不是递归的。
以下是自己运行的方法:
var typeCollisions = String.Join(", ",
System
.AppDomain
.CurrentDomain
.GetAssemblies()
.SelectMany(a => a.GetTypes())
.GroupBy(x => x.Name)
.Where(x => x.Skip(1).Any())
.Select(x => x.Key)
.OrderBy(x => x));