Commit Graph

81 Commits

Author SHA1 Message Date
Steve Sanderson 811ef19f57 In E2E tests, allow for slower execution on Travis/AppVeyor 2018-11-13 12:00:24 +00:00
Steve Sanderson 7530ad9a26 E2E tests for cascading parameters generally 2018-10-18 09:57:41 +01:00
KristianJakubik 067d245f94 Fix negative route params. Fixes #1437 2018-09-24 17:55:21 +01: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
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
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
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 520d47316f Increase default WaitAssert timeout to 2 seconds 2018-08-23 11:58:46 +01:00
Nate McMaster 3a2606a636 Strong name Blazor assemblies (#1344) 2018-08-21 15:37:05 -07:00
Steve Sanderson d3bc28de55 E2E benchmarks (#1307) 2018-08-14 13:21:19 +01:00
Ryan Nowak a05cb42845 Reenable markup blocks (#1286)
* Reenable HtmlBlock unit tests

* Add E2E tests for HTML Block cases

* Remove harded GenerateBaselines=true

* Fix #1193

This commit addresses the root cause of #1193. When we merge HTML
text nodes into HTML blocks we need to re-encode any HTML entities that
were encoded eariler.

I did a bit of a deep dive on how HTML encoding is handled in Blazor and
I think this is the best strategy. I think it's valuable that the
BrowserRenderer uses document.createTextNode, which will always encode
the text - this handles dynamic content. We want to keep this in place
to avoid HTML injection attacks.

* Fix #1265 Reenable MarkupBlock

* test cleanup
2018-08-10 16:29:39 -07:00
Steve Sanderson 70a4bf7521 E2E test async robustness tweaks following recent failures 2018-08-09 10:27:40 +01:00
Steve Sanderson 16d005e00c Fix returning arrays in async JS interop calls. Fixes #1205 2018-07-27 10:11:45 -07:00
Steve Sanderson 4aaeac1e51 preventDefault for form onsubmit handlers. Fixes #951 2018-07-24 08:11:02 -07:00
Steve Sanderson d2f74249b1 Fix updating attributes on SVG elements. Fixes #934 and #1114 2018-07-23 16:03:18 -07:00
Ryan Nowak 8f072a0711 Add HTML Block rewriting (#1146)
* Add HTML Block rewriter

* Baseline updates

* test gaps

* Update some unit tests to represent same behavior as before

* Define Markup frame type. Tests for rendering markup frames into render tree.

* Support markup frames during diffing (retain, insert, update, delete)

* Support markup blocks on WebAssembly

* Support rendering markup frames with server-side execution too

* Support markup blocks with multiple top-level nodes. Support updating markup dynamically.

* Define MarkupString type as a way to insert dynamic markup without needing custom RenderFragment code

* Remove comment

* CR: Better null value handling
2018-07-23 18:18:07 +01:00
Steve Sanderson 41fcf65c05 Run E2E tests for server execution as well as WebAssembly. Fixes several
server-execution bugs uncovered by the E2E tests.
2018-07-19 18:57:17 +01:00
Steve Sanderson 154289ed3d Allow passing DotNetObjectRef to JS in interop calls, and invoking
instance methods on it
2018-07-19 18:57:17 +01:00
Ryan Nowak 9778b2054a Add blazor.server.js (#1116)
Adds a server-side flavored blazor script.
2018-07-13 18:01:05 -07:00
Ryan Nowak 844e38e641 Update versions to 2.1
Updates ASP.NET package versions to 2.1

Tweaks TFMs
- libraries = netstandard2.0
- exes/apps/tools = netcoreapp2.1
- unit tests = netcoreapp2.0
- e2e tests = netcoreapp2.1 (dependency on apps)

The exception to this is the Browser.JS project which depends on our
tool for its build. however this project just builds the js code so its
TFM doesn't really matter.
2018-07-05 09:53:55 -07:00
Steve Sanderson b275055835 JavaScript interop v3 (#1033)
* JavaScript interop via new IJSRuntime abstraction

* CR feedback
2018-06-25 15:14:42 +01:00
Steve Sanderson a1e613b717 When clicking <a> tag with no href, don't attempt navigation to "null". Fixes #943 2018-06-07 20:49:09 +01:00
Ryan Nowak 0fb47684c8 Fix #974
The root cause here was that we weren't setting the language version in
MSBuild, which is only for the command line version.

(cherry picked from commit 319e31f71a150e9b0d91e724f0e358390caec4c2)
2018-06-07 12:27:03 -07:00
Steve Sanderson 783edcbf4c Don't preventDefault on events. Fixes #803 2018-06-06 13:44:53 +01:00
Steve Sanderson 2492d00e75 Stylistic tweaks 2018-06-06 13:44:14 +01:00
Rémi BOURGAREL 3610068929 manages when users clicks on a link with the control button pushed. issue #867 2018-06-06 13:44:14 +01:00
Javier Calvarro Nelson 5cb544ece8 Improved interoperability
* Add support for invoking async JavaScript functions from .NET.
* Add support for invoking .NET methods from JavaScript.
* Add support for invoking async .NET methods from JavaScript.
2018-06-05 16:09:59 -07:00
Suchiman a3776b2a20 Add support for binding long / float / double / decimal 2018-06-05 16:42:31 +01:00
Steve Sanderson 353da42cce Clean up use of relative URLs. Fixes #844 and #845 (#878)
* Handle links to empty-string href, resolved against base href

Needed to change the URLs used in E2E tests to be able to cover this (i.e., removed the /RouterTest prefixes so the default relative URL became an empty string)

* Change links in StandaloneApp sample to be relative

* Standardize on base URIs having trailing slash everywhere

Hence also change terminology from "base URI prefix" to simply "base URI"

* Handle link highlighting when visiting base-href-but-without-trailing-slash

* Removing leading slashes from base-relative URLs in templates
2018-05-24 09:54:43 +01:00
Robin Sue b5128a7efd Add support for sending and receiving arbitrary HttpContent, refs #479 (#815)
* Add support for zero copy byte array marshalling

* Add support for sending arbitrary HttpContent, refs #479

* Fix unit test to set ContentType correctly

* Add support for receiving binary data

* Compare header case insensitive

* Add unit test for binary http requests
2018-05-23 10:16:27 +01:00
Ryan Nowak 6a28aa99c6 remove inadvertant test code 2018-05-02 11:07:52 +01:00
Ryan Nowak 87375f6ba1 Add support for most (if not all events)
This change adds tag helpers and defines event types for all of the DOM
events we could find. You'll find it much easier now to subcribe to
these events.

While we did define new event types, we didn't substantially expand the
set of data that we serialize for events. We're looking for feedback on
what is most critical to have, and looking for contributions adding
those data and tests.
2018-05-02 11:07:49 +01:00
Steve Sanderson be8f2d43ee Support custom events and non-bubbling standard events (#722)
* Support non-bubbling events

* Support responding to arbitrary events. E2E coverage of this and bubbling.

* Rename E2E test files to avoid clash with other PR
2018-05-01 17:12:03 +01:00
Steve Sanderson f61ed4df4f For checkboxes, bind to 'checked'. Fix special property handling in BrowserRenderer.ts. Fixes #659 and #703
* Stop the value<-->checked conversions for checkboxes. Just use native 'checked' property. Fixes #703

* Properly handle removal of 'checked' and 'value' attributes

* E2E coverage for removing 'value'
2018-05-01 16:40:07 +01:00
Steve Sanderson 76bf82eb49 OnAfterRender / OnAfterRenderAsync (#691)
* Implement OnAfterRender and OnAfterRenderAsync

* Add E2E test combining OnAfterRender with "ref" and JS interop

... because this combination is the key to integration with 3rd-party JS
libs
2018-04-27 19:45:19 +01:00
Steve Sanderson 4033560734 Support 'ref' syntax for capturing references to elements and components (#685) 2018-04-27 17:41:21 +01:00
Steve Sanderson a700fa945e Fix ordering issue with nested logical element insertion 2018-04-27 15:43:59 +01:00
Ryan Nowak ed06d7b12e Rough cut at async events 2018-04-26 13:31:28 -07:00
Steve Sanderson d02436d55c Bootstrap 4 and new styling (#619)
* Upgrade to bootstrap v4

Remove  redundant MIME type

* Add new styling to StandaloneApp

* Update THIRD-PARTY-NOTICES.txt

* Update version of Blazor used by templates when running from source

* Update styling on BlazorStandalone.CSharp template

* Tweak brace style

* Update styling in BlazorHosted.CSharp template

* Update E2E tests that rely on specific CSS

* Add Open Ionic fonts license to notices too
2018-04-19 21:06:28 +01:00
Steve Sanderson ac1af2274b Eliminate wrapper elements (#602)
* Factor out all DOM-structure modifying code into an abstraction. Currently, implementation is still backed by the same underlying DOM APIs

* Implement LogicalElement properly (store hierarchy in own property; use comment nodes as containers)

* In LogicalElement, be explicit about unsupported scenarios

* Update E2E tests to stop assuming existence of wrapper elements

* Where supported, store private properties using opaque symbols as keys
2018-04-18 13:54:25 +01:00
Steve Sanderson 2478c164b5 Update Mono to 078d5147836 (#543)
* Update Mono to 078d5147836

* Update driver.c to match updated Mono version

* Rebuild Mono binaries

* Update dependency resolution baseline to match updated Mono BCL

* Add E2E test for new RuntimeInformation values
2018-04-11 14:00:03 +01:00
Steve Sanderson bd2c8a09ef Improve JS-side event handling code. Fixes #433 2018-04-10 18:15:22 +01:00
Ryan Nowak df13669362 Improvements for delegate types (#516)
* Improve support for more types of event handlers

Improves support for for other types of event handlers with eventargs
types derived from UIEventArgs. Additionally fleshes out the set of
event handler types.

This change improves support for using more specific event handler types
like:

```
<button onclick="@Clicked" />

@functions {
    public void Clicked(UIMouseEventArgs e) { ... }
}
```

And:
```
builder.AddAttribute(12, "onkeypressed", KeyPressed);

...

void KeyPressed(UIKeyboardEventArgs e) { ... }

```

In particular what got better is:
- overload resolution for the AddAttribute method
- performance of different cases for AddAttribute

-----

The runtime now treats delegates as one of three types:
- arbitrary delegate: not attached to DOM events, not tracked by
renderer
- UIEventHandler: can attach to DOM events, tracked by renderer, first
class in IHandleEvents
- UIEventHandler-like: can attach to DOM events, tracked by renderer,
requires some special runtime support.

The set of overloads on AddAttribute has been tuned with a few specific
cases in mind.

Lambda expressions in an attribute will be inferred as UIEventHandler
unless the compiler does something more specific. So for instance,
passing a lambda as an attribute value for a component, where the
component doesn't define a matching attribute, will always be inferred
as UIEventHandler.

We now support method-group to delegate conversion for methods that
accept a derived UIEventArgs type. This means you can use a signature
like `void KeyPressed(UIKeyboardEventArgs e)` without any compiler
magic, and this will work in the runtime as long as the event type
produced by the runtime matches.

We also allow user-defined UIEventArgs-derived types. There's a pattern
for this and it requires defining an extension method and delegate type.

The method-group to delegate conversion part required some doing. It
doesn't play well with generics (Action<T> where T : UIEventArgs)
doesn't work at all. Adding more actual overloads (as opposed to
extensions) would cause lambda cases we want to work to be ambiguous.

----

The performance win here is to remove the need for a 'wrapper' delegate
created by the event handler tag helper code. This wrapper is now
created by the runtime, but only *after* we have checked the frame for
changes. This requires more heavy lifting in the runtime, but has the
advantage of producing no-op diffs as often as possible.

You will still get some inefficient behavior if your component uses a
capturing lambda in an event handler, so don't do that.

* Add selenium logs to test output

* Minor feedback

* WIP
2018-04-09 13:21:12 -07:00
Steve Sanderson 281d5a8751 Enable same-origin credentials by default. Add E2E test to show they can be sent to different-origin domains too. 2018-04-09 12:54:13 +01:00
Steve Sanderson d3dc294d5e Revert live reloading implementation. See PR for explanation. 2018-04-04 18:10:12 +01:00
Olivier Lefebvre 1626b3b8c8 Support arbitrary 'fetch' arguments 2018-04-04 10:12:42 +01:00
Steve Sanderson 2c268a4eca Live reloading (currently enabled only for command-line builds - will
add VS support next)
2018-04-02 15:33:00 +01:00
Ryouko Konpaku ef3db51bbf Text Area Bind Fix for issue #434 (#439)
* Text Area Bind Fix for issue #434

* Correct Typo/Mispelling on test method name.
2018-03-30 10:10:23 +01:00
Stephen Roe cda3692d0b Added SVG support (#366) (#435)
* Added SVG support (#366)

* Added E2E tests for SVG
2018-03-30 10:07:10 +01:00