-
Notifications
You must be signed in to change notification settings - Fork 416
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
Cake support #932
Cake support #932
Conversation
{ | ||
var name = Path.GetFileName(filePath); | ||
|
||
var assembly = AssemblyLoader.LoadFrom(cakeScript.Host.AssemblyPath); |
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.
Use IAssemblyLoader
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.1" /> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="2.3.1" /> | ||
<PackageReference Include="Cake.Scripting.Transport" Version="0.1.0-unstable0091" /> |
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.
Should be changed to 0.1.0 once Bakery is finalized.
NuGet.Config
Outdated
@@ -5,5 +5,6 @@ | |||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" /> | |||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> | |||
<add key="dotnet-cli" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" /> | |||
<add key="cake-nightly" value="https://www.myget.org/F/cake/api/v3/index.json" /> |
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.
Is this feed permanent? I assume it not, but just checking. :)
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.
Not permanent. Only used until Cake.Scripting
bits (alias bakery
) is finalized and pushed to NuGet.
var configurationPath = Path.Combine(environment.TargetDirectory, "cake.config"); | ||
if (File.Exists(configurationPath)) | ||
{ | ||
var parser = new ConfigurationParser(); |
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.
Parser will throw if the config is found among other things, if this throws in the constructor that may be a very very bad thing when booting up MEF.
The parser should probably either not throw, or should we should catch specific exceptions that don't matter.
var value = tokens.Current.Value; | ||
if (ContainsWhiteSpace(value)) | ||
{ | ||
throw new InvalidOperationException("Sections cannot contain whitespace."); |
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.
What does cake do in this scenario, does it throw if the config has invalid values or does it default those values?
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.
Configuration handling is "copy-pasted-with-pride" from the Cake repo. Now that I look at it, I should remove any exception throwing and just set sensible defaults.
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.
A second set of 👀 always helps!
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 went the Catch-and-Log route instead. Makes more sense than silently continue and keeps code in sync with code in Cake.
- Allow updating metadatareferences and using on script change
@filipw @david-driscoll sounds like a great idea! |
FWIW, Travis CI failed on Linux. It looks like a real test failure in the Cake unit tests. Examples:
|
@DustinCampbell yes, it feels like some problem using |
@david-driscoll @filipw @DustinCampbell removed [WIP] tag now 😉 |
} | ||
else | ||
{ | ||
lineIndex = request.Line + 7; |
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.
these arbitrary offsets look scary 😄
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.
Yes it is scary, but it has a simple explanation. As GotoDefinition would normally point to the generated DSL, we are instead rerouting to the original extension method (from which the DSL was generated). Ugly, but it works 😄 7 line offset for properties, 3 line offset for methods.
{ | ||
var document = solution.GetDocument(documentId); | ||
var project = document.Project; | ||
var compilationOptions = GetCompilationOptions(e.Usings); |
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 is going to be very inefficient, why not just call compilationOptions.WithUsings()
?
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.
Ah, good catch!
I just took a look at the changes to launch |
@DustinCampbell nice! I’ll just fix @filipw’s comments then. @david-driscoll do you have anything to add? |
Nothing else from me. |
Out of curiosity, why do some files have a header:
are they copied from somewhere? |
@filipw, yes. They are copied from Cake, which is licensed under MIT license. We didn’t want OmniSharp to take on a dependency on Cake.Core and therefore it’ copied. It should only be the configuration bits. |
Per the comment, shouldn't we include the MIT License in the folder with these files? I did the same thing for |
Sure, I can do that! |
Great work @mholo65! Can't wait to get this merged in, and start to roll it out! |
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.
Since everyone signed off, I will merge it 🎉 |
Opening PR to get feedback.
Omnisharp.Cake
piggybacks onOmniSharp.Roslyn.CSharp
services, but will intercept and handle buffer updates before sending them to C# services... This is how it works.omnisharp.exe
andcake.bakery.exe
*.cake
file it is sent to the bakery process in order to get analysed and a Roslyn compatible script is returned.All feedback is welcome! @david-driscoll @DustinCampbell @filipw
here is a small example project if you like to test it out. Please note that
Cake.Bakery
(which can be fetched from our MyGet feed) needs to be located in the workspace before starting OmniSharp. It should be located in thetools
folder. E.g.${workspaceRoot}/tools/
folder or any other folder specified incake.config
.Will send accompanying PR inOmnisharp-VSCode
repo soon.TODO:
Don't hardcodeCake.Bakery.exe
path to$(toolsdir)/Cake.Bakery/tools/Cake.Bakery.exe
Fix lineoffsets when loading nested.cake
filesAdd documentation provider when loading addinsLoad downloaded addins added after server was startedAdd Unit TestsAdd integration testsCleanup