-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/172 #1110
Issue/172 #1110
Conversation
It's likely a fair bit of work to get what could turn out to break next version since it depends on internals of another library. |
@@ -308,7 +308,8 @@ private async IAsyncEnumerable<ConversionResult> ConvertProjectUnhandledAsync<TL | |||
var projectsByPath = | |||
_visualStudioWorkspace.CurrentSolution.Projects.ToLookup(p => p.FilePath, p => p); | |||
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread - ToList ensures this happens within the same thread just switched to above | |||
var projects = selectedProjects.Select(p => projectsByPath[p.FullName].First()).ToList(); | |||
var projects = selectedProjects.SelectMany(p => projectsByPath[p.FullName]).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the initial spike that allowed getting the project that's created for the open editor. I didn't pursue this since even with the faff of needing the windows open, it didn't seem to easily have access to the mapped spans to insert the code back into the original vbhtml file from the generated file
var getDocument = root.GetType().GetProperty("Document", BindingFlags.Instance | BindingFlags.Public).GetMethod; | ||
var document = getDocument.Invoke(root, BindingFlags.Instance | BindingFlags.NonPublic, null, null, null); | ||
var getChildren = document.GetType().GetProperty("Children", BindingFlags.Instance | BindingFlags.Public).GetMethod; | ||
var children = getChildren.Invoke(document, BindingFlags.Instance | BindingFlags.NonPublic, null, null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure everything needed is in here, but it will take a lot of brittle reflection calls to internal methods to put it together.
Ultimately, need to get a vb syntaxtree for the whole file, and be able to map each code block back to the vbhtml so we can insert the relevant cs there at the end of conversion.
} | ||
protected RazorProjectEngine CreateProjectEngine(Action<RazorProjectEngineBuilder> configure) | ||
{ | ||
return RazorProjectEngine.Create(RazorConfiguration.Default, RazorProjectFileSystem.Create("c:\\tmp"), configure); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May need an older version of the library to parse vbhtml, or just to tweak the settings here. If it's an older version, would need to check we're allowed to redistribute it, but it would solve any brittleness issues since it won't change.
I couldn't see a version on nuget that event references visualbasic though so maybe this library wouldn't work: https://www.nuget.org/packages/Microsoft.CodeAnalysis.Razor/2.0.0#dependencies-body-tab
I suspect there's some similar code somewhere for VB that's callable, but not sure where
Spike relates to #172
Best solution available is probably to match the vbhtml structure against the generated vb document (which follows a simple pattern), then manually call to convert each part of the syntax tree separately so it's easy to construct the final document without any manual parsing - after which the normal converter functions can be used.
I haven't found the correct settings to get the vb document yet. It may even need an older version of the library that targeted dot net framework