question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Orphaned expression breaks the application

See original GitHub issue

Describe the bug

If inside a Blazor HTML expression there is orphaned symbol or expression it will break the application in result without any kind of error or warning in Visual Studio “Error list”

To Reproduce

for instance : <img id="@((@context as TreeProxyDataModel).id)" class="eimage" src="/f.png" @onclick="@((e) =>MemberFunction((@context as TreeProxyDataModel).id, e))" />

add “)”, “.” or anything in a random position

<img id="@((@context as TreeProxyDataModel).id)" class="eimage" src="/f.png" ) @onclick="@((e) =>MemberFunction((@context as TreeProxyDataModel).id, e))" />

  • No exception, error or warning will be resulted.

Further technical details

  • ASP.NET Core version : 3.1
  • Include the output of dotnet --info

.NET Core SDK (reflecting any global.json): Version: 3.1.100 Commit: cd82f021f4

Runtime Environment: OS Name: Windows OS Version: 6.3.9600 OS Platform: Windows RID: win81-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.100\

Host (useful for support): Version: 3.1.0 Commit: 65f04fb6db

.NET Core SDKs installed: 2.0.2 [C:\Program Files\dotnet\sdk] 2.1.700 [C:\Program Files\dotnet\sdk] 2.1.801 [C:\Program Files\dotnet\sdk] 2.1.802 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] 3.1.100-preview2-014569 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0-preview2.19528.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0-preview2.19525.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.0-preview2.19525.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and it’s version Visual Studio 2019 Preview 16.5.0 preview 1.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mkArtakMSFTcommented, Dec 11, 2019

Thanks for the details, @YordanYanakiev. Given this is a user-error scenario, we’ll look into addressing this during 5.0 timeline, as we’re currently focused on the upcoming Blazor WASM release, which is in May.

0reactions
SteveSandersonMScommented, Dec 13, 2019

It’s a Blazor component in one or another aspect.

I’m not completely certain which scenario you’re referring to. If you mean something like this:

<div )></div>

… then we do treat that as HTML. It’s up to the browser whether it allows this combination of tags and attributes. Current browsers choose not to allow an attribute called ), hence the runtime error.

However if you mean this:

<SurveyPrompt Title="How is Blazor working for you?" ) />

… then yes, that is a Blazor component. But this is not invalid usage. It’s valid and allowed, so the compiler is correct to allow it. Whether it throws or not at runtime depends on the behavior of the SurveyPrompt component and whether it chooses to accept a parameter called ). The one in the template doesn’t allow that, so it throws.

However if you wanted, you could change SurveryPrompt so that it does accept parameters with any name. For example, in SurveryPrompt.razor’s @code block, add this:

    public override Task SetParametersAsync(ParameterView parameters)
    {
        foreach (var param in parameters)
        {
            Console.WriteLine($"For parameter '{param.Name}', you supplied value '{param.Value}'");
        }

        return Task.CompletedTask;
    }

Now at runtime it won’t throw any more, and instead will log the following to the console:

For parameter ')', you supplied value 'True'

So now the component does allow a parameter called ), and you can implement arbitrary logic to do whatever you want with that parameter.

Aside of this - there is some rules at least which apply to all XML scripts in order to be consistent ones I believe. Is this not true for Blazor components ?

Neither HTML nor .razor are XML. XML is something different and more restrictive than either HTML or .razor.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Orphaned Case Java
Orphaned Case Java with java tutorial, features, history, variables, object, programs, operators, ... If we use comparison expression in the case statement.
Read more >
Orphaned Case Java | How to Fix an Orphaned Case Error?
In Java, an orphaned case refers to a switch statement that doesn't have a corresponding break statement. When a switch statement is executed, ......
Read more >
Rags, Widows & Orphans
A poor rag creates distracting shapes of white space in the margin. Don't rely on the line breaks generated by your software application;...
Read more >
Widows and orphans
In typesetting, widows and orphans are lines of text that dangle at the beginning and at the end of a block of text,...
Read more >
Orphaned file detection. A simple heuristic | by James Fisher
How many old files in your repository could be removed without breaking anything? A significant number, if your repository is non-trivial.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found