aspnetcore/test/Microsoft.AspNetCore.Blazor.../TestFiles/DesignTimeCodeGenerationTest
Ryan Nowak 100382bf71 Add Type Inference for Generic-Typed Components
This change allows you to use generic-typed components without
explicitly specify type arguments.

**Before:**
```
<Grid Items="@MyItems" TItem="Person">
...
</Grid>
```

**After:**
```
<Grid Items="@MyItems">
...
</Grid>
```

Where possible, the type of the component will be inferred based on the
values passed to component parameters. This won't work like magic, you
have to specify parameters that provide type arguments for all of the
component's type parameters.

This is a best effort system, and it's largely based on the limitations
and behaviours of generic type inference in C#. We think it will work
well with most Blazor features and for most reasonable components. You
should not forget it's easy to specify type arguments, because you may
still have to in some cases.

In particular you may notice issues if you are trying to use a generic
typed component where all of the parameters are delegates or templates.
Type inference for delegates/lambdas in C# is based on the context. Any
time you combine generics and delegates it's easy to get into a scenario
where the compiler won't infer the correct type, or will give up.

----
The type inference feature works by generating a 'thunk' method in
*caller* that can act as a site for type inference (C# does not support
inference on constructors).

For our grid example above, the non-inferenced code will look something
like:
```
builder.OpenComponent<Grid<Person>>(0);
builder.AddAttribute(1, "Items", MyItems);
builder.CloseComponent();
```

Note that we can only write the type `Grid<Person>` because you wrote
`Person` in your code. What you type in the `TItem` attribute value gets
inserted into the generated code such that it fills in the generic type
parameter.

On the other hand, if you want is to infer the type, we have to do some
compiler magic. That looks like:
```
__Blazor.(long generated name).TypeInference.CreateGrid_0();
...

// elsewhere in the file
internal static class TypeInference
{
    public static void CreateGrid_0<TItem>(RenderTreeBuilder builder,
    int seq, int __seq0, global::System.Collections.Generic.List<TItem>
    __arg0)
        {
	        builder.OpenComponent<Grid<TItem>>(seq);
		        builder.AddAttribute(__seq0, "Items", __arg0);
			        builder.CloseComponent();
				    }
				    }
				    ```

				    This allows us to rely on the C#
				    compiler for itype inference.
2018-09-20 12:19:26 -07:00
..
AsyncEventHandler_OnElement_ActionEventArgs_Lambda
AsyncEventHandler_OnElement_ActionEventArgs_MethodGroup
AsyncEventHandler_OnElement_Action_Lambda
AsyncEventHandler_OnElement_Action_MethodGroup
BindToComponent_SpecifiesValueAndChangeEvent_WithMatchingProperties
BindToComponent_SpecifiesValueAndChangeEvent_WithoutMatchingProperties
BindToComponent_SpecifiesValue_WithMatchingProperties
BindToComponent_SpecifiesValue_WithoutMatchingProperties
BindToComponent_TypeChecked_WithMatchingProperties
BindToElementFallback_WithFormat_WritesAttributes
BindToElementFallback_WritesAttributes
BindToElementWithSuffix_WritesAttributes
BindToElement_WritesAttributes
BodyAndAttributeChildContent
BodyAndExplicitChildContent
BuiltIn_BindToInputCheckbox_WritesAttributes
BuiltIn_BindToInputText_WithFormatFromProperty_WritesAttributes
BuiltIn_BindToInputText_WithFormat_WritesAttributes
BuiltIn_BindToInputText_WritesAttributes
BuiltIn_BindToInputWithoutType_WritesAttributes
ChildComponent_Generic Add support for generic-typed components (#1417) 2018-09-16 14:01:15 -07:00
ChildComponent_GenericBind Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_GenericBindWeaklyTyped Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_GenericBindWeaklyTyped_TypeInference Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_GenericBind_TypeInference Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_GenericChildContent Add support for generic-typed components (#1417) 2018-09-16 14:01:15 -07:00
ChildComponent_GenericChildContent_TypeInference Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_GenericWeaklyTypedAttribute Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_GenericWeaklyTypedAttribute_TypeInference Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_Generic_TypeInference Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_Generic_TypeInference_Multiple Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_MultipleGenerics Add support for generic-typed components (#1417) 2018-09-16 14:01:15 -07:00
ChildComponent_MultipleGenerics_TypeInference Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_Simple
ChildComponent_WithChildContent Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_WithElementOnlyChildContent
ChildComponent_WithExplicitChildContent
ChildComponent_WithExplicitEventHandler
ChildComponent_WithExplicitGenericChildContent
ChildComponent_WithExplicitStringParameter
ChildComponent_WithGenericChildContent Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_WithGenericChildContent_SetsParameterName Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_WithLambdaEventHandler
ChildComponent_WithNonPropertyAttributes Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_WithPageDirective
ChildComponent_WithParameters Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
ChildComponent_WithWeaklyTypeEventHandler
ComponentParameter_TypeMismatch_ReportsDiagnostic
ComponentWithTypeParameters Add support for generic-typed components (#1417) 2018-09-16 14:01:15 -07:00
Component_WithDocType
Component_WithRef Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
Component_WithRef_WithChildContent Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
Element_WithRef
EventHandler_OnElement_ArbitraryEventName_WithEventArgsMethodGroup
EventHandler_OnElement_WithDelegate
EventHandler_OnElement_WithEventArgsLambdaDelegate
EventHandler_OnElement_WithEventArgsMethodGroup
EventHandler_OnElement_WithLambdaDelegate
EventHandler_OnElement_WithNoArgMethodGroup
EventHandler_OnElement_WithNoArgsLambdaDelegate
EventHandler_OnElement_WithString
GenericComponent_WithComponentRef Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
GenericComponent_WithComponentRef_TypeInference Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
LeadingWhiteSpace_WithCSharpExpression
LeadingWhiteSpace_WithComponent
LeadingWhiteSpace_WithDirective
MultipleExplictChildContent
RazorTemplate_AsComponentParameter
RazorTemplate_AsComponentParameter_MixedContent
RazorTemplate_ContainsComponent
RazorTemplate_FollowedByComponent
RazorTemplate_Generic_AsComponentParameter
RazorTemplate_Generic_InImplicitExpression
RazorTemplate_InAttribute
RazorTemplate_InCodeBlock
RazorTemplate_InCodeBlock_Dynamic
RazorTemplate_InExplicitExpression
RazorTemplate_InImplicitExpression
RazorTemplate_MultipleRoots
RazorTemplate_NonGeneric_AsComponentParameter
RazorTemplate_NonGeneric_InImplicitExpression
Regression_597
Regression_609
Regression_772 Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
Regression_773 Add Type Inference for Generic-Typed Components 2018-09-20 12:19:26 -07:00
Regression_784
ScriptTag_WithErrorSuppressed
TrailingWhiteSpace_WithCSharpExpression
TrailingWhiteSpace_WithComponent
TrailingWhiteSpace_WithDirective