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

Commit

Permalink
Attempt to fix various strange warnings and crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Malware committed Jul 21, 2018
1 parent 832f095 commit d5b1e8c
Show file tree
Hide file tree
Showing 33 changed files with 2,218 additions and 285 deletions.
19 changes: 6 additions & 13 deletions Source/MDK/MDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@
<Compile Include="Build\UsageAnalysis\UsageAnalyzer.cs" />
<Compile Include="Build\Solution\UsingDirectiveComparer.cs" />
<Compile Include="Build\DocumentAnalysis\WeightedPartSorter.cs" />
<Compile Include="Views\VersionDetection\VisualStudioVersionDialog.xaml.cs">
<DependentUpon>VisualStudioVersionDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Views\VersionDetection\VisualStudioVersionDialogModel.cs" />
<Compile Include="VisualStudio\VsVersion.cs" />
<Compile Include="Commands\GlobalBlueprintManagerCommand.cs" />
<Compile Include="Commands\BlueprintManagerCommand.cs" />
<Compile Include="Commands\CommandGroups.cs" />
Expand Down Expand Up @@ -155,7 +150,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Commands\RefreshWhitelistCacheCommand.cs" />
<Compile Include="Commands\QuickDeploySolutionCommand.cs" />
<Compile Include="MDKPackage.cs" />
<Compile Include="MDKPackage.cs">
<VSIXSubPath>Analyzers</VSIXSubPath>
</Compile>
<Compile Include="Build\StringExtensions.cs" />
<Compile Include="Views\ModelCommand.cs" />
<Compile Include="Views\Options\ScriptOptionsDialogModel.cs" />
Expand Down Expand Up @@ -199,9 +196,9 @@
<Content Include="Resources\RunMDKToolCommandPackage.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MDKAnalyzer_Legacy\MDKAnalyzer_Legacy.csproj">
<Project>{26f72d79-cf7a-4e34-934b-9221722d0482}</Project>
<Name>MDKAnalyzer_Legacy</Name>
<ProjectReference Include="..\MDKAnalyzer\MDKAnalyzer.csproj">
<Project>{003de686-c301-430b-b01a-d9a346797e88}</Project>
<Name>MDKAnalyzer</Name>
<VSIXSubPath>Analyzers</VSIXSubPath>
</ProjectReference>
<ProjectReference Include="..\MDKServices\MDKServices.csproj">
Expand Down Expand Up @@ -535,10 +532,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\VersionDetection\VisualStudioVersionDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\UpdateDetection\UpdateDetectedDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
5 changes: 5 additions & 0 deletions Source/MDK/MDKPackage.GeneratedInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public partial class MDKPackage
/// </summary>
public static readonly Version Version = new Version("1.1.11");

/// <summary>
/// The required IDE version
/// </summary>
public static readonly Version RequiredIdeVersion = new Version("15.0");

