Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
The dependency property for the FolderBox was not correctly set up so the bindings did not update
The analyzer was applied to _all_ projects
The analyzer was registered twice
Added a messagebox informing that the whitelist refresh command is not yet available
Added a "deployment complete" message box
  • Loading branch information
Malware committed Jul 25, 2017
1 parent c1de280 commit 3d8d3de
Show file tree
Hide file tree
Showing 45 changed files with 546 additions and 231 deletions.
20 changes: 17 additions & 3 deletions Source/IngameScriptTemplate/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,31 @@ partial class Program: MyGridProgram

public Program()
{

// The constructor, called only once every session and
// always before any other method is called. Use it to
// initialize your script.
//
// The constructor is optional and can be removed if not
// needed.
}

public void Save()
{

// Called when the program needs to save its state. Use
// this method to save your state to the Storage field
// or some other means.
//
// This method is optional and can be removed if not
// needed.
}

public void Main(string argument)
{

// The main entry point of the script, invoked every time
// one of the programmable block's Run actions are invoked.
//
// The method itself is required, but the argument above
// can be removed if not needed.
}
}
}
17 changes: 16 additions & 1 deletion Source/MDK/Build/AnalysisExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

namespace MDK.Build
{
/// <summary>
/// Extra utility functions while dealing with Roslyn code analysis
/// </summary>
public static class AnalysisExtensions
{
/// <summary>
/// Retrieves the fully qualified name of the given symbol.
/// </summary>
/// <param name="symbol"></param>
/// <param name="flags"></param>
/// <returns></returns>
public static string GetFullName(this ISymbol symbol, DeclarationFullNameFlags flags = DeclarationFullNameFlags.Default)
{
var ident = new List<string>(10)
Expand All @@ -26,6 +35,12 @@ public static string GetFullName(this ISymbol symbol, DeclarationFullNameFlags f
return string.Join(".", ident);
}

/// <summary>
/// Retrieves the fully qualified name of the given type declaration.
/// </summary>
/// <param name="typeDeclaration"></param>
/// <param name="flags"></param>
/// <returns></returns>
public static string GetFullName(this TypeDeclarationSyntax typeDeclaration, DeclarationFullNameFlags flags = DeclarationFullNameFlags.Default)
{
var ident = new List<string>(10)
Expand Down Expand Up @@ -53,4 +68,4 @@ public static string GetFullName(this TypeDeclarationSyntax typeDeclaration, Dec
return string.Join(".", ident);
}
}
}
}
17 changes: 15 additions & 2 deletions Source/MDK/Build/BuildConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@

namespace MDK.Build
{
/// <summary>
/// Contains build configuration
/// </summary>
public class BuildConfig
{
/// <summary>
/// Loads build configuration from the given JSON file
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static BuildConfig Load(string fileName)
{
return JsonConvert.DeserializeObject<BuildConfig>(File.ReadAllText(fileName));
}

/// <summary>
/// The target directory where the final file should be placed
/// </summary>
public string Output { get; set; } = Environment.CurrentDirectory;

/// <summary>
/// Whether or not the minifier should be invoked on the generated script file.
/// </summary>
public bool Minify { get; set; }

}
}
}
39 changes: 33 additions & 6 deletions Source/MDK/Build/BuildException.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
using System;
using System.Runtime.Serialization;

namespace MDK.Build {
namespace MDK.Build
{
/// <summary>
/// Represents exceptions happening during a build
/// </summary>
[Serializable]
public class BuildException : Exception
{
public BuildException() { }
public BuildException(string message) : base(message) { }
public BuildException(string message, Exception inner) : base(message, inner) { }
/// <summary>
/// Creates an instance of <see cref="BuildException"/>
/// </summary>
public BuildException()
{ }

/// <summary>
/// Creates an instance of <see cref="BuildException"/>
/// </summary>
/// <param name="message"></param>
public BuildException(string message) : base(message)
{ }

/// <summary>
/// Creates an instance of <see cref="BuildException"/>
/// </summary>
/// <param name="message"></param>
/// <param name="inner"></param>
public BuildException(string message, Exception inner) : base(message, inner)
{ }

/// <summary>
/// Creates an instance of <see cref="BuildException"/>
/// </summary>
/// <param name="info"></param>
/// <param name="context"></param>
protected BuildException(
SerializationInfo info,
StreamingContext context) : base(info, context) { }
StreamingContext context) : base(info, context)
{ }
}
}
}
40 changes: 31 additions & 9 deletions Source/MDK/Build/BuildModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@

