public DisplayNameSignatureBenchmark() { _assembly = AssemblyDef.Create(TestFile); CRefPath path = CRefPath.Parse(TestMethod1); _method1 = _assembly.FindType(path.Namespace, path.TypeName).Methods.Find(m => m.Name == path.ElementName); path = CRefPath.Parse(TestMethod2); _method2 = _assembly.FindType(path.Namespace, path.TypeName).Methods.Find(m => m.Name == path.ElementName); }
public void GenerateMap_WhenAssemblyHasTypesWithoutNamespace_TypesAreContainedInNoneNamespaceContainer() { const string TypeName = "Issue45_TypeWithNoNamespace"; const string NoneNamespaceName = "NoneNamespaces"; List <DocumentedAssembly> assemblies = new List <DocumentedAssembly>(); DocumentedAssembly documentedAssembly = new DocumentedAssembly { FileName = DocumentationFile }; EntryCreator creator = new EntryCreator(); assemblies.Add(documentedAssembly); GroupedNamespaceDocumentMapper mapper = new GroupedNamespaceDocumentMapper(assemblies, false, creator); DocumentMap result = mapper.GenerateMap(); AssemblyDef assembly = documentedAssembly.LoadedAssembly; TypeDef type = assembly.FindType(string.Empty, TypeName); Entry entry = result.FindById(type.GetGloballyUniqueId()); Assert.AreSame(type, entry.Item); // the type has been mapped Assert.AreEqual(NoneNamespaceName, entry.Parent.Parent.SubKey); // is part of the nonenamespace container }
public ClassFormatterBenchmark() { AssemblyDef _assemblyDef = AssemblyDef.Create(TestFile); TypeDef typeDef = _assemblyDef.FindType(TypeNamespace, TypeName); _cSharpFormatter = SyntaxFactory.Create(typeDef, Languages.CSharp); _vbFormatter = SyntaxFactory.Create(typeDef, Languages.VisualBasic); }
private void DoTest(string space, string type, string expected) { TypeDef typeDef = _assemblyDef.FindType(space, type); IFormatter formatter = CreateFormatter(typeDef); string result = formatter.Format().ToString(); Assert.AreEqual(expected, result); }
private TypeDef GetDelegateFromTestAssembly() { // having to load a entire library each time for a test is not great, need // to try and refactor the code to enabled this to become less painful string dir = System.AppDomain.CurrentDomain.BaseDirectory; AssemblyDef assemblyDef = AssemblyDef.Create(System.IO.Path.Combine(dir, TestFile)); return(assemblyDef.FindType("DocumentationTest.AllOutputTypesClass", "D")); }
private void TestIt(string method, string expected) { TypeDef container = _assemblyDef.FindType(NamespaceName, TypeName); MethodDef testMethod = container.Methods.First(p => p.Name == method); IFormatter formatter = CreateFormatter(testMethod); SyntaxTokenCollection tokens = formatter.Format(); Assert.AreEqual(expected, tokens.ToString()); }
public void ByRef_TokenIsSetForRefParameters() { TypeDef typeDef = _assemblyDef.FindType("DocumentationTest", "AllOutputTypesClass"); MethodDef method = typeDef.GetMethods().First(p => p.Name == "bb"); ParamDef refParam = method.Parameters.Find(p => p.Name == "y"); Signature sig = method.Signiture; // get the details of the byref parameter ParamSignatureToken byRefToken = method.Signiture.GetParameterTokens()[refParam.Sequence - 1]; ParamSignatureToken notRefToken = method.Signiture.GetParameterTokens()[0]; Assert.IsTrue(byRefToken.IsByRef); Assert.IsFalse(notRefToken.IsByRef); }
public void Bug45_ClassesWithNoNamspace_WhenFindTypeInAssembly_TypeReturned() { // [#45] we cant currently find types without namespaces when searching this is a bug and // needs to be resolved. This however also manifests itself in the document mappers and we // need to check the export code as well (which uses document mappers). TypeDef found = _assemblyDef.FindType(string.Empty, "Issue45_TypeWithNoNamespace"); Assert.IsNotNull(found); Assert.AreEqual(string.Empty, found.Namespace); Assert.AreEqual("Issue45_TypeWithNoNamespace", found.Name); }