Commit Graph

739 Commits

Author SHA1 Message Date
Steve Sanderson 0ca361a78a Make HttpClientHandler wiping more conservative. Fixes #1484 2018-10-01 12:44:05 +01:00
Nate McMaster 074f2a423d Switch queue name for dnceng and rename yaml files directory (#1481)
Update queue names to to work on https://dev.azure.com/dnceng. Also, react to VSTS => Azure DevOps rebranding.
2018-09-25 17:24:04 -07:00
Ryan Nowak 31b5119c64 fix build of VSIX 2018-09-25 13:52:25 -07:00
Steve Sanderson 824e0097f5 Bump version to 0.7.0-preview1-* 2018-09-25 16:24:23 +01:00
Ryan Nowak 959b45f4e6 Fix #1478 - Razor.Design not getting replaced in templates (#1479)
* Fix #1478 - Razor.Design not getting replaced in templates
2018-09-25 09:27:28 +01:00
Ryan Nowak 6f383a0f0f Adds support for 'Context' parameters on components (#1470)
Adds support for 'Context' parameters on components

This change allows you to set the parameter name of a parameterized child content by using the `Context` attribute on the component. The `Context` attribute will be defined (and shown by completion) when the component has one or more declared parameterized (`RenderFragment<>`) child content parameters.

This is nice for cases where you are using implicit child content:

```
<ol>
  <Repeater Items="People" Context="person">
    <li>@person.FirstName</li>
  </Repeater>
</ol>
```

 or, when you have multiple child content elements and want them all to have the same parameter name:

 ```
<MyComponent Items="People" Context="person">
    <ChildContent1><div>@person.FirstName</div></ChildContent1>
    <ChildContent2><div>@person.LastName</div></ChildContent2>
</Repeater>
```

The parameter name can be overridden by using the `Context` parameter on the child content element:

 ```
<MyComponent Items="People" Context="person">
    <ChildContent1 Context="item"><div>@item.FirstName</div></ChildContent1>
    <ChildContent2><div>@person.LastName</div></ChildContent2>
</Repeater>
```

If the component defines a `Context` parameter already then we won't synthesize one - your component's parameter will work exactly as it did before this feature.
2018-09-24 12:22:16 -07:00
Ryan Nowak 984fabb89f Correct template package reference 2018-09-24 10:42:59 -07:00
KristianJakubik 067d245f94 Fix negative route params. Fixes #1437 2018-09-24 17:55:21 +01:00
Steve Sanderson 0942b5aa0d Switch Hosted template to UseBlazor<Startup> for consistency with server-side template. Fixes #1473 2018-09-24 17:54:46 +01:00
Ryan Nowak 86b532cd47 Undo hardcoded Razor.Design in templates 2018-09-22 16:39:27 -07:00
Ryan Nowak 5459107832 Fix #1298 (#1309)
* Fix #1298

This change lifts our Razor dependencies to 2.1.1. This is needed
because by default ASP.NET Core projects will depend on 2.1.1 - which
results in a conflict trying to use the Blazor compiler. The Blazor
compiler will load the 2.1.0 msbuild tasks, which then break loading the
2.1.1 tasks.

Since this is happening in the MSBuild process, we can't really write
any code to sort this out. We have to make sure the versions match.

In general the guidance for ASP.NET Core is that projects will **compile
against** 2.1.1 so this won't be a problem in the future unless a user
project specifically lifts ASP.NET Core to a higher version. If that's
the case they will also have to live `Microsoft.AspNetCore.Razor.Design`
to match.
2018-09-21 13:29:40 -07:00
Ryan Nowak 4f51d90157 Fix #1399 - crash on start-end syntax for void element
We weren't correctly recovering when a void element is written as a
start-end pair. This change cleans up some of the plumbing around
end-tag handling and adds recognition for this case.

Added a new bespoke diagnostic for the void element case.
2018-09-21 12:54:44 -07:00
Ryan Nowak f601b6d3d2 Fix #1450 Skip compilation on non-C# projects
This change skips our 'temp' compilation that we do to implement 2-phase
build for defining components in .cshtml when the project is not C# OR
when the project has no .cshtml files.

This should make the rest of the build-time Blazor functionality work
for non-C# projects.

This should also make the build faster when you have the Blazor targets
imported in a C# project with no .cshtml files.
2018-09-20 14:27:08 -07:00
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
Steve Sanderson b2f73492f5 Fix method wiping (#1448)
* Fix wiping assemblies that contain references to others in same directory

* Fix generated IL for reporting calls to wiped methods

* Add E2E test for method wiping
2018-09-20 10:20:37 +01:00
Howard Richards d4e2c28145 Amend link for [docs]
The current link for docs points to the wiki which does not have a lot of documentation. Suggest pointing to https://blazor.net/docs/index.html
2018-09-19 11:36:14 -07:00
Steve Sanderson 0fd0fa3b79 Include TPN file in VSIX and all nupkg files built from "src" directory 2018-09-19 13:35:01 +01:00
Steve Sanderson 2f69aa90e5 Revert "Update VSTS queue name", because that change is intended for a
different VSTS instance only.

This reverts commit 32681bf44fc44c2711b5598d5c2481e6accf1ce0.
2018-09-18 22:21:38 +01:00
Steve Sanderson 52d8d4a00f Update VSTS queue name 2018-09-18 22:16:38 +01:00
Steve Sanderson 27189875fb Fix build targets bug (incremental build input was based on wrong property name) 2018-09-18 12:57:50 +01:00
Ryan Nowak 354752cf16 Add support for generic-typed components (#1417)
* Add the ability to discover generic types/properties

* Add @typeparam directive

Adds the ability to declare a generic-typed component using Razor.

* Add a 'type parameter' property to generic components

* Adds the ability to consume generic-typed components
2018-09-16 14:01:15 -07:00
Suchiman b99d805bc0 ILWipe: Remove AsyncStateMachineAttribute 2018-09-14 10:33:32 +01:00
Steve Sanderson fa19f1c4ac Update linker config following upgrade to linker 07c0d489b2c335d0ecddc5a427ef29d39afc8d84 2018-09-13 12:44:08 +01:00
Steve Sanderson 6ff3674b16 Refactor server-side blazor startup to allow Azure SignalR. Fixes #1227 (#1396)
* Move startup action config into AddServerSideBlazor, so that UseServerSideBlazor is reduced to trivial shorthand that can become optional

* Make BlazorHub public so developers can use it with UseAzureSignalR

* Move BlazorHub to Microsoft.AspNetCore.Blazor.Server namespace for easier consumption

* Add notes

* Have E2E tests validate that devs don't have to call UseServerSideBlazor

* Add forgotten tweak

* CR: Document that BlazorHub methods are not intended for application use.

* CR: Rename extension method to UseSignalRWithBlazorHub

* CR: TryAdd
2018-09-11 09:55:27 +01:00
Ryan Nowak d4cbb86f46 Add Support for Templated Components (#1404)
* Test namespace cleanup

* Add recognication for RenderFragment in tag helpers

* Remove dead code from node writers

* refactor type check

* Continue to treat child content as a delegate in codegen

* Add extension to enumerate child content

* Reorganize code generation tests

These were growing a bit disorganized, and weren't really result in good
code reuse.

* fix test base class

* Add some child-content tests

* Add an explicit node for ChildContent

Adds a strongly typed node to represent a 'ChildContent' and what it
contains. This allows us to simplify the code generation path,
detect/processes more issues in IR passes, and will be essential for
supporting multiple child content.

* Ignore ChildContent in components when it's just whitespace

* Add diagnostic for duplicate child content

* Add support for explicit child content elements

Precursor to support for multiple child content items

* Add support for multiple child-content elements

* Change delegate signature for RenderFragment<T>

* Clean up Tag Helper constants

* Allow RenderFragment<T> as a child content

* Allow renaming the template parameter

* Improve error message for invalid child content

* Add diagnostic for repeated child content parameter names
2018-09-10 18:59:51 -07:00
Andrii Kurdiumov 6546c55f4c Removal of global.json from the template
I remove only global.json from the template, and leave global.json in the repository root, since it is required for the build.
See #1324
2018-09-07 12:44:52 +01:00
Ryan Nowak 953479ce21 Fix path to our templates 2018-09-05 14:00:35 -07:00
Steve Sanderson facc1e466e Pre-trim Mono BCL (#1382)
* Add "ilwipe" build command

* Perform BCL wipe as part of build

* Simplify by converting ilwipe command to process entire directories

* Clean up the build
2018-09-05 10:03:54 +01:00
Steve Sanderson b004ffdc24 Set BrowserHttpMessageHandler as the default handler when running on Mono WebAssembly 2018-09-03 17:47:05 +01:00
Steve Sanderson 03ff6ca022 Update jsinterop to version that supports Mono bfc35fc6e65 2018-09-03 17:47:05 +01:00
Steve Sanderson 38b45d82c7 Update linker config following update to Mono bfc35fc6e65 2018-09-03 17:47:05 +01:00
Steve Sanderson 0aa7f13008 Update Mono to bfc35fc6e65 - have not yet rebuilt binaries 2018-09-03 17:47:05 +01:00
cores-system 223a2fed97 Don't intercept clicks for links that open in external frames #1352 (#1354) 2018-09-03 10:31:37 +01:00
Ryan Nowak c97cb8c18b Add support for Razor templates
Adds support for Razor templates and RenderFragment<T>.

Razor templates are a little-known Razor feature that looks like:
```
@<tag>....<tag>
```

It's so little known that it's not even covered in our docs, but it's
been around for many many years. This features hasn't been implemented
until now for Blazor, and this feature brings it back as a build
building block for templated components (more to come).

In Blazor land a template like:
```
@{ RenderFragment<Person> template = @<div>@item.Name</div>; }
```

complies to code like:
```
RenderFragment<Person> template = (__builder, item) =>
{
    __builder.OpenElement(...);
    ...
    __builder.CloseElement(...);
}
```

Since the declaration always has a generic type parameter inside, it
needs to be in a context where the type is known.. ie: not with `var`.

See tests for ways to consume templates.

NOTE: There are the following caveats for templates
- Templates require a single root element.
- Templates don't work in the `@functions { }` block

These limitations are baked into the core of Razor and will take a while
for us to address (v3.0).
2018-08-31 19:10:42 -07:00
Steve Sanderson 2fb5bfb136 Update to latest jsinterop 2018-08-30 08:47:32 +01:00
Nate McMaster 07f524f998 Run compliance checks on official builds (#1357) 2018-08-29 08:29:02 -07:00
Chris Ray 2eaa17f561 include credentials when fetching blazor.boot.json to enable windows auth (#1200) 2018-08-29 11:11:27 +01:00
Steve Sanderson cf59ed94ad Consume jsinterop from submodule (#1351)
* Remove JSInterop files from this repo

* Add jsinterop submodule

* In Blazor.sln, reference jsinterop projects from submodule

* Update other references to jsinterop

* Fix TypeScript warning

* Include submodules in test/pack

* Update to newer jsinterop to fix JS pack issue

* Update to newer jsinterop to obtain strong naming

* Allow jsinterop submodule to inherit Directory.Build.props/targets

* Get latest jsinterop

* For AppVeyor builds, restore git submodules (happens automatically elsewhere)

* Update README.md with instructions to restore submodules
2018-08-29 11:10:35 +01:00
Steve Sanderson 520d47316f Increase default WaitAssert timeout to 2 seconds 2018-08-23 11:58:46 +01:00
Ryan Nowak 3370113a05 Move ITagHelper to another assembly 2018-08-22 17:46:48 -07:00
Ryan Nowak 692bb0e261 Add privateassets=all to Blazor.Build usages
We recommend using this package with PrivateAssets=all everywhere to
make sure that the MSBuild files brought in by this package aren't
applied to transitively.

When that happens, the Blazor.Build MSBuild files will take over the
Razor functionality for other projects, which breaks MVC's view
compilation functionality.

This is part of a fix for #1216.
2018-08-22 08:21:46 -07:00
Steve Sanderson 13cf5bd583 Add Blazor.onServerConnectionClose to fix #1339
This API will be removed once we implement proper connection management (reconnects, etc.)
2018-08-22 15:18:23 +01:00
Steve Sanderson 1089eecbfc In RenderBatchWriter, deduplicate strings only when safe to do so (#1340)
We allow deduplication of HTML element and attribute names, plus whitespace text nodes / attribute values.
2018-08-22 14:52:35 +01:00
Nate McMaster 3a2606a636 Strong name Blazor assemblies (#1344) 2018-08-21 15:37:05 -07:00
Steve Sanderson 52813ddf63 Eliminate temporary MemoryStream buffers used during RenderBatch serialization (#1329)
* Eliminate temporary MemoryStream buffers used during RenderBatch serialization. Fixes #1132

* CR: Fix namespace
2018-08-21 14:08:39 +01:00
Daniel Roth 7a763fc4f6 Scan only declared methods for JS interop (#1320)
* Scan only declared methods for JS interop

* Add DotNetDispatcher test for JS invokable method on base class
2018-08-17 12:35:24 +01:00
Steve Sanderson 04427d2e28 Fix publishing following recent build changes (now that $(OutDir) is relative) 2018-08-15 13:55:54 +01:00
Steve Sanderson d3bc28de55 E2E benchmarks (#1307) 2018-08-14 13:21:19 +01:00
Ryan Nowak fd5426943f Merge sibling nodes during markup block rewrite
This change adds the ability to merge sibling nodes when possible during
markup block rewriting. We retain that invariant that each markup block
is a valid chunk of markup containing properly nested tags.

We still haven't done any work to remove whitespace yet, so most of the
cases where this comes into play right now will merge an element with
its surrounding whitespace.
2018-08-13 11:17:11 -07:00
Ryan Nowak 277e1b4702 Install ASP.NET Core runtime (#1291)
This will make sure the build script includes the ASP.NET Core runtime
when running on local .NET. The effect of this is that our test projects
and apps will 'roll forward' unto the newest runtime without us
hardcoding it.

We can't yet rely on 2.1.3 -  but we can just bump up a version number when it's available.
2018-08-10 20:35:28 -07:00