Extension causing exception in VS2017

PHP Tools [?] extends Visual Studio with set of advanced features to work more efficiently with PHP code.

Extension causing exception in VS2017

Postby metal450 » April 1st, 2018, 5:17 am

Using PHP Tools in Visual Studio 2017 Enterprise, I'm constantly getting "An exception has been encountered. This may be caused by an extension." Here's what the dialog looks like: https://www.screencast.com/t/GRLwSHmh

It pops up when pasting in a simple single line of code. Simple as in... $var = "text";

The relevant entry in ActivityLog.xml is:

Code: Select all
<entry>
    <record>681</record>
    <time>2018/04/01 05:07:34.524</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.InvalidOperationException: Document is malformed. Php code on line 1132 in Html document isn&apos;t supported by formatter.&#x000D;&#x000A;   at HtmlAgilityPack.HtmlDocument.Parse()&#x000D;&#x000A;   at HtmlAgilityPack.HtmlDocument.Load(TextReader reader, ArtifactCollection artifacts)&#x000D;&#x000A;   at HtmlAgilityPack.HtmlDocument.LoadHtml(String html, ArtifactCollection artifacts)&#x000D;&#x000A;   at Devsense.VisualStudio.Html.Formatting.HtmlFormatter.FormatRange(ITextProvider textProvider, ITextRange range, ArtifactCollection artifacts, ITextRange&amp; actualRange, String&amp; originalText)&#x000D;&#x000A;   at &#x0006;&#x0009;&#x001B;&#x001B;&#x0017;&#x0003;&#x0013;&#x0012;&#x0002;&#x0007; &#x0009;&#x000C;&#x0009;&#x0013;&#x0004;&#x0008;&#x0007;&#x0010;&#x0004;&#x0007;&#x000F;&#x0003;&#x001B;&#x001D;.&#x0018;&#x0017;&#x000D;&#x0013;&#x0015;&#x0010;&#x000F;&#x0017;&#x001C;&#x0002;&#x0011;&#x0008;&#x0007;&#x0002;&#x0009;&#x0010;&#x000B;&#x0007;&#x0019;&#x001B;&#x0009;&#x000D;&#x0009;&#x0001;&#x0002;(Span &#x0006;&#x000E;&#x0001;&#x000D;&#x001A;&#x0017;&#x001E;&#x0019;&#x000F;&#x001D;&#x0019;&#x000C;&#x0003;&#x0009;&#x0009;&#x001C;&#x0012;&#x0018;&#x000D;&#x0011;&#x0005;&#x000F;&#x0007;&#x0004;, HtmlExternalFormatters &#x0006;&#x0008;&#x000F;&#x0013;&#x000F;&#x000E;&#x0004;&#x0012;&#x0006;&#x0016;&#x0005;&#x0003;&#x0011;&#x001E;&#x001B;&#x000E;&#x0003;&#x0008;&#x000B; &#x000C;&#x0011;&#x001C;&#x0004;&#x000C;)&#x000D;&#x000A;   at &#x0015;&#x000E;&#x001E;&#x001F;&#x0016;&#x0018;&#x000F;&#x0006;&#x0018;&#x000F;&#x0019; &#x0013;&#x0010;&#x001D;&#x0008;&#x0012;&#x0005;&#x001B;&#x001B;&#x0018;&#x0003;&#x0016;&#x0005;&#x0015;.&#x0004;&#x0008;&#x0013;&#x0010;&#x001D;&#x001F;&#x0018; &#x0007;&#x0018;&#x000C;&#x0017;&#x001E;&#x000E;&#x0016;&#x0002; &#x000C;&#x0001;&#x0012;&#x0005;&#x001A;&#x001E;&#x001E;&#x000E;.&#x000B;&#x0011;&#x0012;&#x001F;&#x0003; &#x0006;&#x000E;&#x000E;&#x0012;&#x0011;&#x0013;&#x0019;&#x000D;&#x000B;&#x0007;&#x0017;&#x0007;&#x001A;&#x0017;&#x000C;&#x0010;&#x0010;&#x0003;&#x001D;()&#x000D;&#x000A;   at Devsense.VisualStudio.Shell.GuardedOperations.Call(Object source, Action action)</description>
  </entry>


The relevant section of code (around line 1132) is a mix of PHP & javascript, something like:

Code: Select all
function exampleFunc( $someCode )
{
?>

        FB.api('/me/permissions', function(response)
        {
            <?php echo $someCode;?>
        });
<?php
}


The line of code that I'm pasting in when the exception pops up is nowhere near this block; i.e. if I just paste in a simple line way at the beginning of the file, it still throws up the exception.
metal450
 
Posts: 8
Joined: July 9th, 2016, 5:53 am

Re: Extension causing exception in VS2017

Postby metal450 » April 1st, 2018, 5:42 am

...Also, I'm not sure if this is related but I'm guessing it is, it keeps messing up all the formatting in my php document, seemingly without logic or warning. Like I'll paste a line of PHP, and all of a sudden half the document will have reformatted itself. It looks like it's usually removing whitespace or newlines - but not just around the paste, all over the document. For example, I might have:

<div />
<?php /*some php*/ ?>


Then I'll paste something elsewhere in the document (hundreds of lines away), and this will suddenly become:
<div /><?php /*some php*/ ?>


I just lost like 3 hours of development work because upon checking the diffs before committing to git, I discovered that like 80% of the lines had changed. It was impossible to figure out where the actual relevant work was, so I pretty much just had to do it over again. Then partway through doing so, I realized what had happened: I can't ever copy/paste, as whenever I do it takes it upon itself to reformat all the code.
metal450
 
Posts: 8
Joined: July 9th, 2016, 5:53 am

Re: Extension causing exception in VS2017

Postby metal450 » April 2nd, 2018, 6:08 pm

Addendum: I tried disabling everything under Options->Text Editor->PHP->Formatting->General. That made it stop reporting the exception, but it still persists silently reformatting the whole document whenever I paste. Basically, making the addon unusable... :(
metal450
 
Posts: 8
Joined: July 9th, 2016, 5:53 am

Re: Extension causing exception in VS2017

Postby Miloslav Beno » April 3rd, 2018, 9:37 am

Hello,

My apologies for this experience. Could you please send me the complete file that causes this? info at devsense.com We will analyse the file ASAP.

Thanks!
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbenomiloslav@devsense.com
User avatar
Miloslav Beno
 
Posts: 1153
Joined: January 7th, 2012, 8:36 pm

Re: Extension causing exception in VS2017

Postby Miloslav Beno » April 6th, 2018, 2:11 pm

Thanks again for sending me the code snippet.

We've fixed the copy/paste exception, it will be ready in the next update.

Cheers,
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbenomiloslav@devsense.com
User avatar
Miloslav Beno
 
Posts: 1153
Joined: January 7th, 2012, 8:36 pm


Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 2 guests

cron

User Control Panel

Login

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 62 on January 7th, 2012, 10:54 pm

Users browsing this forum: No registered users and 2 guests
Phalanger