/// <summary>
/// Determines whether this version is a prerelease version
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions Source/MDK/MDKPackage.GeneratedInfo.csx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var isPrerelease = string.Equals(other.XPathSelectElement("/Other/IsPrerelease")
var helpPageUrl = other.XPathSelectElement("/Other/HelpPageUrl")?.Value ?? "";
var releasePageUrl = other.XPathSelectElement("/Other/ReleasePageUrl")?.Value ?? "";
var issuesPageUrl = other.XPathSelectElement("/Other/IssuesPageUrl")?.Value ?? "";
var requiredIdeVersion = other.XPathSelectElement("/Other/RequiredIdeVersion")?.Value ?? "";

Context.Output.WriteLine($@"using System;
using System.Collections.Immutable;
Expand All @@ -57,6 +58,11 @@ namespace {namespaceName}
/// </summary>
public static readonly Version Version = new Version(""{version}"");
/// <summary>
/// The required IDE version
/// </summary>
public static readonly Version RequiredIdeVersion = new Version(""{requiredIdeVersion}"");
/// <summary>
/// Determines whether this version is a prerelease version
/// </summary>
Expand Down
80 changes: 37 additions & 43 deletions Source/MDK/MDKPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace MDK
{
/// <summary>
/// The MDK Visual Studio Extension
/// The MDK Visual Studio Extension
/// </summary>
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
Expand All @@ -38,7 +38,7 @@ namespace MDK
public sealed partial class MDKPackage : ExtendedPackage
{
/// <summary>
/// RunMDKToolCommandPackage GUID string.
/// RunMDKToolCommandPackage GUID string.
/// </summary>
public const string PackageGuidString = "7b9c2d3e-b001-4a3e-86a8-00dc6f2af032";

Expand All @@ -47,38 +47,30 @@ public sealed partial class MDKPackage : ExtendedPackage
SolutionManager _solutionManager;

/// <summary>
/// Creates a new instance of <see cref="MDKPackage" />
/// Creates a new instance of <see cref="MDKPackage" />
/// </summary>
public MDKPackage()
{
ScriptUpgrades = new ScriptUpgrades();
}

/// <inheritdoc />
protected override void Dispose(bool disposing)
{
_solutionManager?.Dispose();
_solutionManager = null;
base.Dispose(disposing);
}

/// <summary>
/// Fired when the MDK features are enabled
/// Fired when the MDK features are enabled
/// </summary>
public event EventHandler Enabled;

/// <summary>
/// Fired when the MDK features are disabled
/// Fired when the MDK features are disabled
/// </summary>
public event EventHandler Disabled;

/// <summary>
/// Determines whether the package is currently busy deploying scripts.
/// Determines whether the package is currently busy deploying scripts.
/// </summary>
public bool IsDeploying { get; private set; }

/// <summary>
/// Determines whether the MDK features are currently enabled
/// Determines whether the MDK features are currently enabled
/// </summary>
public bool IsEnabled
{
Expand All @@ -96,28 +88,36 @@ private set
}

/// <summary>
/// Gets the MDK options
/// Gets the MDK options
/// </summary>
public MDKOptions Options => (MDKOptions)GetDialogPage(typeof(MDKOptions));

/// <summary>
/// The service provider
/// The service provider
/// </summary>
public IServiceProvider ServiceProvider => this;

/// <summary>
/// The <see cref="ScriptUpgrades"/> service
/// The <see cref="ScriptUpgrades" /> service
/// </summary>
public ScriptUpgrades ScriptUpgrades { get; }

/// <summary>
/// Gets the installation path for the current MDK package
/// Gets the installation path for the current MDK package
/// </summary>
public DirectoryInfo InstallPath { get; } = new FileInfo(new Uri(typeof(MDKPackage).Assembly.CodeBase).LocalPath).Directory;

/// <inheritdoc />
protected override void Dispose(bool disposing)
{
_solutionManager?.Dispose();
_solutionManager = null;
base.Dispose(disposing);
}

/// <summary>
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// Initialization of the package; this method is called right after the package is sited, so this is the place
/// where you can put all the initialization code that rely on services provided by VisualStudio.
/// </summary>
protected override void Initialize()
{
Expand Down Expand Up @@ -157,7 +157,7 @@ async void CheckForUpdatesAsync()
}

/// <summary>
/// Checks the GitHub sites for any updated releases.
/// Checks the GitHub sites for any updated releases.
/// </summary>
/// <returns>The newest release version on GitHub, or <c>null</c> if the current version is the latest</returns>
public async Task<Version> CheckForUpdatesAsync(bool includePrerelease)
Expand All @@ -179,6 +179,7 @@ public async Task<Version> CheckForUpdatesAsync(bool includePrerelease)
if (detectedVersion > Version)
return detectedVersion;
}

return null;
}
catch (Exception e)
Expand All @@ -201,17 +202,17 @@ void OnShellActivated()
_solutionManager.EndRecording();
}

private void OnSolutionClosed(object sender, EventArgs e)
void OnSolutionClosed(object sender, EventArgs e)
{
IsEnabled = false;
}

private void OnSolutionLoaded(object sender, EventArgs e)
void OnSolutionLoaded(object sender, EventArgs e)
{
OnSolutionLoaded(DTE.Solution);
}

private void OnProjectLoaded(object sender, ProjectLoadedEventArgs e)
void OnProjectLoaded(object sender, ProjectLoadedEventArgs e)
{
if (e.IsStandalone)
OnProjectLoaded(e.Project);
Expand Down Expand Up @@ -239,6 +240,7 @@ async void OnProjectLoaded(Project project)
IsEnabled = false;
return;
}

if (!result.HasScriptProjects)
return;
IsEnabled = true;
Expand Down Expand Up @@ -278,17 +280,14 @@ async void OnSolutionLoaded(Solution solution)
IsEnabled = false;
return;
}

