PistonDevelopers / VisualRust

Visual Studio extension for Rust
MIT License
702 stars 72 forks source link

Bug in Visual Studio Community 2013 #268

Open huettenhain opened 7 years ago

huettenhain commented 7 years ago

I have installed the Plugin, I run Visual Studio Community 2013 on Windows 2008 Server R2. Usually, differences to Windows 7 are negligible. When creating a new "Rust Application" project, I receive the following error message:

error

where I have anonymized the path to my ActivityLog.xml. The file contains two error messages towards the end:

<?xml version="1.0" encoding="utf-16"?>
<?xml-stylesheet type="text/xsl" href="ActivityLog.xsl"?>
<activity>
  <entry>
    <record>334</record>
    <time>2017/02/13 11:16:02.231</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.&#x000D;&#x000A;&#x000D;&#x000A;1) Cannot set the value of &apos;VisualRust.Text.RustClassifierProvider.lexer&apos; because the member is not writable. If the member is a property, it must have an accessible setter; otherwise, if it is a field, it must not be read-only.&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: Cannot activate part &apos;VisualRust.Text.RustClassifierProvider&apos;.&#x000D;&#x000A;Element: VisualRust.Text.RustClassifierProvider --&gt;  VisualRust.Text.RustClassifierProvider&#x000D;&#x000A;&#x000D;&#x000A;Resulting in: Cannot get export &apos;VisualRust.Text.RustClassifierProvider (ContractName=&quot;Microsoft.VisualStudio.Text.Tagging.ITaggerProvider&quot;)&apos; from part &apos;VisualRust.Text.RustClassifierProvider&apos;.&#x000D;&#x000A;Element: VisualRust.Text.RustClassifierProvider (ContractName=&quot;Microsoft.VisualStudio.Text.Tagging.ITaggerProvider&quot;) --&gt;  VisualRust.Text.RustClassifierProvider&#x000D;&#x000A;&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart)&#x000D;&#x000A;   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()&#x000D;&#x000A;   at System.ComponentModel.Composition.Primitives.Export.get_Value()&#x000D;&#x000A;   at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)&#x000D;&#x000A;   at System.ComponentModel.Composition.ExportServices.&lt;&gt;c__DisplayClass4`2.&lt;CreateStronglyTypedLazyOfTM&gt;b__1()&#x000D;&#x000A;   at System.Lazy`1.CreateValue()&#x000D;&#x000A;   at System.Lazy`1.LazyInitValue()&#x000D;&#x000A;   at System.Lazy`1.get_Value()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)</description>
  </entry>
  <entry>
    <record>335</record>
    <time>2017/02/13 11:16:02.418</time>
    <type>Error</type>
    <source>Color Theme Service</source>
    <description>The color &apos;Popup&apos; in category &apos;de7b1121-99a4-4708-aedf-15f40c9b332f&apos; does not exist.</description>
  </entry>
</activity>

The source file in this project then has no syntax highlighting. Building and running executables works fine.

Observation: When I reload the project, or close the solution and re-open it without restarting Visual Studio, syntax highlighting works and no error message is displayed. However, the error re-occurs every time I open Visual Studio for the first time and then load the rust application project.

huettenhain commented 7 years ago

I just opened the same solution on a Windows 10 computer with Visual Studio 2015 and Visual Rust installed - there is no error message and the syntax highlighting works. The problem seems to be with VS2013 or my OS.

MaulingMonkey commented 7 years ago

record 334

reformatted for readability:

System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Cannot set the value of 'VisualRust.Text.RustClassifierProvider.lexer' because the member is not writable. If the member is a property, it must have an accessible setter; otherwise, if it is a field, it must not be read-only.

Resulting in: Cannot activate part 'VisualRust.Text.RustClassifierProvider'.
Element: VisualRust.Text.RustClassifierProvider -->  VisualRust.Text.RustClassifierProvider

Resulting in: Cannot get export 'VisualRust.Text.RustClassifierProvider (ContractName="Microsoft.VisualStudio.Text.Tagging.ITaggerProvider")' from part 'VisualRust.Text.RustClassifierProvider'.
Element: VisualRust.Text.RustClassifierProvider (ContractName="Microsoft.VisualStudio.Text.Tagging.ITaggerProvider") -->  VisualRust.Text.RustClassifierProvider

   at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
   at System.ComponentModel.Composition.Primitives.Export.get_Value()
   at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
   at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedLazyOfTM>b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)

It's complaining about this:

        [Import]
        readonly IRustLexer lexer; // <---

        [ImportingConstructor]
        public RustClassifierProvider(IRustLexer lexer)
        {
            this.lexer = lexer;
        }

https://github.com/PistonDevelopers/VisualRust/blob/e74bc0198df0b0f19bc0781b5dd85f1c99365edb/src/VisualRust/Text/RustClassifierProvider.cs#L33

I don't know enough about VS extension to be certain, but I think we don't need to both [Import] and init this via [ImportingConstructor].

tl;dr: I just need to remove either [Import] or readonly and the ctor.

record 335

seems unrelated.

MaulingMonkey commented 7 years ago

Should be fixed by https://github.com/MaulingMonkey/VisualRust/commit/38b5e9dbfb3ee211ff279ade3bad4a2410a21edd