Xaml syntax highlighting changes on different ContentPage and different errors result

Will.ItraxWill.Itrax CAMember ✭✭✭

Hi,
Thanks for taking a look at this.

Our project has several ContentPages. What I can not understand is that some have one pattern for syntax highlighting and some have another. The first group give me errors and the second do not for the same code. Ok, so they are actually psuedo-errors in that they look like errors but do not affect whether or not it builds and runs. And if I close the file, the errors disappear.
But what causes the errors in the first place and why is the syntax highlighting different?

The following is a screen cap of a page that gives errors.

And the following is a screen cap of a page with no errors.

Notice that the colors are different and in the one WinPhone is considered an error. That also appears in the Error List below.

As the errors do not stop the build, it is not critical but it is annoying.

Has anyone come across this before?

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Remove that broken one and create a new cs file ,move you code into it , then check if error persists.

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    @ColeX Thanks for your suggestion. I have tried the following:
    0) made a separate copy of the ContentPage that is misbehaving
    1) deleted the Page from the Project
    2) added a new ContentPage. It had the same syntax coloring as the "bad" version above. Copy and pasting in the original had no effect. Also copying in the code from a "good" page retained the bad coloring and the errors.
    3) Creating a New Project (File->New->project-Cross-platform->Mobile App Template: Blank, .Net Standard
    This results in the "bad" coloring and when I drop in the <ContentPage.Padding> code WinPhone results in an error.

    Here is a screen shot:

    If I change WinPhone to UWP, I get rid of the "Error" (remember, it claims to be an Error but the program build and runs). But I use WinPhone like that in dozens of other ContentPages. Such a mystery.

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    @ColeX Another case where I get a false Error is in Label.FontFamily. Here is a screenCap:

    Again, I use the same code in a couple other places with no errors (and different syntax coloring).
    Thanks for considering this.

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    Out of curiosity, I replaced "WinPhone" with "UWP". That got rid of the squiggly line but Gives me an error that actually stops the build.

  • ColeXColeX Member, Xamarin Team Xamurai
    edited December 2018

    I can't reproduce this issue on my side .

    Try to repair your visual studio or reinstall it .

    Update Nuget library to the latest.

Sign In or Register to comment.