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

Commit

Permalink
Fixes issue #6061 Add using writes the wrong reference down for a
Browse files Browse the repository at this point in the history
framework assembly
  • Loading branch information
mkrueger authored and Václav Vančura committed Oct 23, 2018
1 parent 5257d65 commit 7cd8c7e
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
@@ -0,0 +1,96 @@
//
// MonoDevelopFrameworkAssemblyPathResolver.cs
//
// Author:
// Mike Krüger <mikkrg@microsoft.com>
//
// Copyright (c) 2018 Microsoft Corporation. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.Composition;
using System.IO;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using MonoDevelop.Core;
using MonoDevelop.Core.Assemblies;

namespace MonoDevelop.Ide.TypeSystem
{
[ExportWorkspaceService (typeof (IFrameworkAssemblyPathResolver), ServiceLayer.Host), Shared]
class MonoDevelopFrameworkAssemblyPathResolver : IFrameworkAssemblyPathResolver
{
public string ResolveAssemblyPath (ProjectId projectId, string assemblyName, string fullyQualifiedName = null)
{
string assemblyFile = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyLocation (assemblyName, null);
if (assemblyFile != null) {
//if (string.IsNullOrEmpty(fullyQualifiedName) || CanResolveType(ResolveAssembly (projectId, assemblyName), fullyQualifiedName))
return assemblyFile;
}

return null;
}

//static bool CanResolveType (Assembly assembly, string fullyQualifiedTypeName)
//{
// if (fullyQualifiedTypeName == null) {
// // nothing to resolve.
// return true;
// }

// // We only get a type name without generic indicators. So try to few different
// // generic versions of the type name in case any of those hit. it's highly
// // unlikely we'd find something with more than 4 generic parameters, so only try
// // up that point.
// for (var i = 0; i < 5; i++) {
// var name = i == 0
// ? fullyQualifiedTypeName
// : fullyQualifiedTypeName + "`" + i;

// try {
// var type = assembly.GetType (name, throwOnError: false);
// if (type != null) {
// return true;
// }
// } catch (FileNotFoundException) {
// } catch (FileLoadException) {
// } catch (BadImageFormatException) {
// }
// }
// return false;
//}

//Assembly ResolveAssembly (ProjectId projectId, string assemblyLocation)
//{
// Runtime.AssertMainThread ();

// try {
// return Assembly.LoadFrom (assemblyLocation);
// } catch (Exception e) {
// // Something wrong with our TFM. We don't have enough information to
// // properly resolve this assembly name.
// LoggingService.LogError ("Error while resolving assembly assemblyName");
// return null;
// }
//}
}
}
1 change: 1 addition & 0 deletions main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
Expand Up @@ -4197,6 +4197,7 @@
<Compile Include="MonoDevelop.Ide.Updater\UpdateInfo.cs" />
<Compile Include="MonoDevelop.Ide.Desktop\ThermalMonitor.cs" />
<Compile Include="MonoDevelop.Ide\PlatformThermalStatusEventArgs.cs" />
<Compile Include="MonoDevelop.Ide.TypeSystem\MonoDevelopFrameworkAssemblyPathResolver.cs" />
</ItemGroup>
<ItemGroup>
<Data Include="options\DefaultEditingLayout.xml" />
Expand Down

0 comments on commit 7cd8c7e

Please sign in to comment.