Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 38962c0

Browse files
authored
Merge pull request #914 from github/fixes/885-remove-assembly-resolver
Remove the need for assembly resolver
2 parents f13f5e3 + c88337e commit 38962c0

File tree

15 files changed

+478
-11
lines changed

15 files changed

+478
-11
lines changed

GitHubVS.sln

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.VisualStudio.UI", "s
104104
EndProject
105105
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.StartPage", "src\GitHub.StartPage\GitHub.StartPage.csproj", "{50E277B8-8580-487A-8F8E-5C3B9FBF0F77}"
106106
EndProject
107+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.UI.UnitTests", "test\GitHub.UI.UnitTests\GitHub.UI.UnitTests.csproj", "{110B206F-8554-4B51-BF86-94DAA32F5E26}"
108+
EndProject
107109
Global
108110
GlobalSection(SolutionConfigurationPlatforms) = preSolution
109111
Debug|Any CPU = Debug|Any CPU
@@ -157,8 +159,8 @@ Global
157159
{346384DD-2445-4A28-AF22-B45F3957BD89}.Release|Any CPU.Build.0 = Release|Any CPU
158160
{346384DD-2445-4A28-AF22-B45F3957BD89}.Release|x86.ActiveCfg = Release|Any CPU
159161
{346384DD-2445-4A28-AF22-B45F3957BD89}.Release|x86.Build.0 = Release|Any CPU
160-
{346384DD-2445-4A28-AF22-B45F3957BD89}.XamlDesign|Any CPU.ActiveCfg = Debug|Any CPU
161-
{346384DD-2445-4A28-AF22-B45F3957BD89}.XamlDesign|Any CPU.Build.0 = Debug|Any CPU
162+
{346384DD-2445-4A28-AF22-B45F3957BD89}.XamlDesign|Any CPU.ActiveCfg = XamlDesign|Any CPU
163+
{346384DD-2445-4A28-AF22-B45F3957BD89}.XamlDesign|Any CPU.Build.0 = XamlDesign|Any CPU
162164
{346384DD-2445-4A28-AF22-B45F3957BD89}.XamlDesign|x86.ActiveCfg = Debug|Any CPU
163165
{346384DD-2445-4A28-AF22-B45F3957BD89}.XamlDesign|x86.Build.0 = Debug|Any CPU
164166
{158B05E8-FDBC-4D71-B871-C96E28D5ADF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -522,8 +524,8 @@ Global
522524
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.Release|Any CPU.Build.0 = Release|Any CPU
523525
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.Release|x86.ActiveCfg = Release|Any CPU
524526
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.Release|x86.Build.0 = Release|Any CPU
525-
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.XamlDesign|Any CPU.ActiveCfg = Debug|Any CPU
526-
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.XamlDesign|Any CPU.Build.0 = Debug|Any CPU
527+
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.XamlDesign|Any CPU.ActiveCfg = XamlDesign|Any CPU
528+
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.XamlDesign|Any CPU.Build.0 = XamlDesign|Any CPU
527529
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.XamlDesign|x86.ActiveCfg = Release|Any CPU
528530
{D1DFBB0C-B570-4302-8F1E-2E3A19C41961}.XamlDesign|x86.Build.0 = Release|Any CPU
529531
{50E277B8-8580-487A-8F8E-5C3B9FBF0F77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -542,6 +544,22 @@ Global
542544
{50E277B8-8580-487A-8F8E-5C3B9FBF0F77}.XamlDesign|Any CPU.Build.0 = Release|Any CPU
543545
{50E277B8-8580-487A-8F8E-5C3B9FBF0F77}.XamlDesign|x86.ActiveCfg = Release|Any CPU
544546
{50E277B8-8580-487A-8F8E-5C3B9FBF0F77}.XamlDesign|x86.Build.0 = Release|Any CPU
547+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
548+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Debug|Any CPU.Build.0 = Debug|Any CPU
549+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Debug|x86.ActiveCfg = Debug|Any CPU
550+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Debug|x86.Build.0 = Debug|Any CPU
551+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Publish|Any CPU.ActiveCfg = Release|Any CPU
552+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Publish|Any CPU.Build.0 = Release|Any CPU
553+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Publish|x86.ActiveCfg = Release|Any CPU
554+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Publish|x86.Build.0 = Release|Any CPU
555+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Release|Any CPU.ActiveCfg = Release|Any CPU
556+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Release|Any CPU.Build.0 = Release|Any CPU
557+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Release|x86.ActiveCfg = Release|Any CPU
558+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.Release|x86.Build.0 = Release|Any CPU
559+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.XamlDesign|Any CPU.ActiveCfg = Release|Any CPU
560+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.XamlDesign|Any CPU.Build.0 = Release|Any CPU
561+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.XamlDesign|x86.ActiveCfg = Release|Any CPU
562+
{110B206F-8554-4B51-BF86-94DAA32F5E26}.XamlDesign|x86.Build.0 = Release|Any CPU
545563
EndGlobalSection
546564
GlobalSection(SolutionProperties) = preSolution
547565
HideSolutionNode = FALSE
@@ -565,5 +583,6 @@ Global
565583
{0EC8DBA1-D745-4EE5-993A-6026440EC3BF} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AF9}
566584
{DD99FD0F-82F6-4C30-930E-4A1D0DF01D65} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AB9}
567585
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
586+
{110B206F-8554-4B51-BF86-94DAA32F5E26} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
568587
EndGlobalSection
569588
EndGlobal

