Skip to content
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

Further improvements to CSX support #760

Merged
merged 12 commits into from
Feb 9, 2017

Conversation

filipw
Copy link
Member

@filipw filipw commented Feb 8, 2017

This is a follow up PR to the large work we did in #659
In that PR we removed custom scripting code and focused on "standard" Roslyn scripting.

In this PR, we take it a step further and introduce suggestions from Tomas (#659 (comment)) on how to approach CSX projects (which have no project system after all). So what we do here, is we move away from the current model of "project-per-file" to a "project-per-entry-file" model (a project is created only for a top-level CSX file and all its #load dependencies are delegated to Roslyn's ScriptSourceResolver - we never manually specify project-to-project relationships anymore).

This has some terrific results for us:

  • we can delete a ton of custom parsing code, and let Roslyn resolvers do the heavy lifting for us
  • we get support for workspace level changes out of the box - user can change #r references or #load directives and we pick them up in real time
  • multiple #load per project are now supported (in the past, due to our "project-per-file" model, only 1 was allowed - this is because a submission compilation can only have one project reference)

Fixes #227 and #689 - two most important issues we have for CSX at the moment.

Here is the behavior demo for "real time" #load:

And "real time" #r:

var cancellationSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(request.Timeout));
var metadataDocument = await _metadataHelper.GetDocumentFromMetadata(document.Project, symbol, cancellationSource.Token);
if (metadataDocument != null)
try
Copy link
Member Author

Choose a reason for hiding this comment

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

sorry this change got in by accident, will revert

@@ -62,8 +62,7 @@ public Task<Document> GetDocumentFromMetadata(Project project, ISymbol symbol, C

var service = _csharpMetadataAsSourceService.CreateInstance(temporaryDocument.Project.LanguageServices);
var method = _csharpMetadataAsSourceService.GetMethod(AddSourceToAsync);

return method.Invoke<Task<Document>>(service, new object[] { temporaryDocument, topLevelSymbol, cancellationToken });
return method.Invoke<Task<Document>>(service, new object[] {temporaryDocument, topLevelSymbol, cancellationToken});
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to indent here?

Copy link
Member Author

Choose a reason for hiding this comment

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

no 😧

CreateCsxProject(csxPath);
var csxFileName = Path.GetFileName(csxPath);
var project = ProjectInfo.Create(
id: ProjectId.CreateNewId(Guid.NewGuid().ToString()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to create a new Guid for this. ProjectId.Create() already does that. The debugName parameter is to give it something human-readable for debugging. (ref)

Logger.LogError($"{csxPath} will be ignored due to the following error:", ex.ToString());
Logger.LogError(ex.ToString());
Logger.LogError(ex.InnerException?.ToString() ?? "No inner exception.");
_logger.LogError(0, ex, $"{csxPath} will be ignored due to an following error");
Copy link
Contributor

Choose a reason for hiding this comment

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

We've got an extension method that allows you to call LogError without needing to pass an event ID now.

Copy link
Contributor

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

I love all of the red! 😄

@adamralph
Copy link
Contributor

All kinds of awesome

@filipw
Copy link
Member Author

filipw commented Feb 9, 2017

thanks, pushed the mentioned changes - should be good to go now :shipit:

@DustinCampbell
Copy link
Contributor

:shipit:

@filipw filipw merged commit ca84079 into OmniSharp:dev Feb 9, 2017
@filipw filipw deleted the feature/csx-project-model branch February 9, 2017 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants