Skip to content

Feature/creaing extension version to visual studio 2022 #62

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 11 additions & 11 deletions src/NuGetReferenceSwitcher.Presentation/Models/ProjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
// <author>Rico Suter, [email protected]</author>
//-----------------------------------------------------------------------

using EnvDTE;
using EnvDTE80;
using MyToolkit.Collections;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Threading;
using System.Xml;
using EnvDTE;
using MyToolkit.Collections;
using VSLangProj;

namespace NuGetReferenceSwitcher.Presentation.Models
Expand All @@ -27,11 +28,11 @@ public class ProjectModel
/// <summary>Initializes a new instance of the <see cref="ProjectModel"/> class. </summary>
/// <param name="project">The native project object. </param>
/// <param name="application">The native application object. </param>
public ProjectModel(VSProject project, DTE application)
public ProjectModel(VSProject project, DTE2 application)
{
_vsProject = project;

Name = project.Project.Name;
Name = project.Project.Name;
SolutionFile = new FileInfo(application.Solution.FileName);
LoadReferences();
}
Expand All @@ -56,7 +57,7 @@ public string PreviousConfigurationPath
{
get { return GetConfigurationPath(".previous.nugetreferenceswitcher"); }
}

/// <summary>Gets the current project reference to NuGet reference transformations. </summary>
public List<FromProjectToNuGetTransformation> CurrentToNuGetTransformations
{
Expand All @@ -75,10 +76,10 @@ public string Path
get { return _vsProject.Project.FileName; }
}