src/GitHub.UI/GitHub.UI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<Compile Include="Converters\CountToVisibilityConverter.cs" />
109109
<Compile Include="Converters\DefaultValueConverter.cs" />
110110
<Compile Include="Converters\StickieListItemConverter.cs" />
111+
<Compile Include="Helpers\LoadingResourceDictionary.cs" />
111112
<Compile Include="Helpers\ScrollViewerUtilities.cs" />
112113
<Compile Include="Resources.Designer.cs">
113114
<AutoGen>True</AutoGen>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.IO;
3+
using System.Windows;
4+
using System.Reflection;
5+
using System.Collections.Generic;
6+
using GitHub.VisualStudio;
7+
8+
namespace GitHub
9+
{
10+
public class LoadingResourceDictionary : ResourceDictionary
11+
{
12+
#if !XAML_DESIGNER // XAML Designer doesn't work if `Source` property has been replaced.
13+
static Dictionary<string, Assembly> assemblyDicts = new Dictionary<string, Assembly>();
14+
15+
public new Uri Source
16+
{
17+
get { return base.Source; }
18+
set
19+
{
20+
EnsureAssemblyLoaded(value);
21+
base.Source = value;
22+
}
23+
}
24+
25+
void EnsureAssemblyLoaded(Uri value)
26+
{
27+
try
28+
{
29+
var assemblyName = FindAssemblyNameFromPackUri(value);
30+
if (assemblyName == null)
31+
{
32+
VsOutputLogger.WriteLine($"Couldn't find assembly name in '{value}'.");
33+
return;
34+
}
35+
36+
var baseDir = Path.GetDirectoryName(GetType().Assembly.Location);
37+
var assemblyFile = Path.Combine(baseDir, assemblyName + ".dll");
38+
if (assemblyDicts.ContainsKey(assemblyFile))
39+
{
40+
return;
41+
}
42+
43+
if (!File.Exists(assemblyFile))
44+
{
45+
VsOutputLogger.WriteLine($"Couldn't find assembly at '{assemblyFile}'.");
46+
return;
47+
}
48+
49+
var assembly = Assembly.LoadFrom(assemblyFile);
50+
assemblyDicts.Add(assemblyFile, assembly);
51+
}
52+
catch(Exception e)
53+
{
54+
VsOutputLogger.WriteLine($"Error loading assembly for '{value}': {e}");
55+
}
56+
}
57+
58+
static string FindAssemblyNameFromPackUri(Uri packUri)
59+
{
60+
var path = packUri.LocalPath;
61+
if (!path.StartsWith("/"))
62+
{
63+
return null;
64+
}
65+
66+
var component = ";component/";
67+
int componentIndex = path.IndexOf(component, 1);
68+
if (componentIndex == -1)
69+
{
70+
return null;
71+
}
72+
73+
return path.Substring(1, componentIndex - 1);
74+
}
75+
#endif
76+
}
77+
}

