Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Melnikov <mikhail_melnikov@epam.com>2018-04-27 14:54:16 +0300
committerJoel Martinez <joelmartinez@gmail.com>2018-04-27 22:46:20 +0300
commit89ef92404a729c67671e0daaa274320b9053bbd5 (patch)
tree42900884837df1f940cf8f7aec7c829eac435b2c /mdoc/mdoc.Test/BasicTests.cs
parent9d7610859c73d63bc4008e0de6595b9a72148a5b (diff)
Special treatment of ref-like structs to not produce Obsolete attribute
Added a unit test for MDocUpdater.GetCustomAttributes Added logic to skip the attribute `Obsolete` Changed test classes hierarchy Closes #225
Diffstat (limited to 'mdoc/mdoc.Test/BasicTests.cs')
-rw-r--r--mdoc/mdoc.Test/BasicTests.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/mdoc/mdoc.Test/BasicTests.cs b/mdoc/mdoc.Test/BasicTests.cs
new file mode 100644
index 00000000..cddbcbd8
--- /dev/null
+++ b/mdoc/mdoc.Test/BasicTests.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Mono.Cecil;
+
+namespace mdoc.Test
+{
+ public class BasicTests
+ {
+ protected Dictionary<string, ModuleDefinition> moduleCash = new Dictionary<string, ModuleDefinition>();
+ protected Dictionary<string, TypeDefinition> typesCash = new Dictionary<string, TypeDefinition>();
+
+ protected TypeDefinition GetType(string filepath, string classname)
+ {
+ if (typesCash.ContainsKey(classname))
+ return typesCash[classname];
+
+
+ if (!moduleCash.ContainsKey(filepath))
+ {
+ var readModule = ModuleDefinition.ReadModule(filepath);
+ moduleCash.Add(filepath, readModule);
+ }
+
+ var module = moduleCash[filepath];
+ var types = module.GetTypes();
+ var testclass = types
+ .SingleOrDefault(t => t.FullName == classname);
+ if (testclass == null)
+ {
+ throw new Exception($"Test was unable to find type {classname}");
+ }
+
+ var typeDef = testclass.Resolve();
+ typesCash.Add(classname, typeDef);
+ return typeDef;
+ }
+
+ protected virtual TypeDefinition GetType(Type type)
+ {
+ var moduleName = type.Module.FullyQualifiedName;
+ return GetType(moduleName, type.FullName);
+ }
+ }
+} \ No newline at end of file