if (!result.HasScriptProjects)
{
IsEnabled = false;
return;
}
IsEnabled = true;

if (VsVersion.Full < new Version(15, 7))
{

}
IsEnabled = true;

if (!result.IsValid)
QueryUpgrade(this, result);
Expand All @@ -301,10 +300,14 @@ async void OnSolutionLoaded(Solution solution)
}

/// <summary>
/// Deploys the all scripts in the solution or a single script project.
/// Deploys the all scripts in the solution or a single script project.
/// </summary>
/// <param name="project">The specific project to build</param>
/// <param name="nonBlocking"><c>true</c> if there should be no blocking dialogs shown during deployment. Instead, an <see cref="InvalidOperationException"/> will be thrown for the more grievous errors, while other stoppers merely return false.</param>
/// <param name="nonBlocking">
/// <c>true</c> if there should be no blocking dialogs shown during deployment. Instead, an
/// <see cref="InvalidOperationException" /> will be thrown for the more grievous errors, while other stoppers merely
/// return false.
/// </param>
/// <returns></returns>
public async Task<bool> DeployAsync(Project project = null, bool nonBlocking = false)
{
Expand Down Expand Up @@ -338,13 +341,9 @@ public async Task<bool> DeployAsync(Project project = null, bool nonBlocking = f
using (new StatusBarAnimation(ServiceProvider, Animation.Build))
{
if (project != null)
{
dte.Solution.SolutionBuild.BuildProject(dte.Solution.SolutionBuild.ActiveConfiguration.Name, project.FullName, true);
}
else
{
dte.Solution.SolutionBuild.Build(true);
}
failedProjects = dte.Solution.SolutionBuild.LastBuildInfo;
}

Expand Down Expand Up @@ -380,9 +379,7 @@ public async Task<bool> DeployAsync(Project project = null, bool nonBlocking = f
BlueprintManagerDialog.ShowDialog(model);
}
else
{
VsShellUtilities.ShowMessageBox(ServiceProvider, Text.MDKPackage_Deploy_DeploymentCompleteDescription, Text.MDKPackage_Deploy_DeploymentComplete, OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
}
}
else
Expand Down Expand Up @@ -416,13 +413,10 @@ public async Task<bool> DeployAsync(Project project = null, bool nonBlocking = f
}
}

string FormattedPath(string scriptOutputPath)
{
return Path.GetFullPath(scriptOutputPath).TrimEnd('\\').ToUpper();
}
string FormattedPath(string scriptOutputPath) => Path.GetFullPath(scriptOutputPath).TrimEnd('\\').ToUpper();

/// <summary>
/// Displays an error dialog
/// Displays an error dialog
/// </summary>
/// <param name="title"></param>
/// <param name="description"></param>
Expand Down
19 changes: 19 additions & 0 deletions Source/MDK/Services/MDKOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class MDKOptions : UIElementDialogPage, INotifyPropertyChanged
bool _promoteMDK = true;
bool _showBlueprintManagerOnDeploy = true;
bool _trimTypes;
string _lastSuppressedIdeVersionWarning;

/// <summary>
/// Creates an instance of <see cref="MDKOptions" />
Expand Down Expand Up @@ -202,6 +203,24 @@ public bool ShowBlueprintManagerOnDeploy
}
}

/// <summary>
/// The visual studio version warning that should be suppressed.
/// </summary>
[Category("MDK/SE")]
[DisplayName("The last suppressed ide version warning")]
[Description("Gets the last suppressed ide version warning, if the currently required warning is less than or equal to this, the warning will be shown.")]
public string LastSuppressedIdeVersionWarning
{
get => _lastSuppressedIdeVersionWarning;
set
{
if (_lastSuppressedIdeVersionWarning == value)
return;
_lastSuppressedIdeVersionWarning = value;
OnPropertyChanged();
}
}

/// <summary>
/// Whether script projects should default to generating minified scripts.
/// </summary>
Expand Down
Loading

0 comments on commit d5b1e8c

Please sign in to comment.