FSharp.Compiler.CodeDom Convert string into Option string where null and String.Empty result in None Implementation of the CodeDomProvider for the F# language. This is specialized version that can be used with ASP.NET. Implementation of the CodeDomProvider for the F# language. If you intend to use CodeDom with ASP.NET you should use <c>FSharpAspNetCodeProvider</c> instead. Where are we generating member? We use exception for returning value when generating complex code that returns using imperative "return" statement Type of the method Types of all local variables in the method Names of all type arguments in scope (need to rename T -> 'T etc.) Options, output, ... Some unique ID for every namespace (so we don't have name clashes) Hacking for ASP.NET incorrect array initializers They generate "string" where codedom test suite uses "string[]" Reference inherited fields using "fld" instead of "this.fld" (could be used in the future to allow implicit classes in ASP.NET?) No extra configuration Generate code for compile unit (file) Generate code for type declaration (not included in namespace) Generate code for namespace without compilation unit Generates namespace code - takes output from 'preprocessNamespace' Returns CodeNamespace, list of classes with scope (which includes class names of containing classes and sequence of class renames) Generates a main method. Generates method code Generates comments and than calls 'generatMethod' By default all CodeDOM generated methods are 'virtual' which means that we have to generate "abstract and default" (unless we're in struct or we're implementing an interface, or the method is overriden) (NOTE: the same logic isn't properly implemented for properties) Abstract method in the interface Abstract property in the interface fields Generate expression - with unkonw type Matches array or indexer expression and corrects it if the generated CodeDOM is incorrect Generates a "this" or "CurrentType" reference depending on whether a reference is static or not. Used for "ambiguous" references without a type or object qualifier. Unfortunately the Code tree isn't so kind as to tell us whether a reference is static or not up front. Instead we predetermine a set of some static members and assume all other references are instance references. Tries to resolve type of an expression using a few tricks: * Fields of current type may have known type * Properties of current type as well * We can also try to resolve other properties (sometimes it helps) * Resolve type for local variables or argument reference Tries to resolve if type is an array, so we can generate appropriate code (it can be either indexer or array, but we need to generate .Item call for indexers (no overloading is supported by .[]). Returns: "None" - can't resolve, "Some" resovled (true/false - is it an array?) Generate array initializer. Checks generator options for ASP.NET workaround. Generate value of primitive expression Returns F# conversion function for the specified type (or empty string) Are both types numerical types where numeric conversion function can be applied? Generates code for binary operator using function for left and right operand Preprocess collection with type parameters Returns array to be used with <c>usingTyParams</c> and function to be called to generate < ... > code Record specified type parameters in the context, call generating function and then restore the original type parameters (this works if someone uses nested type parameters with the same name) Generate type arguments using context Generate type reference using context (this is most commonly used method) Get type reference, but don't rename .NET types to F# types (this is only needed when calling static methods on the type) Get full type reference string using empty context Get full type reference using information from context Generate type reference with empty context Generates type reference (not for arrays) Tries to resolve type of a variable and adds it to the Context dictionary Get System.Type of know type (either standard type or resolved) Output string as a valid F# identifier Tries to find .NET type for specified type name This is used when we need to know type in order to generate something correctly, but it's just a fallback case Call specified function only on elements of specified type. (performs dynamic type test using x.GetType()) Process collection - keeps context through the whole processing calls 'f' for every element in sequence and 'fs' between every two elements as a separator. This is a variant that works on typed collections. Process collection - keeps context through the whole processing calls 'f' for every element in sequence and 'fs' between every two elements as a separator Perform map and filter operations in one Create closure to do the counting (this is usend when we need indexing during collection processing) Print object converted to string Identity function Call function, but give it context as an argument Append specified string without line-break Break-line and append specified string Print unique id using: "+> uniqid" Function composition operator Create context using specified text writer and options Walks through the CodeDom tree and keeps current "scope" and the result. The result is collected through entire tree, but the modified scope is passed only to sub-nodes of the current node. First argument is a function that is called for nodes and has a function as a first argument, scope and result as a second and current node as a third. The function argument can be used to walk deeper in the tree if wanted. Search for members and return flat list of selected members Function given as an argument returns tuple - first item specifies if the current element should be included in the result, the second specifies if we should walk through child members of the current object