Automatically references assemblies if they have the same name as an imported namespace or as a type annotation when declaring a variable.
/autoref[+ | -]
- +| -
On by default, unless /nostdlib+ is specified. Specifying /autoref+, or just /autoref, causes the compiler to automatically reference assemblies based on imported namespaces and fully qualified names.
The /autoref option instructs the compiler to reference assemblies without having to pass the assembly to /reference. When you use import to import a namespace, or you use a fully qualified type name in your code, the JScript compiler searches for an assembly that contains the type. See /lib for a discussion of how the JScript compiler searches for assemblies.
The compiler does not try to reference an assembly if it has the same name as the output file of the program you are building.
The following program will compile and run when /autoref+ is in effect; the compiler will reference System.dll as a result of the type annotation when declaring a variable.
var s: System.Collections.Specialized.StringCollection = new System.Collections.Specialized.StringCollection(); print(s);
The following program will compile and run when /autoref+ is in effect; the compiler will reference System.dll as a result of the import statement.
import System; var s = new System.Collections.Specialized.StringCollection(); print(s);
These examples also show how the compiler looks for assembly names based on type annotation or import statements. When the compiler did not find an assembly called System.Collections.Specialized.dll that contained StringCollection, it looked for System.Collections.dll. Failing to find that file, it looked for System.dll, which it did find to contain StringCollection.