Abstract:
Type safety is important property of any type system. Modern programming languages support different mechanisms to work in type safe manner, e.g., properties, methods, events, attributes (annotations) and other structures, but none of the existing, general purpose, programming languages which support reflection provide type safe type (class/structure) member metadata access. Existing solutions provide no or limited type safety which are complex and processed at runtime which by definition is not built-in type-safe metadata access, but only more or less type safe workarounds called “best practices”. Problem can be solved by introducing method for type safe type member metadata access which could be processed at compile time.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application claims the benefit of U.S. Provisional Application No. 61/603,342, filed 26 Feb. 2012. 
     
    
     REFERENCES CITED 
     Other Sources 
       [0000]    
       
         1. Francois-Nicola Demers, Jacques Malenfant.: Reflection in logic, functional and object-oriented programming: a Short Comparative Study. In: Proc. of the IJCAI&#39;95 Workshop on Reflection and Metalevel Architectures and their Applications in AI, pp. 29-38. Montreal (1995). 
         2. C# Language Specification Version 4.0 [retrieved on 20 Feb. 2013]. Retrieved from the Internet: http://go.microsoft.com/fwlink/?LinkId=199552. 
         3. Jon Skeet.: C# in Depth Second Edition, Manning, Stamford (2011). 
         4. Java Language and Virtual Machine Specifications [retrieved on 20 Feb. 2013]. Retrieved from the Internet: http://docs.oracle.com/javase/specs/. 
         5. Ira R. Forman, Nate Forman.: Java Reflection in Action. Manning Publications, (2004). 
         6. WPF Apps With The Model-View-ViewModel Design Pattern [retrieved on 20 Feb. 2013]. Retrieved from the Internet: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx. 
         7. How to implement MVVM (Model-View-ViewModel) in TDD (Test Driven Development) [retrieved on 20 Feb. 2013]. Retrieved from the Internet: http://code.msdn.microsoft.com/How-to-implement-MVVM-71a65441. 
         8. Getting Information About Objects, Types, and Members with Expression Trees [retrieved on 20 Feb. 2013]. Retrieved from the Internet: http://blogs.msdn.com/b/csharpfaq/archive/2010/01/06/getting-information-about-objects-types-and-members-with-expression-trees.aspx. 
         9. Joseph Albahari, Ben Albahari.: C#5.0 in a Nutshell, 5th Edition, The Definitive Reference. O&#39;Reilly Media, (2012). 
         10. Caller Information (C# and Visual Basic) [retrieved on 20 Feb. 2013]. Retrieved from the Internet: http://msdn.microsoft.com/en-us/library/hh534540.aspx. 
         11. In Foof We Trust: A Dialogue [retrieved on 20 Feb. 2013]. Retrieved from the Internet: http://blogs.msdn.com/b/ericlippert/archive/2009/05/21/in-foof-we-trust-a-dialogue.aspx 
         12. Jeffrey Palermo, Jimmy Bogard, Eric Hexter, Matthew Hinze, Jeremy Skinner.: ASP.NET MVC 4 in Action. Manning, N.Y. (2012). 
       
     
     
    
     
       BRIEF DESCRIPTION OF DRAWINGS 
         [0014]    The system and methods for providing type safe member metadata access in programming languages with reflection support are further described with reference to the accompanying drawings in which: 
           [0015]      FIG. 1 . show declaration of example class named Person in programming language C#. This example class is used in many C# code examples to demonstrate use cases of various aspects of present invention. 
           [0016]      FIG. 2 . show reflection usage example in C#. Example demonstrates accessing instance and static member metadata for members declared in class Person shown in  FIG. 1 . 
           [0017]      FIG. 3 . show declaration of example class named Person in programming language Java. This example class is used in many Java code examples to demonstrate use cases of various aspects of present invention. 
           [0018]      FIG. 4 . show reflection usage example in Java. Example demonstrates accessing instance and static member metadata for members declared in class Person shown in  FIG. 3 . 
           [0019]      FIG. 5 . show ViewModel declaration example in language C#. Method OnPropertyChanged event is fired by providing needed property name in compile time as string parameter. 
           [0020]      FIG. 6 . show ViewModel declaration example in language C#. Method OnPropertyChanged event is fired by providing expression tree data structure. Expression tree is processed at runtime taking significant amount of time. 
           [0021]      FIG. 7 . show ViewModel declaration example in language C#. Method OnPropertyChanged event is fired by providing needed property name in compile time. Compiller detects needed property name using CallerInfo attributes. 
           [0022]      FIG. 8 . show C# and Java examples demonstrating how operator memberof can be designed to return metadata from instance fields and how it is different from accessing only static fields. 
           [0023]      FIG. 9 . show C# examples demonstrating use cases of operator memberof in accessing metadata of different kinds of members (according to class Person shown in  FIG. 1 .) 
           [0024]      FIG. 10 . show Java examples demonstrating use cases of operator memberof in accessing metadata of different kinds of members (according to class Person shown in  FIG. 3 .) 
           [0025]      FIG. 11 . show ViewModel declaration example in language C#. Method OnPropertyChanged event is fired by providing needed property name obtained from usage of operator memberof. 
           [0026]      FIG. 12 . show ViewModel declaration example in language C#. Method OnPropertyChanged event is fired by providing needed property name obtained from usage of operator member. 
           [0027]      FIG. 13 . demonstrates C# code for FilterByEquality method declaration where declared method accepts as parameter nongeneric version of metadata instance and some value. 
           [0028]      FIG. 14 . show C# examples demonstrating use cases of operator memberof in accessing metadata of different kinds of members (according to class Person shown in  FIG. 1 .). Memberof operator returns generic version of metadata instance containing one generic parameter. 
           [0029]      FIG. 15 . show Java examples demonstrating use cases of operator memberof in accessing metadata of different kinds of members (according to class Person shown in  FIG. 3 .). Memberof operator returns generic version of metadata instance containing one generic parameter. 
           [0030]      FIG. 16 . demonstrates C# code for FilterByEquality method declaration where declared method accepts as parameter generic version of metadata instance and some value. 
           [0031]      FIG. 17 . show C# examples demonstrating use cases of operator memberof in accessing metadata of different kinds of members (according to class Person shown in  FIG. 1 .). Memberof operator returns generic version of metadata instance containing 2 generic parameters. 
           [0032]      FIG. 18 . show Java examples demonstrating use cases of operator memberof in accessing metadata of different kinds of members (according to class Person shown in  FIG. 3 .). Memberof operator returns generic version of metadata instance containing 2 generic parameters. 
           [0033]      FIG. 19 . demonstrates C# code for FilterByEquality method declaration where declared method accepts as parameter generic version of metadata instance with 2 generic parameters and some value. 
           [0034]      FIG. 20 . demonstrates simplified class Person and class Address declaration in language C#. 
           [0035]      FIG. 21 . demonstrates C# code fragment where to operator memberof is passed multiple member access expression. 
           [0036]      FIG. 22 . demonstrates C# code fragment where to operator memberof is passed multiple member access expression and type of returning value is specified explicitly. 
           [0037]      FIG. 23 . demonstrates another C# code fragment where to operator memberof is passed single member access expression. 
           [0038]      FIG. 24 . show declaration of method TestMetadata and metadata passing to this method using operator memberof. 
           [0039]      FIG. 25 . show metadata passing to method TestMetadata using method parameter access modifier ‘meta’. 
           [0040]      FIG. 26 . show field metadata passing to method using method parameter access modifier ‘meta’. 
           [0041]      FIG. 27 . show property metadata passing to method using method parameter access modifier ‘meta’. 
           [0042]      FIG. 28 . show method metadata passing to method using method parameter access modifier ‘meta’. 
           [0043]      FIG. 29 . show constructor metadata passing to method using method parameter access modifier ‘meta’. 
           [0044]      FIG. 30 . show event metadata passing to method using method parameter access modifier ‘meta’. 
           [0045]      FIG. 31 . show view designed in ASP.NET MVC Razor View Engine where HTML helper ‘TextBox’ is used in type unsafe way. 
           [0046]      FIG. 32 . shown view designed in ASP.NET MVC Razor View Engine where HTML helper ‘TextBox’ is used together with expression trees. 
           [0047]      FIG. 33 . show HTML helper ‘TextBox’ implementation example for ASP.NET MVC Razor View Engine. HTML helper uses metadata instance where type of metadata instance consists of 2 generic parameters. 
           [0048]      FIG. 34 . show view designed in ASP.NET MVC Razor View Engine where HTML helper ‘TextBox’ (shown in  FIG. 33 ) is used together with method parameter access modifier ‘meta’. 
           [0049]      FIG. 35 . show simplified C# code example in which is used HTML helper ‘TextBox’ (shown in  FIG. 33 ) using method parameter access modifier ‘meta’. 
           [0050]      FIG. 36 . show simplified C# code example in which is used HTML helper ‘TextBox’ (shown in  FIG. 33 ) using method parameter access modifier ‘meta’ and specifying HTML helper generic parameters explicitly. 
           [0051]      FIG. 37 . show view designed in ASP.NET MVC Razor View Engine where HTML helper ‘TextBox’ (shown in  FIG. 33 ) is used together with method parameter access modifier ‘meta’. View is strongly typed and in HTML helper call is employed all context information available. 
           [0052]      FIG. 38 . show method parameter modifier ‘meta’ used with types. 
           [0053]      FIG. 39 . show standard C# operator ‘typed’ usage example. 
       
    
    
     BACKGROUND 
       [0054]    Reflection is a powerful mechanism provided by some major object oriented languages and frameworks that allows to access information about classes and their members at metadata level, and use it in different scenarios. Some of few use cases are: detecting what kind of methods or fields does the class have, detecting the specific field data type at runtime, dynamically invoking method which name is unknown at compile time. These are non-standard cases of classical object oriented programming, but they make a great significance in contemporary object oriented design solutions and frameworks where modularity and extensibility are key values (1). 
         [0055]    Reflection is designed the way that metadata access is not straightforward and type-safe for distinct members. The usual scenarios of using reflection allow:
       traversing class fields or members, and doing the processing operations on each iteration;   checking if a specific member (field, method, constructor, event, property . . . ) with a specified name (and possible additional signature information for the latter) exists, and then processing it.
 
This approach does not allow direct and type-safe access of distinct fields or methods which programmer is aware of (2), (3), (4), (5).
       
 
         [0058]      FIG. 1  demonstrates C# example class named ‘Person’ declaration which has instance level field named ‘FullName’ and static field ‘TotalPersons’.  FIG. 2  demonstrated: getting metadata information about these fields. 
         [0059]      FIG. 3  and  FIG. 4  demonstrate same example in Java. Java also allows accessing both private and public fields. In case of Java there&#39;s a special case of retrieving class metadata by using “class” keyword as a member of class. Please note that Java has some differences in metadata retrieval and metadata structure (e.g., Constructor has a single generic parameter referencing to a constructor holder class), but conceptual approach is almost identical to that of C#. 
         [0060]    Previously demonstrated examples show existing technique of accessing metadata in two major general purpose programming languages: C# and Java. Providing type member name as string instances to access type member metadata are not type safe. It means that code is not reliable for maintenance (refactoring) and also if there is a mistake it will be noticed only at runtime. 
         [0061]    The most obvious benefit of static type-checking is that it allows early detection of some programming errors. Errors that are detected early can be fixed immediately, rather than lurking in the code to be discovered much later, when the programmer is in the middle of something else or even after the program has been deployed. Most of general purpose object-oriented programming languages are strongly typed, but none of them provide fully type safe metadata access mechanism—they lack type safe type (class/structure) member metadata access. Not all programming languages support metadata access mechanisms like reflection, but for languages which support metadata access, type safety in this field is considered to be a property of a computer program rather than the language in which that program is written. In such cases programmer is responsible for type safety which means correct metadata representation in basic data types, usually strings. 
         [0062]      FIG. 5  demonstrates member metadata access use case in MVVM design pattern usage (6). Best that programmer can do if programming language does not have strongly typed type member metadata access is checking type member names (metadata) at runtime which only partly solves type safety issues, but on downside makes code more complex, forces programmer to use redundant type expressions and leads to performance slowdown. Microsoft® provides best practices to access metadata in mentioned type safe way using lambda expressions (7), (8). Metadata access example using lambda expressions are shown in  FIG. 6 . Unfortunately described practices do not guarantee 100% type safety and desired result. In case if programmer provides lambda expression which does not contain member access expression, program execution will fail. 
         [0063]    In C#5, it is possible to tag optional parameters with one of three caller info attributes (9), (10): [CallerMemberName] applies the caller&#39;s member name; [CallerFilePath] applies the path to caller&#39;s source code file; [CallerLineNumber] applies the line number in caller&#39;s source code file. By using CallerInfo attributes, it is possible to obtain information about the caller to a method. You can obtain file path of the source code, the line number in the source code, and the member name of the caller. CallerInfo attributes instruct the compiler to feed information obtained from the caller&#39;s source code into the parameter&#39;s default value: This information is helpful for tracing, debugging, and creating diagnostic tools.  FIG. 7  demonstrates modified C# example shown in  FIG. 5  by using CallerInfo attributes. CallerInfo attributes make metadata access more type safe, metadata access is performed at compile time and it works much faster than processing expression trees at runtime. However, CallerInfo attributes are not a generic solution. Attributes (annotations in Java) are metadata by definition and type safe metadata access using nothing else than another metadata is odd and can&#39;t be ideal solution. CallerInfo attributes are suitable for narrow use cases: to safely access member name from inside the member (property or method, but not field), but are not applicable for data querying, because data are contained in fields. 
         [0064]    All mentioned downsides can be solved by introducing language improvements to support type safe metadata access which would make compile-time checks possible. Type metadata gathering operator “typeof” (C#) and “.class” call (Java) returns metadata about specified type (class, structure, interface), but there is no type safe way to access class member metadata. For example, programming languages can be extended with operator named ‘memberof’ so that memberof(classField) returns field metadata instance FieldInfo (C#) or Field (Java) instances instead of field value instances. Microsoft® has been working on design of type safe member metadata access operator named “infoof” (11). The following example shows how non-static field from previous example can be accessed without using instance reference of class: 
         [0000]                                //C#       FieldInfo instanceMemberMetadata = infoof(Person.FullName);       Alternatively Java example would be as follows:       //Java       Field instanceMemberMetadata = infoof(Person.fullName);                    
Field ‘FullName’ is used like static field, but since type cannot have instance level member and static level member with the same name, there should be no misunderstanding to which field we are pointing to and system should return correct metadata instance. The same is with methods, properties, events and constructors.
 
Microsoft® has been thinking about operator infoof as similar operator to operator typeof which allows type safe metadata access:
 
Type info=typeof (int);
 
Operator typeof accepts parameter which is type instead of instance. Following example is invalid according to C# specification:
 
Type x=typeof(6);
 
Use cases of member metadata access operator, that does not accept instance expressions as operator parameter, are too specific and that is not enough for fully type safe member metadata access.
 
       SUMMARY 
       [0065]    Current invention provides methods for type safe type (class/structure) member metadata access in programming languages with support reflection. Type member metadata access invention is based on introduction of different forms of generic forms of operator ‘memberof’, context dependent operator ‘member’ and method parameter modifier ‘meta’ which forces compiler to interpret method actual parameter as metadata access expression instead of value access expression. Introduced operators require changes in programming frameworks like .NET, Java and others, as well as propose improvements in syntax of general purpose programming languages, but as result make programming languages fully type safe in metadata access field. 
       DETAILED DESCRIPTION 
       [0066]    The disclosed invention facilitates extending object oriented programming languages with new operators to support type safe type (class/structure) member metadata access. 
         [0067]    Member metadata access operator can be designed to work also with member instance expressions as demonstrates  FIG. 8 . The most important aspect of operator ‘memberof’ is that member access or member call expressions provided to operator ‘memberof’ are not processed as member access operations/member call operations, but instead the metadata instance of supplied member (field, method, property, constructor, event) is created and returned. This means that code from previous example—memberof(myFriend.FullName)—is not reducible to memberof(“Oscar”) as it would be if field myFrield.FullName would be interpreted as field access operation. 
         [0000]                                In Frameworks operator ‘memberof’ could be overloaded with following versions:       .NET:       memberof(field) which should return FieldInfo instance;       memberof(method(parameter type list - optional)) which should return MethodInfo instance;       memberof(property) which should return PropertyInfo instance;       memberof(class(parameter type list - optional)) which should return ConstructorInfo instance;       memberof(event) which should return EventInfo instance;                    
In .NET class MemberInfo is base class for classes: FieldInfo, MethodInfo, PropertyInfo, ConstructorInfo, EventInfo and in cases when is needed only type safe member name determination, better is to use MemberInfo instance. Similar metadata type system architecture is in programming language Java, differs only metadata class names and usage syntax:
 
         [0000]                                Java:       memberof(field_path) - returns Field instance for a given field (expressed with a full path, e.g.,        myFriend.fullName or Person.fullName)       memberof(method_path(Class&lt;?&gt; ... parameterTypes)) - returns Method instance       memberof(class_name(Class&lt;?&gt; ... parameterType)) - returns Constructor instance representing       constructor information for the given class                    
C# examples using operator memberof are demonstrated in  FIG. 9  and Java examples are demonstrated in  FIG. 10 . In order to maintain a consistency with existing Java language specification, meta-data class Constructor provides a single generic parameter which references to a parent class of a constructor (just as described in examples above when metadata was retrieved using standard solution).
 
         [0068]    One of most valuable use cases of operator ‘memberof’ could be in design pattern MVVM ViewModel declarations.  FIG. 11  shows more type safe version of class CustomerViewModel than was introduced in Background section (type safety is achieved by using operator ‘memberof’). 
         [0069]    Many programming languages have operator ‘this’ which points to current instance context, but none of programming languages have operator which could point to current instance member context. Such operator could be operator named ‘member’ as shown in  FIG. 12 . Operator ‘member’ depends on usage context. When used in constructor code block it should return constructor metadata instance, when used in method code block it should return method metadata instance, when used in property code blocks it should return property metadata instance. The difference from non-generic operator memberof usage example is that now we are using context dependent operator which will be handled by compiler. Context dependent operator enables easier code refactoring, for example, in renaming property, changes inside property declaration (including body) are required to be made only in one place—in property name. 
         [0000]    Sometimes it&#39;s required not only to access type member metadata, but also to process type member taking into consideration some parameter(s) whose type should be compatible with initial member type. For example, in database querying useful could be method ‘FilterByEquality’ declared as shown in  FIG. 13 . Demonstrated example is not type safe because type of parameter ‘constrainedValue’ may not be compatible with type of member to which parameter ‘memberMetaData’ indirectly points to. To solve such problems we propose extending metadata types to generic versions: 
         [0000]                                //C#       MemberInfo&lt;T&gt; should replace MemberInfo       FieldInfo&lt;T&gt; should replace FieldInfo       MethodInfo&lt;T&gt; should replace MethodInfo       PropertyInfo&lt;T&gt; should replace PropertyInfo       ConstructorInfo&lt;T&gt; should replace ConstructorInfo       EventInfo&lt;T&gt; should replace EventInfo       //Java       AccessibleObject&lt;T&gt; should replace AccessibleObject       Field&lt;T&gt; should replace Field       Method&lt;T&gt; should replace Method       Constructor&lt;C, T&gt; should replace Constructor&lt;C&gt;       Note that Java metadata class Constructor already had a single type-parameter (referencing to        a constructor&#39;s holder class), and thus we are extending it by an additional generics parameter.                    
Now operator ‘memberof’ should return generic versions of metadata instances.
 
       .NET: 
       [0070]    memberof(suppliedField) which should return FieldInfo&lt;T&gt; instance and T is type of field ‘supplied Field’;
 
memberof(suppliedMethod(parameter type list—optional)) which should return MethodInfo&lt;T&gt; instance and type T is type container for all ‘suppliedMethod’ parameters. In .NET this type container could be standard delegate: Func&lt; . . . &gt; or Action&lt; . . . &gt;. Which type exactly will function as type container depends on ‘suppliedMethod’ returning type—for methods with returning value type container will be Func&lt; . . . &gt; and for methods without returning value (void) type container will be Action&lt; . . . &gt;. It is possible to use custom type container types, but better is to stick to well-known standard classes, this way it would be possible to use implicit type declarations (keyword ‘var’);
 
memberof(suppliedProperty) which should return PropertyInfo&lt;T&gt; instance and T is type of property ‘suppliedProperty’;
 
memberof(suppliedClass(parameter type list—optional)) which should return ConstructorInfo&lt;T&gt; instance and type T is type container for all ‘suppliedClass’ constructor parameters. In .NET this type container could be standard delegate Action&lt; . . . &gt;;
 
memberof(event) which should return EventInfo&lt;T&gt; instance where type T should specify event argument (in should be class EventArgs or class which inherits from EventArgs);
 
Similarly improved operator ‘memberof’ can be designed for Java and other programming languages. Usage examples of improved operator ‘memberof’ are demonstrated in  FIG. 14  (C# examples) and  FIG. 15  (Java examples).
 
In programming languages which does not support delegates, programmer needs to take care of designing type containers for method parameters. Type ‘Action’ variations are supposed to function as method parameter type containers for methods which do not have returning value (void methods). Type ‘Action’ is supposed to describe fact that method does not have parameters; Action1&lt;T1&gt; is supposed to describe fact that method has one parameter with type should equal to generic parameter T1; Action2&lt;T1, T2&gt; is supposed to describe fact that method has two parameters which types should be equal to generic parameters T1 and T2 accordingly; and so on . . . .
 
Similarly is with ‘Func’ variations. ‘Func’ acts as method parameter type container for methods which return value. Func&lt;R&gt; is supposed to describe fact that method does not have parameters and type of returning value should be equal to generic parameter R. Func1&lt;T1, R&gt; is supposed to describe fact that method has one parameter of type which should be equal to generic parameter T1 and type of returning value should be equal to generic parameter R. Func2&lt;T1, T2, R&gt; is supposed to describe fact that method has two parameters of types which should be equal to generic parameters T1 and T2 accordingly and type of returning value should be equal to generic parameter R.
 
Please note that the final names of ‘Action’ and ‘Func’ type containers can be changed depending on a target framework. E.g., C# already provides such types along with delegates, and it allows using the same name across different versions (different generic parameters&#39; count designates different types). However, in case of Java generics are processed differently, and different type names required even if generics declaration differs. The Action, Action1, Action2, . . . and Func, Func1, Func2, . . . could be introduced in Java as a metadata parameter holders.
 
Taking into consideration all previously proposed ideas, method ‘FilterByEquality’ example can be improved as shown in  FIG. 16 .
 
Important part is in expression: memberof(Person.FullName) which returns FieldInfo&lt;T&gt; instance where type T is determined as string. Compiller automatically detects type of variable ‘memberMetadata’ from ‘memberof’ operator call context and in example this type is MemberInfo&lt;string&gt;. Demonstrated example of ‘memberof’ call is equivalent to following code where returning type is explicitly declared:
 
MemberInfo&lt;string&gt; memberMetadata=memberof(Person.FullName);
 
         [0071]    Method&#39;s ‘FilterByEquality’ example still are not fully type safe, because returning collection items type is not detected from provided metadata. Problem can be solved by extending metadata containing types with one more generic parameter which will hold member containing object&#39;s type information. 
         [0000]    This means: MemberInfo&lt;T&gt; extension to MemberInfo&lt;TObject, TMember&gt; where TMember refers to member&#39;s type and TObject refers to members containing object type: 
         [0000]                                //C#       MemberInfo&lt;TObject, TMember&gt; should replace MemberInfo       FieldInfo&lt;TObject, TMember&gt; should replace FieldInfo       MethodInfo&lt;TObject, TMember&gt; should replace MethodInfo       PropertyInfo&lt;TObject, TMember&gt; should replace PropertyInfo       ConstructorInfo&lt;TObject, TMember&gt; should replace ConstructorInfo       EventInfo&lt;TObject, TMember&gt; should replace EventInfo       //Java       Member&lt; TObject, TMember&gt; should replace Member       Field&lt; TObject, TMember&gt; should replace Field       Method&lt; TObject, TMember&gt; should replace Method       Constructor&lt; TObject, TMember&gt; should replace Constructor                    
Improved operator ‘memberof’ usage examples for C# programming language are demonstrated in  FIG. 17  and Java examples in  FIG. 18 .
 
Taking into consideration previously described improvements to operator ‘memberof’, example with method ‘FilterByEquality’ can be declared as shown in  FIG. 19 . Last code line from example demonstrated in  FIG. 19  can be rewritten to use implicit type declaration as follows:
 
var wantedPersons=FilterByEquality(memberMetadata, personName);
 
         [0072]    It is possible that member access expression is invoked from existing member access expression. Consider example class declarations shown in  FIG. 20 . Example of multiple level member access expression with two level member accesses expression is shown in  FIG. 21 . 
         [0000]    In case of two level member access expression (in example: instance.HomeAddress.Street) type of operator ‘memberof’ returning value should be member containing type from first member access expression. In example, first member access expression is ‘HomeAddress’ member access expression and its containing type is Person, so previous example can be rewritten without implicit type declaration as shown in  FIG. 22 . Interesting part is what should be exact type of variable ‘memberMetadata’?
 
For multiple member access expressions to be useful as metadata, compiler should maintain whole chain of member access expressions. In previous example it means that variable ‘memberMetadata’ represents ‘Street’ member access expression and contains information that member ‘Street’ was accessed from ‘HomeAddress’ which is another member access expression. Member ‘HomeAddress’ was accessed from instance (not from another member access expressions), so here stops member access chain backtracking.
 
If is needed Address as returning type and we have only ‘Person’ instance, then multiple member access expression should be separated as shown in  FIG. 23 .
 
Such multiple member access level behaviour of ‘memberof’ operator would be useful in defining queries.
 
         [0073]    Metadata can be gathered and then passed to methods, like in example shown in  FIG. 24 . In cases when metadata needs to be passed to method as parameter, operator ‘memberof’ syntax can be transformed into much nicer syntax using method parameter modifier called ‘meta’ as shown in  FIG. 25 . Method parameter modifier ‘meta’ forces compiler to interpret method actual parameter as metadata access expression instead of value access expression what is default behaviour in method parameter interpretation. Reference parameters and output parameters changes not only how method accepts parameter, but also the way how method processes parameters, that is why reference parameters and output parameters requires parameter modifier usage at method declaration. Method parameter modifier ‘meta’ makes changes only in actual value passed to method call. Parameter modifier ‘meta’ does not impact method execution, so method parameter modifier ‘meta’ specifying at method declaration is not necessary. 
         [0000]    Method parameter modifier ‘meta’ has 5 different forms: 
         [0074]    Example of parameter modifier for field metadata access is shown in  FIG. 26 . 
         [0075]    Example of parameter modifier for property metadata access is shown in  FIG. 27 . 
         [0076]    Example of parameter modifier for method metadata access is shown in  FIG. 28 . 
         [0077]    Example of parameter modifier for constructor metadata access is shown in  FIG. 29 . 
         [0078]    Example of parameter modifier for event metadata access is shown in  FIG. 30 . 
         [0079]    Most benefits from method parameter modifier ‘meta’ usage can be gained in frameworks where reflection is used as architectural discipline, especially in frameworks supporting MVC architectural pattern where views usually are linked with models using binding mechanism which uses reflection. In  FIG. 31  shown example demonstrates View designed in ASP.NET MVC Razor View Engine (12). HTML helper ‘TextBox’ accepts metadata in type unsafe way. 
         [0000]    Best that is possible without operator ‘memberof’ invention is usage of lambda expressions as shown in  FIG. 32 . Example view is defined as strongly typed, this means, that variable ‘Html’ is of type HtmlHelper&lt;Person&gt; and that is why HTML helper ‘TextBoxFor’ can accept member ‘Person.FullName’ metadata in strongly typed way. But, as lambda expressions are processed at runtime, they are not fully type safe. Besides lambda expressions syntax in HTML helper case requires declaration of formal parameter (in previous example it is parameter named ‘model’) which is unnecessary from syntax perspective and should be removed to simplify syntax. 
         [0080]      FIG. 33  demonstrates simple HTML helper ‘TextBoxFor’ accepting member metadata instance. Example demonstrates how metadata from ‘memberAccess’ expression is gathered during compile time and syntax does not contain any unnecessary or redundant parts. Improved HTML helper calling code is demonstrated in  FIG. 34  where is defined ASP.NET MVC Razor example view using method parameter modifier ‘meta’. But still example can be simplified! In case of strongly typed view, member containing type specification in member access expression is redundant. In  FIG. 35  is shown simplified, but equivalent code sample to previously declared ASP.NET MVC Razor view example. Still HTML helper usage example can be rewritten specifying generic parameters explicitly as shown in  FIG. 36 . Now can be seen, that generic parameter ‘T’ (type ‘Person’) in HTML helper ‘TextBoxFor’ call is used in 3 places: in ‘Html’ variable declaration, in ‘TextBoxFor’ method call and in member access expression. Compiler uses type inference to detect unknown generic types and for compiler it is sufficient to supply type for generic parameter only in one place instead of all tree places. In example, place where generic parameter T type is specified is in variable ‘Html’ declaration, so further generic parameter T specifications are not necessary. In similar way compiler is capable to infer type of generic parameter ‘TProp’ from member access expression ‘Person.FullName’, so the shortest syntax of HTML helper ‘TextBoxFor’ usage would be as follows: 
       Html.TextBoxFor(meta FullName); 
       [0081]    Finally, type member metadata access and usage syntax in all aspects are short, expressive and fully type safe. In  FIG. 37  is demonstrated example of shortest syntax form for method modifier ‘meta’ demonstrating how metadata should be provided to HTML helpers in ASP.NET MVC Razor views engine. 
         [0082]    The only part that is not yet covered is method parameter modifier ‘meta’ for types (member containers). If method parameter modifier ‘meta’ works with type members, it should work with types as well.  FIG. 38  example demonstrates method parameter ‘meta’ usage syntax with types. Such practice is equivalent to code usage pattern shown in  FIG. 39 . In case of method modifier ‘meta’ syntax is much simpler and nicer.