Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Propogate additional compilation data from RoslynCompilationService #873

Closed
wants to merge 4 commits into from

Conversation

pranavkm
Copy link
Contributor

  • Update CompilationFailedException to include path of file being compiled
  • Pass in path being compiled to Rolsyn.
  • Adding doc comments for compilation pieces

Fixes #869

/// <param name="compiledCode">The contents that were compiled.</param>
/// <param name="messages">A sequence of <see cref="CompilationMessage"/> encountered during compilation.</param>
public CompilationFailedException(
[NotNull] string filePath,
Copy link
Contributor

Choose a reason for hiding this comment

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

we should also include the original razor text

@pranavkm
Copy link
Contributor Author

Updated PR to include cshtml content.

}

public string GeneratedCode { get; private set; }
/// <summary>
/// Gets the path to the file that produced the compilation failure..
Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra .

Copy link
Member

Choose a reason for hiding this comment

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

Similar to fileContent / compiledCode separation, is this the .cshtml or .cs file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We never have a cs file, the cshtml is codegened in memory to produce C# content. In System.Web, these files had to be saved to disk since it was the only way to invoke csc.exe to produce a type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to

Gets the path to the Razor source file that produced the compilation failure.

* Update CompilationFailedException to include path of file being compiled
* Pass in path being compiled to Rolsyn.
* Adding doc comments for compilation pieces

Fixes #869
{
try
{
using (var stream = file.CreateReadStream())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: not sure if style cop catches this but should you have open and closing braces for this as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

@@ -35,8 +35,7 @@ public CompilationResult Compile([NotNull] IFileInfo file)
return _cache.GetOrAdd(file, () => CompileCore(file));
}

// TODO: Make this internal
public CompilationResult CompileCore(IFileInfo file)
internal CompilationResult CompileCore(IFileInfo file)
Copy link
Member

Choose a reason for hiding this comment

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

why are we making anything internal? I see the TODO but don't get why we'd execute on it prior to an all-up API review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The method's an implementation detail. It was public when we hadn't decided on using internal for unit testing.

/// Gets the generated C# content that was compiled.
/// </summary>
/// <remarks>
/// For a Razor page, <c>ReadContent(compilationResult.File)</c> represents the actual contents on disk and
Copy link
Member

Choose a reason for hiding this comment

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

shoot. I didn't realize both File and ReadContent() were both private when I wrote my comment. How would something outside this class get the file content? is System.IO.File.ReadAllLines(FilePath) their best choice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could leave the remark out since we're more explicit about what CompiledContent is and how it differs from the file content.

@pranavkm
Copy link
Contributor Author

pranavkm commented Aug 8, 2014

Updated PR.

/// Instantiates a new instance of <see cref="CompilationFailedException"/>.
/// </summary>
/// <param name="filePath">The path of the Razor source file that was compiled.</param>
/// <param name="fileContent">The contents of the Razor source file.</param>
Copy link
Member

Choose a reason for hiding this comment

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

nit: content (here too)

Copy link
Member

Choose a reason for hiding this comment

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

looks like there's a few more instances of this nit / minor inconsistency ...

@dougbu
Copy link
Member

dougbu commented Aug 8, 2014

🚢 it after avoiding the short-term issue with the null propagating operator and fixing the bad .kproj merge.

@harshgMSFT
Copy link
Contributor

:shipit:

@pranavkm pranavkm closed this Aug 9, 2014
@pranavkm pranavkm deleted the RoslynCompilationFixes branch August 9, 2014 02:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants