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

Commit

Permalink
Removed debug code that for some reason crashed runtime. _Shouldn't_ …
Browse files Browse the repository at this point in the history
…crash even if it was there though. Did I somehow manage to release a debug version?Added MDK dev console and relevant output

Changed how solution load status is detected (attempt to fix #141 and #156
  • Loading branch information
Malware committed Jul 7, 2019
1 parent 66ba03f commit 0be058d
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 102 deletions.
1 change: 1 addition & 0 deletions Source/IngameScriptTemplate/ProjectTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="netstandard" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down
5 changes: 0 additions & 5 deletions Source/MDK/Build/Solution/ProgramDocumentComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ bool IsDebugDocument(string filePath, MDKProjectProperties config)
if (fileName.IndexOf(".debug.", StringComparison.CurrentCultureIgnoreCase) >= 0)
return true;

if (filePath.Contains("Bootstrapper.cs"))
{
Debugger.Break();
}

return config.IsIgnoredFilePath(filePath);
}

Expand Down
11 changes: 10 additions & 1 deletion Source/MDK/Commands/ProjectDependentCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ protected override void OnBeforeQueryStatus()

protected bool TryGetValidProject(out Project project, out MDKProjectProperties projectProperties)
{
var package = (MDKPackage)Package;
package.Echo("MDK Command", Id, "is attempting to retrieve an MDK project");
var dte2 = (EnvDTE80.DTE2)Package.DTE;
project = ((IEnumerable)dte2.ToolWindows.SolutionExplorer.SelectedItems)
.OfType<UIHierarchyItem>()
Expand All @@ -28,11 +30,18 @@ protected bool TryGetValidProject(out Project project, out MDKProjectProperties
.FirstOrDefault();
if (project == null)
{
package.Echo("MDK Command", Id, "failed because no project could be found");
projectProperties = null;
return false;
}
projectProperties = MDKProjectProperties.Load(project.FullName, project.Name);
return projectProperties.IsValid;
if (projectProperties.IsValid)
{
package.Echo("MDK Command", Id, "retrieved a valid project");
return true;
}
package.Echo("MDK Command", Id, "did not retrieve a valid project");
return false;
}

protected bool TryGetValidProject(out MDKProjectProperties projectProperties)
Expand Down
4 changes: 2 additions & 2 deletions Source/MDK/MDKPackage.GeneratedInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class MDKPackage
/// <summary>
/// The current package version
/// </summary>
public static readonly Version Version = new Version("1.2.15");
public static readonly Version Version = new Version("1.2.21");

/// <summary>
/// The required IDE version
Expand All @@ -20,7 +20,7 @@ public partial class MDKPackage
/// <summary>
/// Determines whether this version is a prerelease version
/// </summary>
public const bool IsPrerelease = false;
public const bool IsPrerelease = true;

/// <summary>
/// Gets the help page navigation URL
Expand Down
59 changes: 52 additions & 7 deletions Source/MDK/MDKPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using EnvDTE;
using EnvDTE80;
using Malware.MDKServices;
using MDK.Build;
using MDK.Commands;
Expand Down Expand Up @@ -109,11 +110,8 @@ protected override void Dispose(bool disposing)
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
Echo("Initializing MDK");
_solutionManager = new SolutionManager(this);
_solutionManager.BeginRecording();
_solutionManager.ProjectLoaded += OnProjectLoaded;
_solutionManager.SolutionLoaded += OnSolutionLoaded;
_solutionManager.SolutionClosed += OnSolutionClosed;

// Make sure the dialog page is loaded, since the options are needed in other threads and not preloading it
// here will cause a threading exception.
Expand Down Expand Up @@ -141,9 +139,17 @@ void OnUpdateDetected(Version detectedVersion)
UpdateDetectedDialog.ShowDialog(new UpdateDetectedDialogModel(detectedVersion));
}

void OnShellActivated()
async void OnShellActivated()
{
_solutionManager.EndRecording();
await JoinableTaskFactory.SwitchToMainThreadAsync();
if (_solutionManager.Status == SolutionStatus.Loaded)
{
Echo("A solution is already loaded on start");
OnSolutionLoaded(DTE.Solution);
}
_solutionManager.ProjectLoaded += OnProjectLoaded;
_solutionManager.SolutionLoaded += OnSolutionLoaded;
_solutionManager.SolutionClosed += OnSolutionClosed;
}

void OnSolutionClosed(object sender, EventArgs e)
Expand All @@ -153,6 +159,7 @@ void OnSolutionClosed(object sender, EventArgs e)

void OnSolutionLoaded(object sender, EventArgs e)
{
Echo("Detected the loading of a solution");
OnSolutionLoaded(DTE.Solution);
}

Expand All @@ -164,6 +171,7 @@ void OnProjectLoaded(object sender, ProjectLoadedEventArgs e)

async void OnProjectLoaded(Project project)
{
Echo("Detected the loading of a project");
HealthAnalysis analysis;
try
{
Expand Down Expand Up @@ -273,7 +281,8 @@ HealthAnalysisOptions GetAnalysisOptions() =>
GameAssemblyNames = GameAssemblyNames,
GameFiles = GameFiles,
UtilityAssemblyNames = UtilityAssemblyNames,
UtilityFiles = UtilityFiles
UtilityFiles = UtilityFiles,
Echo = v => Echo(v)
};

void PresentAnalysisResults(params HealthAnalysis[] analysis)
Expand Down Expand Up @@ -411,5 +420,41 @@ public void ShowError(string title, string description, Exception exception)
};
ErrorDialog.ShowDialog(errorDialogModel);
}

static readonly Guid OutputGuid = new Guid("9D599C61-0B50-46FD-9230-7709866F32B7");

/// <summary>
/// Echoes output information to the MDK dev console.
/// </summary>
/// <param name="values"></param>
public void Echo(params object[] values)
{
string message;
if (values == null || values.Length == 0)
message = "";
else
message = string.Join(" ", values.Select(TranslateForEcho));

EchoAsync(message);
}

async void EchoAsync(string message)
{
var output = (IVsOutputWindow)await GetServiceAsync(typeof(SVsOutputWindow));
var paneGuid = OutputGuid;
output.GetPane(ref paneGuid, out var pane);
if (pane == null)
{
output.CreatePane(ref paneGuid, "MDK Dev Console", 1, 1);
output.GetPane(ref paneGuid, out pane);
}

pane.OutputString($"{message}\n");
}

string TranslateForEcho(object value)
{
return (value == null) ? "(null)" : value.ToString();
}
}
}
Loading

0 comments on commit 0be058d

Please sign in to comment.