Skip to content

Commit

Permalink
Merge pull request #63 from codingadventures/LINQBridgeVs2.0
Browse files Browse the repository at this point in the history
LINQBridgeVs version 2.0
  • Loading branch information
codingadventures authored Dec 21, 2018
2 parents df842d8 + 4a3c288 commit da88515
Show file tree
Hide file tree
Showing 77 changed files with 535 additions and 2,775 deletions.
File renamed without changes

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Windows;
using BridgeVs.Shared.Common;
using BridgeVs.VsPackage.Helper;
using BridgeVs.VsPackage.Helper.Command;
using BridgeVs.VsPackage.Helper.Configuration;
using EnvDTE;
using Project = EnvDTE.Project;

namespace BridgeVs.VsPackage
namespace BridgeVs.VisualStudio.AsyncExtension
{
public class BridgeVsExtension
{
Expand All @@ -57,6 +55,7 @@ private IEnumerable<Project> AllProjects
{
get
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
Projects projects = _application.Solution.Projects;
if (projects == null)
return Enumerable.Empty<Project>();
Expand All @@ -71,6 +70,7 @@ where IsSupported(project.UniqueName)

public void Execute(CommandAction action)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
List<Project> projects = AllProjects.ToList();

if (projects.Count == 0)
Expand All @@ -79,12 +79,12 @@ public void Execute(CommandAction action)
if (BridgeCommand.IsEveryProjectSupported(projects, _application.Version, _application.Edition))
{
BridgeCommand.ActivateBridgeVsOnSolution(action, projects, SolutionName, _application.Version,
_application.Edition);
_application.Edition, Path.GetDirectoryName(_application.Solution.FileName));
}
else
{
string message = $@"Solution {SolutionName} contains one or more un-supported projects. ASP.NET Core, .NET Core, .NET standard and UAP are not supported by LINQBridgeVs.";
MessageBox.Show(message);
System.Windows.MessageBox.Show(message);
}
}

Expand All @@ -97,14 +97,18 @@ public void UpdateCommand(MenuCommand cmd, CommandAction action)

private CommandStates GetStatus(CommandAction action)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

CommandStates result = CommandStates.Visible;

bool isBridgeVsConfigured = PackageConfigurator.IsBridgeVsConfigured(_application.Version);

if (!isBridgeVsConfigured)
return result; //just show it as visible

bool isSolutionEnabled = CommonRegistryConfigurations.IsSolutionEnabled(SolutionName, _application.Version);
string solutionDir = Path.GetDirectoryName(_application.Solution.FileName);
string directoryTarget = Path.Combine(solutionDir, "Directory.Build.targets");
bool isSolutionEnabled = File.Exists(directoryTarget);

if (isSolutionEnabled && action == CommandAction.Disable || !isSolutionEnabled && action == CommandAction.Enable)
result |= CommandStates.Enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#endregion

using BridgeVs.Shared.Common;
using BridgeVs.Shared.FileSystem;
using BridgeVs.VsPackage.Helper.Configuration;
using EnvDTE;
using System;
using System.Collections.Generic;
Expand All @@ -36,6 +38,7 @@ namespace BridgeVs.VsPackage.Helper.Command
{
public static class BridgeCommand
{
private const string DirectoryBuildTargets = "Directory.Build.targets";
private static readonly List<string> UnsupportedFrameworks = new List<string>(20)
{
"netstandard",
Expand All @@ -51,8 +54,11 @@ public static class BridgeCommand

public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project> projects, string solutionName,
string vsVersion,
string vsEdition)
string vsEdition,
string solutionFolder)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

List<BridgeProjectInfo> executeParams = new List<BridgeProjectInfo>();

//enable each individual project by mapping the assembly name and location to a registry entry
Expand All @@ -70,6 +76,7 @@ public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project
if (project.Object is VSProject vsProject && vsProject.References != null)
{
references = from Reference reference in vsProject.References
where reference.Path != null
where reference.SourceProject == null //it means it's an assembly reference
where !reference.Path.Contains(".NETFramework") && !reference.Path.Contains("Microsoft") //no .net framework assembly
select reference.Path;
Expand All @@ -83,9 +90,14 @@ public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project
{
case CommandAction.Enable:
CommonRegistryConfigurations.BridgeSolution(solutionName, vsVersion, executeParams);
//copy directory build target to the solution folder
string target = PackageConfigurator.GetInstallationFolder(vsVersion);
File.Copy(Path.Combine(target, "Targets", DirectoryBuildTargets), Path.Combine(solutionFolder, DirectoryBuildTargets), true);
break;
case CommandAction.Disable:
CommonRegistryConfigurations.UnBridgeSolution(solutionName, vsVersion);
//delete directory build target
File.Delete(Path.Combine(solutionFolder, DirectoryBuildTargets));
break;
}

Expand All @@ -99,6 +111,8 @@ public static void ActivateBridgeVsOnSolution(CommandAction action, List<Project
public static bool IsEveryProjectSupported(List<Project> projects, string applicationVersion,
string applicationEdition)
{
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

foreach (Project project in projects)
{
string targetFramework = project.Properties.Item("TargetFrameworkMoniker").Value.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public static string GetMsBuildVersion(string vsVersion)
return "v14.0";
case "15.0":
return "v15.0";
case "16.0":
return "v16.0";
default :
throw new ArgumentException("Visual Studio Version not Supported", nameof(vsVersion));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System.Security.Principal;
using System.Windows.Forms;
using BridgeVs.Shared.Common;
using BridgeVs.VisualStudio.AsyncExtension.Configuration;
using Microsoft.Win32;
using OpenFileDialog = System.Windows.Forms.OpenFileDialog;

Expand Down Expand Up @@ -121,20 +122,6 @@ private static bool IsLINQPadInstalled(string vsVersion)
return false;
}

private static void DeployMsBuildTargets(string vsVersion, string vsEdition)
{
string msBuildDir = CreateMsBuildTargetDirectory(vsVersion, vsEdition);
//Copy the CustomAfter and CustomBefore to the default MSBuild v4.0 location
File.Copy(CommonFolderPaths.CustomAfterTargetFileNamePath, Path.Combine(msBuildDir, CommonFolderPaths.CustomAfterTargetFileName), true);

string customBeforeTarget = Path.Combine(msBuildDir, CommonFolderPaths.CustomBeforeTargetFileName);
if (File.Exists(customBeforeTarget)) //old before target, now obsolete
{
File.Delete(customBeforeTarget);
}

}

private static void SetInstallationFolder(string vsVersion)
{
//Set in the registry the installer location if it is has changed
Expand All @@ -151,7 +138,7 @@ private static void SetInstallationFolder(string vsVersion)
}
}

private static string GetInstallationFolder(string vsVersion)
public static string GetInstallationFolder(string vsVersion)
{
//Set in the registry the installer location if it is has changed
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(CommonRegistryConfigurations.GetRegistryKey(Resources.ProductRegistryKey, vsVersion)))
Expand Down Expand Up @@ -235,8 +222,6 @@ public static bool Install(string vsVersion, string vsEdition)
//Always check if installation folder has changed
SetInstallationFolder(vsVersion);

DeployMsBuildTargets(vsVersion, vsEdition);

GenerateGuidForCurrentInstallation(vsVersion);

DeleteExistingVisualizers(vsVersion);
Expand Down Expand Up @@ -314,6 +299,10 @@ private static string DebuggerVisualizerTargetFolder(string vsVersion)
case "15.0":
debuggerVisualizerTargetFolder = CommonFolderPaths.Vs2017DebuggerVisualizerDestinationFolder;
break;
case "16.0":
debuggerVisualizerTargetFolder = CommonFolderPaths.Vs2019DebuggerVisualizerDestinationFolder;
break;

}

return debuggerVisualizerTargetFolder;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

using System;

namespace BridgeVs.VsPackage
namespace BridgeVs.VisualStudio.AsyncExtension
{
public static class GuidList
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion

namespace BridgeVs.VsPackage
namespace BridgeVs.VisualStudio.AsyncExtension
{
internal static class PkgCmdIdList
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#region License
// Copyright (c) 2013 Coding Adventures
// Copyright (c) 2013 - 2018 Coding Adventures
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
Expand All @@ -23,43 +23,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
#endregion

using System;

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BridgeVs.VsPackage.Helper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Coding Advengures")]
[assembly: AssemblyProduct("BridgeVs.VsPackage.Helper")]
[assembly: AssemblyCopyright("Copyright © Coding Adventures 2013 - 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("916dc547-062f-4fb4-90f7-a4bf1cf4d815")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.7.*")]
[assembly: AssemblyTitle("BridgeVs.AsyncVsPackage")]
[assembly: AssemblyProduct("BridgeVs.VisualStudio.AsyncExtension")]
[assembly: Guid("2016fd5d-79e9-4823-b927-cb796f7b411a")]
#if TEST
[assembly: InternalsVisibleTo("BridgeVs.UnitTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f575ceee4c0b7992660f21a6c2a09c93eac56d9dad2f20caa2d48bf5d904c9b2af5800ba01cae7b37299bff9486a8b97047959c3fbe16de730cf3397f4bafaefc745dba1ce34cedf27698f2dc96159eaa27eef4093f6c35236f30239a4841b864ea734ed3582478cc4214d76497ceb974ac920f35043de0913a149d1107bd3a1")]
#endif
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
using BridgeVs.Shared.Options;

namespace BridgeVs.VsPackage.Helper.Settings
{
/// <inheritdoc />
[ClassInterface(ClassInterfaceType.None)]
[CLSCompliant(false), ComVisible(true)]
{
public sealed class PackageSettings : DialogPage
{
private const string ErrorMessage = "Please insert a valid path to LINQPad";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- This is the file that defines the actual layout and type of the commands.
Expand Down Expand Up @@ -54,8 +54,8 @@
</Strings>
</Menu>
</Menus>

<Groups>

<Group guid="guidTopLevelMenuCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidTopLevelMenuCmdSet" id="LINQBridge" />
</Group>
Expand Down Expand Up @@ -112,38 +112,10 @@
</Strings>
</Button>


<!--<Button guid="guidLINQBridgeVsPackageCmdSet" id="cmdidToolWindow1Command" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1" />
<Icon guid="guidImages1" id="bmpPic1" />
<Strings>
<ButtonText>ToolWindow1</ButtonText>
</Strings>
</Button>-->
</Buttons>

<!--The bitmaps section is used to define the bitmaps that are used for the commands.-->
<Bitmaps>
<!-- The bitmap id is defined in a way that is a little bit different from the others:
the declaration starts with a guid for the bitmap strip, then there is the resource id of the
bitmap strip containing the bitmaps and then there are the numeric ids of the elements used
inside a button definition. An important aspect of this declaration is that the element id
must be the actual index (1-based) of the bitmap inside the bitmap strip.
<Bitmap guid="guidImages" href="Resources\Images.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows" />-->
</Bitmaps>

</Commands>

<!--<CommandPlacements>
--><!--Here we place two commands inside the empty menu group we created in the Groups section.--><!--
<CommandPlacement guid="guidTopLevelMenuCmdSet" id="CmdIdStarted" priority="0x100">
<Parent guid="guidTopLevelMenuCmdSet" id="HelpGroup"/>
</CommandPlacement>
<CommandPlacement guid="guidTopLevelMenuCmdSet" id="CmdIdFeedback" priority="0x200">
<Parent guid="guidTopLevelMenuCmdSet" id="HelpGroup"/>
</CommandPlacement>
</CommandPlacements>-->

<VisibilityConstraints>
<VisibilityItem guid="guidTopLevelMenuCmdSet" id="CmdIdEnableBridge" context="UICONTEXT_SolutionExistsAndNotBuildingAndNotDebugging" />
<VisibilityItem guid="guidTopLevelMenuCmdSet" id="CmdIdDisableBridge" context="UICONTEXT_SolutionExistsAndNotBuildingAndNotDebugging" />
Expand Down
Loading

0 comments on commit da88515

Please sign in to comment.