src/GitHub.UI/Helpers/SharedDictionaryManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
namespace GitHub.UI.Helpers
66
{
7-
public class SharedDictionaryManager : ResourceDictionary
7+
public class SharedDictionaryManager : LoadingResourceDictionary
88
{
9+
#if !XAML_DESIGNER // XAML Designer doesn't work if `Source` property has been replaced.
910
static readonly Dictionary<Uri, ResourceDictionary> resourceDicts = new Dictionary<Uri, ResourceDictionary>();
1011

1112
Uri sourceUri;
@@ -25,5 +26,6 @@ public class SharedDictionaryManager : ResourceDictionary
2526
resourceDicts.Add(value, this);
2627
}
2728
}
29+
#endif
2830
}
2931
}

src/GitHub.VisualStudio.UI/Helpers/SharedDictionaryManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
using System.Windows;
44
using Microsoft.VisualStudio.PlatformUI;
55
using GitHub.VisualStudio.Helpers;
6-
using GitHub.Helpers;
76

87
namespace GitHub.VisualStudio.UI.Helpers
98
{
10-
public class SharedDictionaryManager : ResourceDictionary
9+
public class SharedDictionaryManager : LoadingResourceDictionary
1110
{
11+
#if !XAML_DESIGNER // XAML Designer doesn't work if `Source` property has been replaced.
1212
public SharedDictionaryManager()
1313
{
1414
currentTheme = Colors.DetectTheme();
@@ -17,7 +17,6 @@ public SharedDictionaryManager()
1717
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
1818
string currentTheme;
1919

20-
#if !XAML_DESIGNER
2120
static readonly Dictionary<Uri, ResourceDictionary> resourceDicts = new Dictionary<Uri, ResourceDictionary>();
2221
static string baseThemeUri = "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/";
2322

src/GitHub.VisualStudio/AssemblyResolverPackage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
namespace GitHub.VisualStudio
1212
{
1313
// This is the Git service GUID, which fires early and is used by GitHubService.
14-
[ProvideAutoLoad(Guids.GitSccProviderId)]
14+
//[ProvideAutoLoad(Guids.GitSccProviderId)]
1515

1616
// This fires before ShellInitialized and SolutionExists.
17-
[ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)]
17+
//[ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)]
1818

1919
[Guid(GuidList.guidAssemblyResolverPkgString)]
2020
public class AssemblyResolverPackage : Package

src/GitHub.VisualStudio/Helpers/SharedDictionaryManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
namespace GitHub.VisualStudio.Helpers
77
{
8-
public class SharedDictionaryManager : ResourceDictionary
8+
public class SharedDictionaryManager : LoadingResourceDictionary
99
{
10+
#if !XAML_DESIGNER // XAML Designer doesn't work if `Source` property has been replaced.
1011
static readonly Dictionary<Uri, ResourceDictionary> resourceDicts = new Dictionary<Uri, ResourceDictionary>();
1112

1213
Uri sourceUri;
@@ -26,5 +27,6 @@ public class SharedDictionaryManager : ResourceDictionary
2627
resourceDicts.Add(value, this);
2728
}
2829
}
30+
#endif
2931
}
3032
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
3+
using Microsoft.VisualStudio.Shell;
34

45
[assembly: AssemblyTitle("GitHub.VisualStudio")]
56
[assembly: AssemblyDescription("GitHub for Visual Studio VSPackage")]
67
[assembly: Guid("fad77eaa-3fe1-4c4b-88dc-3753b6263cd7")]
8+
9+
[assembly: ProvideCodeBase(AssemblyName = "GitHub.UI", CodeBase = @"$PackageFolder$\GitHub.UI.dll")]
10+
[assembly: ProvideCodeBase(AssemblyName = "GitHub.VisualStudio.UI", CodeBase = @"$PackageFolder$\GitHub.VisualStudio.UI.dll")]
11+
[assembly: ProvideCodeBase(AssemblyName = "GitHub.Exports", CodeBase = @"$PackageFolder$\GitHub.Exports.dll")]
12+
[assembly: ProvideCodeBase(AssemblyName = "GitHub.Extensions", CodeBase = @"$PackageFolder$\GitHub.Extensions.dll")]
13+
[assembly: ProvideCodeBase(AssemblyName = "Octokit", CodeBase = @"$PackageFolder$\Octokit.dll")]
14+
[assembly: ProvideCodeBase(AssemblyName = "LibGit2Sharp", CodeBase = @"$PackageFolder$\LibGit2Sharp.dll")]
15+
[assembly: ProvideCodeBase(AssemblyName = "Splat", CodeBase = @"$PackageFolder$\Splat.dll")]
16+
[assembly: ProvideCodeBase(AssemblyName = "Rothko", CodeBase = @"$PackageFolder$\Rothko.dll")]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
3+
namespace GitHub.UI.UnitTests
4+
{
5+
public class AppDomainContext : IDisposable
6+
{
7+
AppDomain domain;
8+
9+
public AppDomainContext(AppDomainSetup setup)
10+
{
11+
var friendlyName = GetType().FullName;
12+
domain = AppDomain.CreateDomain(friendlyName, null, setup);
13+
}
14+
15+
public T CreateInstance<T>()
16+
{
17+
return (T)domain.CreateInstanceFromAndUnwrap(typeof(T).Assembly.CodeBase, typeof(T).FullName);
18+
}
19+
20+
public void Dispose()
21+
{
22+
AppDomain.Unload(domain);
23+
}
24+
}
25+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{110B206F-8554-4B51-BF86-94DAA32F5E26}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>GitHub.UI.UnitTests</RootNamespace>
11+
<AssemblyName>GitHub.UI.UnitTests</AssemblyName>
12+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
35+
<HintPath>..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
36+
<Private>True</Private>
37+
</Reference>
38+
<Reference Include="PresentationCore" />
39+
<Reference Include="PresentationFramework" />
40+
<Reference Include="System" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Xml.Linq" />
43+
<Reference Include="System.Data.DataSetExtensions" />
44+
<Reference Include="Microsoft.CSharp" />
45+
<Reference Include="System.Data" />
46+
<Reference Include="System.Net.Http" />
47+
<Reference Include="System.Xml" />
48+
<Reference Include="WindowsBase" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Compile Include="AppDomainContext.cs" />
52+
<Compile Include="ResourceDictionaryUtilities.cs" />
53+
<Compile Include="SharedDictionaryManagerTests.cs" />
54+
<Compile Include="LoadingResourceDictionaryTests.cs" />
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<None Include="packages.config" />
59+
</ItemGroup>
60+
<ItemGroup>
61+
<ProjectReference Include="..\..\src\GitHub.UI\GitHub.UI.csproj">
62+
<Project>{346384dd-2445-4a28-af22-b45f3957bd89}</Project>
63+
<Name>GitHub.UI</Name>
64+
</ProjectReference>
65+
<ProjectReference Include="..\..\src\GitHub.VisualStudio.UI\GitHub.VisualStudio.UI.csproj">
66+
<Project>{d1dfbb0c-b570-4302-8f1e-2e3a19c41961}</Project>
67+
<Name>GitHub.VisualStudio.UI</Name>
68+
</ProjectReference>
69+
</ItemGroup>
70+
<ItemGroup />
71+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
72+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
73+
Other similar extension points exist, see Microsoft.Common.targets.
74+
<Target Name="BeforeBuild">
75+
</Target>
76+
<Target Name="AfterBuild">
77+
</Target>
78+
-->
79+
</Project>

0 commit comments

Comments
 (0)