/// <summary>Deletes the previous configuration file and renames the current
/// <summary>Deletes the previous configuration file and renames the current
/// configuration file to the path of the previous configuration file. </summary>
public void DeleteConfigurationFile()
{
{
if (File.Exists(CurrentConfigurationPath))
{
if (File.Exists(PreviousConfigurationPath))
Expand Down Expand Up @@ -118,7 +119,7 @@ public bool AddReference(string assemblyPath)

return true;
}
return false;
return false;
}

/// <summary>Removes the project from the solution. </summary>
Expand Down Expand Up @@ -146,10 +147,9 @@ private List<FromProjectToNuGetTransformation> LoadTransformationsFromFile(strin
.Select(l => l.Split('\t'))
.Where(l => l.Length == 3).ToArray();



foreach (var line in lines)
list.Add(new FromProjectToNuGetTransformation {
list.Add(new FromProjectToNuGetTransformation
{
FromProjectName = line[0],
FromProjectPath = PathUtilities.MakeAbsolute(line[1], configurationPath),
ToAssemblyPath = PathUtilities.MakeAbsolute(line[2], configurationPath)
Expand Down
91 changes: 48 additions & 43 deletions src/NuGetReferenceSwitcher.Presentation/Models/Reference4.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EnvDTE;
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using EnvDTE;
using VSLangProj;

namespace NuGetReferenceSwitcher.Presentation.Models
{
[Guid("F71B6036-80F1-4F08-BC59-B5D92865F629")]
public interface Reference4
{
// Reference
[DispId(1)] DTE DTE { get; }
[DispId(2)] References Collection { get; }
[DispId(3)] Project ContainingProject { get; }
[DispId(4)] void Remove();
[DispId(5)] string Name { get; }
[DispId(6)] prjReferenceType Type { get; }
[DispId(7)] string Identity { get; }
[DispId(8)] string Path { get; }
[DispId(9)] string Description { get; }
[DispId(10)] string Culture { get; }
[DispId(11)] int MajorVersion { get; }
[DispId(12)] int MinorVersion { get; }
[DispId(13)] int RevisionNumber { get; }
[DispId(14)] int BuildNumber { get; }
[DispId(15)] bool StrongName { get; }
[DispId(16)] Project SourceProject { get; }
[DispId(17)] bool CopyLocal { get; set; }
[DispId(18), TypeLibFunc(1088)] dynamic get_Extender(string ExtenderName);
[DispId(19)] dynamic ExtenderNames { get; }
[DispId(20)] string ExtenderCATID { get; }
[DispId(21)] string PublicKeyToken { get; }
[DispId(22)] string Version { get; }
// Reference2
[DispId(100)] string RuntimeVersion { get; }
// Reference3
[DispId(120)] bool SpecificVersion { get; set; } // The property we actually need
[DispId(121)] string SubType { get; set; }
[DispId(122)] bool Isolated { get; set; }
[DispId(123)] string Aliases { get; set; }
[DispId(124)] uint RefType { get; }
[DispId(125)] bool AutoReferenced { get; }
[DispId(126)] bool Resolved { get; }
// Reference4
[DispId(127)] bool EmbedInteropTypes { get; set; }
{
// Reference
[DispId(1)] DTE DTE { get; }

[DispId(2)] References Collection { get; }
[DispId(3)] Project ContainingProject { get; }

[DispId(4)] void Remove();

[DispId(5)] string Name { get; }
[DispId(6)] prjReferenceType Type { get; }
[DispId(7)] string Identity { get; }
[DispId(8)] string Path { get; }
[DispId(9)] string Description { get; }
[DispId(10)] string Culture { get; }
[DispId(11)] int MajorVersion { get; }
[DispId(12)] int MinorVersion { get; }
[DispId(13)] int RevisionNumber { get; }
[DispId(14)] int BuildNumber { get; }
[DispId(15)] bool StrongName { get; }
[DispId(16)] Project SourceProject { get; }
[DispId(17)] bool CopyLocal { get; set; }

[DispId(18), TypeLibFunc(1088)] dynamic get_Extender(string ExtenderName);

[DispId(19)] dynamic ExtenderNames { get; }
[DispId(20)] string ExtenderCATID { get; }
[DispId(21)] string PublicKeyToken { get; }
[DispId(22)] string Version { get; }

// Reference2
[DispId(100)] string RuntimeVersion { get; }

// Reference3
[DispId(120)] bool SpecificVersion { get; set; } // The property we actually need

[DispId(121)] string SubType { get; set; }
[DispId(122)] bool Isolated { get; set; }
[DispId(123)] string Aliases { get; set; }
[DispId(124)] uint RefType { get; }
[DispId(125)] bool AutoReferenced { get; }
[DispId(126)] bool Resolved { get; }

// Reference4
[DispId(127)] bool EmbedInteropTypes { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,17 @@
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="envdte100, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="EnvDTE90, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.OLE.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Shell.15.0, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0">
<EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0">
<EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.12.0" />
<Reference Include="MyToolkit">
<Reference Include="MyToolkit, Version=2.3.12.0, Culture=neutral, PublicKeyToken=3e349a1360994d26, processorArchitecture=MSIL">
<HintPath>..\packages\MyToolkit.2.3.12.0\lib\portable-net45+wp8+win8+wpa81\MyToolkit.dll</HintPath>
</Reference>
<Reference Include="MyToolkit.Extended">
<Reference Include="MyToolkit.Extended, Version=2.3.12.0, Culture=neutral, PublicKeyToken=3e349a1360994d26, processorArchitecture=MSIL">
<HintPath>..\packages\MyToolkit.Extended.2.3.12.0\lib\net45\MyToolkit.Extended.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
Expand All @@ -84,9 +61,6 @@
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="VSLangProj, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -126,11 +100,11 @@
<None Include="StrongNameKey.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
// <author>Rico Suter, [email protected]</author>
//-----------------------------------------------------------------------

using EnvDTE;
using EnvDTE80;
using MyToolkit.Build;
using MyToolkit.Collections;
using MyToolkit.Mvvm;
using MyToolkit.Utilities;
using NuGetReferenceSwitcher.Presentation.Models;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -14,13 +21,6 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using EnvDTE;
using EnvDTE80;
using MyToolkit.Build;
using MyToolkit.Collections;
using MyToolkit.Mvvm;
using MyToolkit.Utilities;
using NuGetReferenceSwitcher.Presentation.Models;
using VSLangProj;

namespace NuGetReferenceSwitcher.Presentation.ViewModels
Expand Down Expand Up @@ -51,7 +51,7 @@ public MainDialogModel()
public bool RemoveProjects { get; set; }

/// <summary>Gets or sets the Visual Studio application object. </summary>
public DTE Application { get; set; }
public DTE2 Application { get; set; }

/// <summary>Gets or sets the used UI dispatcher. </summary>
public Dispatcher Dispatcher { get; set; }
Expand All @@ -73,7 +73,7 @@ public string ExtensionVersion
get { return ExtensionAssembly != null ? ExtensionAssembly.GetVersionWithBuildTime() : "n/a"; }
}

/// <summary>Initializes the view model. Must only be called once per view model instance
/// <summary>Initializes the view model. Must only be called once per view model instance
/// (after the InitializeComponent method of a <see cref="!:UserControl"/>). </summary>
public override async void Initialize()
{
Expand Down Expand Up @@ -134,7 +134,7 @@ await RunTaskAsync(token => Task.Run(() =>
PathUtilities.MakeRelative(assemblyToProjectSwitch.ToProject.Path,
project.CurrentConfigurationPath) + "\t" +
PathUtilities.MakeRelative(fromAssemblyPath, project.CurrentConfigurationPath) +
"\n";
"\n";
}
else
{
Expand Down Expand Up @@ -186,7 +186,7 @@ await RunTaskAsync(token => Task.Run(() =>
{
MessageBox.Show("The project '" + transformation.ToAssemblyPath + "' could not be added. " +
"\nSkipped.", "Could not add project", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

Expand Down Expand Up @@ -273,4 +273,4 @@ private void RemoveProjectsFromSolution(List<ProjectModel> projectsToDelete)
}
}
}
}
}
24 changes: 11 additions & 13 deletions src/NuGetReferenceSwitcher.Presentation/Views/MainDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,37 @@
// <author>Rico Suter, [email protected]</author>
//-----------------------------------------------------------------------

using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using EnvDTE;

using EnvDTE80;
using Microsoft.VisualStudio.PlatformUI;

using MyToolkit.Collections;
using MyToolkit.Mvvm;
using NuGetReferenceSwitcher.Presentation.Models;
using NuGetReferenceSwitcher.Presentation.ViewModels;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using Button = System.Windows.Controls.Button;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using Window = System.Windows.Window;

namespace NuGetReferenceSwitcher.Presentation.Views
{
/// <summary>Interaction logic for MainDialog.xaml </summary>
public partial class MainDialog : DialogWindow
{
private OpenFileDialog _dlg;

/// <summary>Initializes a new instance of the <see cref="MainDialog"/> class. </summary>
/// <param name="application">The application object. </param>
/// <param name="extensionAssembly">The assembly of the extension. </param>
public MainDialog(DTE application, Assembly extensionAssembly)
public MainDialog(DTE2 application, Assembly extensionAssembly)
{
InitializeComponent();

Model.ExtensionAssembly = extensionAssembly;
Model.ExtensionAssembly = extensionAssembly;
Model.Application = application;
Model.Dispatcher = Dispatcher;

Expand Down Expand Up @@ -103,4 +101,4 @@ private void OnSelectProjectFile(object sender, RoutedEventArgs e)
fntpSwitch.ToProjectPath = _dlg.FileName;
}
}
}
}
4 changes: 2 additions & 2 deletions src/NuGetReferenceSwitcher.Presentation/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MyToolkit" version="2.3.12.0" targetFramework="net45" />
<package id="MyToolkit.Extended" version="2.3.12.0" targetFramework="net45" />
<package id="MyToolkit" version="2.3.12.0" targetFramework="net472" />
<package id="MyToolkit.Extended" version="2.3.12.0" targetFramework="net472" />
</packages>
Loading