namespace MDK.Build
{
/// <summary>
/// A service designed to combine C# class files into a coherent Space Engineers script.
/// </summary>
public class BuildModule
{
readonly IProgress<float> _progress;
Project[] _scriptProjects;
int _steps;

/// <summary>
/// Creates a new instance of <see cref="BuildModule"/>
/// </summary>
/// <param name="package"></param>
/// <param name="solutionFileName"></param>
/// <param name="progress"></param>
public BuildModule(MDKPackage package, [NotNull] string solutionFileName, IProgress<float> progress = null)
{
_progress = progress;
Expand All @@ -28,14 +37,29 @@ public BuildModule(MDKPackage package, [NotNull] string solutionFileName, IProgr
SynchronizationContext = SynchronizationContext.Current;
}

/// <summary>
/// The synchronization context the service will use to invoke any callbacks, as it runs asynchronously.
/// </summary>
public SynchronizationContext SynchronizationContext { get; }

/// <summary>
/// The <see cref="MDKPackage"/>
/// </summary>
public MDKPackage Package { get; }

/// <summary>
/// The file name of the solution to build
/// </summary>
public string SolutionFileName { get; }

/// <summary>
/// The document analysis utility
/// </summary>
public DocumentAnalyzer Analyzer { get; } = new DocumentAnalyzer();

/// <summary>
/// The current step index for the build. Moves towards <see cref="TotalSteps"/>.
/// </summary>
protected int Steps
{
get => _steps;
Expand All @@ -48,17 +72,15 @@ private set
}
}

/// <summary>
/// The total number of steps to reach before the build is complete.
/// </summary>
protected int TotalSteps { get; private set; }

public Task Preload()
{
return Task.Run(async () =>
{
_scriptProjects = await LoadScriptProjects();
await Task.WhenAll(_scriptProjects.Select(Build)).ConfigureAwait(false);
});
}

/// <summary>
/// Starts the build.
/// </summary>
/// <returns></returns>
public Task Run()
{
return Task.Run(async () =>
Expand Down
13 changes: 12 additions & 1 deletion Source/MDK/Build/DeclarationFullNameFlags.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace MDK.Build
{
/// <summary>
/// Flags altering the behavior of <see cref="AnalysisExtensions.GetFullName(ISymbol, DeclarationFullNameFlags)"/> and <see cref="AnalysisExtensions.GetFullName(TypeDeclarationSyntax, DeclarationFullNameFlags)"/>
/// </summary>
[Flags]
public enum DeclarationFullNameFlags
{
/// <summary>
/// Default behavior. Returns a complete, fully qualified name, including the namespace.
/// </summary>
Default = 0b0000,

/// <summary>
/// Only generates the name up to the outermost type declaration. Does not include the namespace.
/// </summary>
WithoutNamespaceName = 0b0001
}
}
}
17 changes: 16 additions & 1 deletion Source/MDK/Build/DocumentAnalysisResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@

namespace MDK.Build
{
/// <summary>
/// Contains the results of a document analysis performed by <see cref="DocumentAnalyzer.Analyze"/>.
/// </summary>
public class DocumentAnalysisResult
{
/// <summary>
/// Creates a new instance of <see cref="DocumentAnalysisResult"/>
/// </summary>
/// <param name="parts"></param>
/// <param name="usingDirectives"></param>
public DocumentAnalysisResult(ImmutableArray<ScriptPart> parts, ImmutableArray<UsingDirectiveSyntax> usingDirectives)
{
Parts = parts;
UsingDirectives = usingDirectives;
}

/// <summary>
/// The <see cref="ScriptPart"/> definitions detected in the document
/// </summary>
public ImmutableArray<ScriptPart> Parts { get; }

/// <summary>
/// The using directives detected in the document
/// </summary>
public ImmutableArray<UsingDirectiveSyntax> UsingDirectives { get; }
}
}
}
10 changes: 9 additions & 1 deletion Source/MDK/Build/DocumentAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@

namespace MDK.Build
{
/// <summary>
/// Analyses a document, finding <see cref="ScriptPart"/> and other useful information related to a build operation.
/// </summary>
public class DocumentAnalyzer
{
/// <summary>
/// Analyse the given document
/// </summary>
/// <param name="document"></param>
/// <returns></returns>
public async Task<DocumentAnalysisResult> Analyze(Document document)
{
var text = await document.GetTextAsync();
Expand Down Expand Up @@ -76,4 +84,4 @@ public override void VisitClassDeclaration(ClassDeclarationSyntax node)
}
}
}
}
}
11 changes: 10 additions & 1 deletion Source/MDK/Build/ExtensionScriptPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@

namespace MDK.Build
{
/// <summary>
/// Represents a script part which consists of an extension class; that is a class that is defined outside of the Program.
/// </summary>
public class ExtensionScriptPart : ScriptPart
{
/// <summary>
/// Creates a new instance of <see cref="ExtensionScriptPart"/>
/// </summary>
/// <param name="document"></param>
/// <param name="partRoot"></param>
public ExtensionScriptPart(Document document, SyntaxNode partRoot) : base(document, partRoot)
{ }

/// <inheritdoc />
public override IEnumerable<SyntaxNode> ContentNodes()
{
yield return PartRoot;
}
}
}
}
Loading

0 comments on commit 3d8d3de

Please sign in to comment.