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

Code cleanup and documentation enhancement #21

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions VSExtension1/ExtensionEntrypoint.cs → VSExtension1/Extension1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,27 @@ namespace VSExtension1
/// <summary>
/// Extension entrypoint for the VisualStudio.Extensibility extension.
/// </summary>
/// <remarks>
/// This class is responsible for initializing and configuring the extension,
/// including setting up the script engine and dependency injection.
/// </remarks>
[VisualStudioContribution]
internal class ExtensionEntrypoint : Extension
internal class Extension1 : Extension
{
/// <summary>
/// The name of the initialization file.
/// </summary>
/// <remarks>
/// This file contains the initial JavaScript code to be executed by the V8ScriptEngine.
/// </remarks>
protected const string InitializeFileName = "__init__.js";

/// <summary>
/// Creates a meta object for a document.
/// </summary>
/// <remarks>
/// This method extracts and returns meta information from the provided DocumentInfo object.
/// </remarks>
/// <param name="info">The document information.</param>
/// <returns>A dictionary containing meta information about the document.</returns>
protected static Dictionary<string, object> CreateMetaObject(DocumentInfo info)
Expand All @@ -53,10 +63,14 @@ protected static Dictionary<string, object> CreateMetaObject(DocumentInfo info)
/// <summary>
/// Creates and configures a new instance of the V8ScriptEngine.
/// </summary>
/// <remarks>
/// This method sets up the V8ScriptEngine with the necessary document settings and host objects.
/// It attempts to execute an initialization script and handles any exceptions that occur during this process.
/// </remarks>
/// <param name="serviceProvider">The service provider to resolve dependencies.</param>
/// <returns>A configured instance of the V8ScriptEngine.</returns>
/// <exception cref="ScriptEngineException">Thrown when there is an error executing the script.</exception>
/// <exception cref="FileLoadException">Thrown when there is an error loading a file.</exception>
/// <exception cref="Exception">Thrown when there is a general error during script execution.</exception>
protected static ScriptEngine CreateScriptEngine(IServiceProvider serviceProvider)
{
var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".";
Expand All @@ -80,7 +94,7 @@ protected static ScriptEngine CreateScriptEngine(IServiceProvider serviceProvide
}
catch (Exception e)
{
globalObject.Output.WriteLine("FileLoadException: " + e.Message);
globalObject.Output.WriteLine("Exception: " + e.Message);
throw;
}

Expand Down