You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
namespaceGu.Wpf.ValidationScope.UiTests{usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Reflection;usingNUnit.Framework;[Explicit("Script")]publicclassDumpAppDomain{[Test]publicvoidDumpNotExcludedAssemblies(){varexcludedAssemblies=ExcludedAssemblies();varnotExcluded=AppDomain.CurrentDomain.GetAssemblies().Where(a =>!excludedAssemblies.Contains(a.GetName().Name)).Select(a =>a.GetName().Name).OrderBy(x =>x).ToList();foreach(varassemblyNameinnotExcluded){Console.WriteLine($"\"{assemblyName}\",");}}[Test]publicvoidDumpExcludedAssembliesSorted(){varexcludedAssemblies=ExcludedAssemblies().OrderBy(x =>x).ToArray();foreach(varnameinexcludedAssemblies){Console.WriteLine($"\"{name}\",");}}privatestaticHashSet<string>ExcludedAssemblies(){// ReSharper disable once PossibleNullReferenceExceptionvarhashSet=(HashSet<string>)typeof(InputTypeCollectionConverter).GetNestedType("CompatibleTypeCache",BindingFlags.Static|BindingFlags.NonPublic).GetField("ExcludedAssemblies",BindingFlags.Static|BindingFlags.NonPublic).GetValue(null);returnnewHashSet<string>(hashSet);}}}
namespaceGu.Wpf.ValidationScope{usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Diagnostics;usingSystem.Globalization;usingSystem.IO;usingSystem.Linq;usingSystem.Reflection;usingSystem.Security;usingSystem.Text;usingSystem.Windows.Controls;usingSystem.Windows.Markup;publicclassInputTypeCollectionConverter:TypeConverter{privatestaticreadonlychar[]SeparatorChars={',',' '};publicoverrideboolCanConvertFrom(ITypeDescriptorContexttypeDescriptorContext,TypesourceType){returnsourceType==typeof(string)||sourceType==typeof(Type)||sourceType==typeof(TypeExtension)||typeof(IEnumerable<Type>).IsAssignableFrom(sourceType);}publicoverrideboolCanConvertTo(ITypeDescriptorContexttypeDescriptorContext,TypedestinationType){returnfalse;}publicoverrideobjectConvertFrom(ITypeDescriptorContexttypeDescriptorContext,CultureInfocultureInfo,objectsource){vartext=sourceasstring;if(text!=null){returnConvertFromText(text);}vartypes=sourceasIEnumerable<Type>;if(types!=null){returnnewInputTypeCollection(types);}vartype=sourceasType;if(type!=null){returnnewInputTypeCollection{type};}vartypeExtension=sourceasTypeExtension;if(typeExtension!=null){returnnewInputTypeCollection{typeExtension.Type};}returnbase.ConvertFrom(typeDescriptorContext,cultureInfo,source);}[SecurityCritical]publicoverrideobjectConvertTo(ITypeDescriptorContexttypeDescriptorContext,CultureInfocultureInfo,objectvalue,TypedestinationType){thrownewNotSupportedException();}privatestaticInputTypeCollectionConvertFromText(stringtext){vartypeNames=text.Split(SeparatorChars,StringSplitOptions.RemoveEmptyEntries).Select(x =>x.Trim()).ToArray();varinputTypeCollection=newInputTypeCollection();foreach(vartypeNameintypeNames){varmatch=CompatibleTypeCache.FindType(typeName);inputTypeCollection.Add(match);}returninputTypeCollection;}privatestaticclassCompatibleTypeCache{privatestaticreadonlyobjectGate=newobject();privatestaticreadonlyHashSet<Type>Types=newHashSet<Type>();privatestaticreadonlyList<Type>KnownInputTypes=InputTypeCollection.Default.ToList();privatestaticreadonlyHashSet<string>ExcludedAssemblies=newHashSet<string>{"Castle.Core","JetBrains.ReSharper.TaskRunnerFramework","JetBrains.ReSharper.UnitTestRunner.nUnit","JetBrains.ReSharper.UnitTestRunner.nUnit30","Mono.Cecil","Microsoft.Windows.Design.Extensibility","Microsoft.Windows.Design.Interaction","Microsoft.VisualStudio.DesignTools.Designer","Microsoft.VisualStudio.DesignTools.Designer.resources","Microsoft.VisualStudio.DesignTools.DesignerContract","Microsoft.VisualStudio.DesignTools.DesignerHost","Microsoft.VisualStudio.DesignTools.DesignerHost.resources","Microsoft.VisualStudio.DesignTools.Markup","Microsoft.VisualStudio.DesignTools.Platform","Microsoft.VisualStudio.DesignTools.Platform.resources","Microsoft.VisualStudio.DesignTools.Utility","Microsoft.VisualStudio.DesignTools.Utility.resources","Microsoft.VisualStudio.DesignTools.WpfDesigner","Microsoft.VisualStudio.DesignTools.XamlDesigner","Microsoft.VisualStudio.DesignTools.XamlDesigner.resources","Microsoft.VisualStudio.RemoteControl","Microsoft.VisualStudio.Telemetry","Microsoft.VisualStudio.Utilities.Internal","mscorlib","Newtonsoft.Json","nunit.engine","nunit.engine.api","nunit.framework","PresentationFramework.Aero","SMDiagnostics","System","System.ComponentModel.DataAnnotations","System.Configuration","System.Core","System.Data","System.Drawing","System.Numerics","System.Runtime.Remoting","System.Runtime.Serialization","System.ServiceModel.Internals","System.Web","System.Xml","System.Xml.Linq","System.Security","System.Windows.Forms","TestStack.White","UIAutomationClient","UIAutomationProvider","UIAutomationTypes","XDesProc",};privatestaticreadonlyStringBuilderErrorBuilder=newStringBuilder();staticCompatibleTypeCache(){foreach(varassemblyinAppDomain.CurrentDomain.GetAssemblies()){AddCompatibleTypes(assembly);}AppDomain.CurrentDomain.AssemblyLoad+=(sender,args)=>AddCompatibleTypes(args.LoadedAssembly);}// ReSharper disable once UnusedMember.LocalinternalstaticstringErrorText=>ErrorBuilder.ToString();internalstaticTypeFindType(stringtypeName){Typematch;try{lock(Gate){match=KnownInputTypes.Find(t =>IsMatch(t,typeName));if(match!=null){returnmatch;}match=Types.SingleOrDefault(t =>IsMatch(t,typeName));}}catch(Exception){varerrorBuilder=newStringBuilder();errorBuilder.AppendLine($"Found more than one match for {typeName}");lock(Gate){varmatches=Types.Where(t =>IsMatch(t,typeName));foreach(vartypeinmatches){errorBuilder.AppendLine($" - {type.FullName} in assembly: {type.Assembly.FullName}");}}if(!IsFullName(typeName)){errorBuilder.AppendLine($"Try specifying full name: {typeof(TextBox).FullName}");}thrownewInvalidOperationException(errorBuilder.ToString());}if(match==null){thrownewInvalidOperationException($"Did not find a match for for {typeName}");}returnmatch;}privatestaticboolIsMatch(Typetype,stringname){returntype.Name==name||type.FullName==name;}privatestaticboolIsFullName(stringtypeName){returntypeName.Contains('.');}privatestaticvoidAddCompatibleTypes(Assemblyassembly){Debug.WriteLine(assembly.FullName);if(ExcludedAssemblies.Contains(assembly.GetName().Name)){return;}try{lock(Gate){foreach(varcompatibleTypeinassembly.GetTypes().Where(InputTypeCollection.IsCompatibleType)){if(Types.Add(compatibleType)){if(KnownInputTypes.Contains(compatibleType)){continue;}if(KnownInputTypes.Any(t =>t.IsAssignableFrom(compatibleType))){KnownInputTypes.Add(compatibleType);}}else{Trace.WriteLine($"Type {compatibleType.FullName} was already added");}}}}catch(ReflectionTypeLoadExceptionex){// http://stackoverflow.com/a/8824250/1069200foreach(varexSubinex.LoaderExceptions){ErrorBuilder.AppendLine(exSub.Message);varexFileNotFound=exSubasFileNotFoundException;if(!string.IsNullOrEmpty(exFileNotFound?.FusionLog)){ErrorBuilder.AppendLine(exFileNotFound.FusionLog);}ErrorBuilder.AppendLine();}}catch(Exceptione){varmessage=$"Could not process assembly {assembly.FullName}. Exception: {e.Message}";Trace.WriteLine(message);ErrorBuilder.AppendLine(message);}}}}}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: