Skip to content

Fix ContainedLanguage support for Workflow v1 XOML files - #1021

Merged
DustinCampbell merged 2 commits into
dotnet:masterfrom
DustinCampbell:fix-workflow-v1-issues
Mar 4, 2015
Merged

Fix ContainedLanguage support for Workflow v1 XOML files#1021
DustinCampbell merged 2 commits into
dotnet:masterfrom
DustinCampbell:fix-workflow-v1-issues

Conversation

@DustinCampbell

Copy link
Copy Markdown
Member

Workflow XOML files call into IVsContainedLanguageFactory.GetLanguage(), passing an IVsTextBufferCoordinator. However, that IVsTextBufferCoordinator is constructed differently than the one we get from Venus and breaks some assumptions in the C#/VB language services.

The critical assumption that XOML breaks is that the primary buffer is an IProjectionBuffer. This is not true for XOML. Instead, it is simply a non-projected buffer with the HTML content type. So, our code attempts to cast to an IProjectionBuffer and we crash before ever creating a ContainedDocument and adding it to the workspace. To fix this, we need to break the IProjectionBuffer assumption and update any calling code depending on projections to dynamically cast to IProjectionBuffer first. This unblocks several Workflow v1 scenarios.

Next, it turns out that XOML never calls SetHost() on the IVsContainedLanguage that we return. So, there's never an IVsContainedLanguageHost hooked up and calling code needs to be updated to guard against null hosts.

Workflow XOML files call into IVsContainedLanguageFactory.GetLanguage(),
passing an IVsTextBufferCoordinator. However, that
IVsTextBufferCoordinator is constructed differently than the one we get
from Venus and breaks some assumptions in the C#/VB language services.

The critical assumption that XOML breaks is that the primary buffer is
an IProjectionBuffer. This is not true for XOML. Instead, it is simply a
non-projected buffer with the HTML content type.  So, our code attempts
to cast to an IProjectionBuffer and we crash before ever creating a
ContainedDocument and adding it to the workspace. To fix this, we need
to break the IProjectionBuffer assumption and update any calling code
depending on projections to dynamically cast to IProjectionBuffer first.
This unblocks several Workflow v1 scenarios.

Next, it turns out that XOML never calls SetHost() on the
IVsContainedLanguage that we return. So, there's never an
IVsContainedLanguageHost hooked up and calling code needs to be updated
to guard against null hosts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an assert that _hostType == HostType.Razor so that the case below is safe?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point.

@Pilchie

Pilchie commented Mar 4, 2015

Copy link
Copy Markdown
Member

👍

@gafter gafter added the Area-IDE label Mar 4, 2015
@DustinCampbell

Copy link
Copy Markdown
Member Author

@dotnet-bot test this please

DustinCampbell added a commit that referenced this pull request Mar 4, 2015
Fix ContainedLanguage support for Workflow v1 XOML files
@DustinCampbell
DustinCampbell merged commit 9a22a87 into dotnet:master Mar 4, 2015
@DustinCampbell
DustinCampbell deleted the fix-workflow-v1-issues branch March 4, 2015 23:27
@DustinCampbell DustinCampbell added this to the 1.0-rc2 milestone Mar 5, 2015
dibarbet pushed a commit that referenced this pull request Aug 18, 2026
…typetag-from-vstemplates

remove VSSDK template tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants