There is no such specific compiler.
You can take a look at the source code (or the decompiled source) and look for ways to use generics. Generics can be declared in your project or general constructions (classes, methods, variables, ...) can be used by your project.
You might want to use reflection to look for generic declarations (classes, methods, fields, ... but not variables) in your assembly. To look for the use of generics, you also need to study the IL instructions. A library like Mono.Cecil can help you with this.
UPDATE
It turns out (with Eric Lippert, of course) you can compile your code for the C # 1.0 specification with this switch:
/ langversion: ISO-1
Besides generics, you will also miss a few things that were added in C # 2.0 and later.
SAMPLE CODE
With Mono.Cecil, you can download the assembly and get all its types:
using Mono.Cecil; using Mono.Cecil.Rocks; ... var asm = AssemblyDefinition.ReadAssembly("MyAssembly.dll"); var types = asm.MainModule.GetAllTypes();
And then start making interesting queries with them:
var genericTypes = types.Where(type => type.HasGenericParameters); var genericMethods = types. Select(type => type.Methods.Where(method => method.HasGenericParameters)); var genericFields = types. Select(type => type.Fields.Where(field => field.DeclaringType.HasGenericParameters)); var genericMethodInstructions = types.Select(type => type.Methods.Where(method => method.HasBody). Select(method => method.Body.Instructions. Where(instruction => instruction.Operand is MethodReference). Select(instruction => (MethodReference)instruction.Operand). Where(methodRef => methodRef.Resolve().HasGenericParameters)));
source share