mirror of https://github.com/icsharpcode/ILSpy.git
34 changed files with 6 additions and 784 deletions
@ -1,80 +0,0 @@
@@ -1,80 +0,0 @@
|
||||
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// 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.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// References a member that is an explicit interface implementation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Resolving an ExplicitInterfaceImplementationMemberReference requires a context
|
||||
/// that provides enough information for resolving the declaring type reference
|
||||
/// and the interface member reference.
|
||||
/// Note that the interface member reference is resolved in '<c>context.WithCurrentTypeDefinition(declaringType.GetDefinition())</c>'
|
||||
/// - this is done to ensure that open generics in the interface member reference resolve to the type parameters of the
|
||||
/// declaring type.
|
||||
/// </remarks>
|
||||
[Serializable] |
||||
public sealed class ExplicitInterfaceImplementationMemberReference : IMemberReference |
||||
{ |
||||
ITypeReference typeReference; |
||||
IMemberReference interfaceMemberReference; |
||||
|
||||
public ExplicitInterfaceImplementationMemberReference(ITypeReference typeReference, IMemberReference interfaceMemberReference) |
||||
{ |
||||
if (typeReference == null) |
||||
throw new ArgumentNullException("typeReference"); |
||||
if (interfaceMemberReference == null) |
||||
throw new ArgumentNullException("interfaceMemberReference"); |
||||
this.typeReference = typeReference; |
||||
this.interfaceMemberReference = interfaceMemberReference; |
||||
} |
||||
|
||||
public ITypeReference DeclaringTypeReference { |
||||
get { return typeReference; } |
||||
} |
||||
|
||||
public IMember Resolve(ITypeResolveContext context) |
||||
{ |
||||
IType declaringType = typeReference.Resolve(context); |
||||
IMember interfaceMember = interfaceMemberReference.Resolve(context.WithCurrentTypeDefinition(declaringType.GetDefinition())); |
||||
if (interfaceMember == null) |
||||
return null; |
||||
IEnumerable<IMember> members; |
||||
if (interfaceMember.SymbolKind == SymbolKind.Accessor) { |
||||
members = declaringType.GetAccessors( |
||||
m => m.IsExplicitInterfaceImplementation, |
||||
GetMemberOptions.IgnoreInheritedMembers); |
||||
} else { |
||||
members = declaringType.GetMembers( |
||||
m => m.SymbolKind == interfaceMember.SymbolKind && m.IsExplicitInterfaceImplementation, |
||||
GetMemberOptions.IgnoreInheritedMembers); |
||||
} |
||||
return members.FirstOrDefault(m => m.ImplementedInterfaceMembers.Count == 1 && interfaceMember.Equals(m.ImplementedInterfaceMembers[0])); |
||||
} |
||||
|
||||
ISymbol ISymbolReference.Resolve(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context); |
||||
} |
||||
} |
||||
} |
@ -1,67 +0,0 @@
@@ -1,67 +0,0 @@
|
||||
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// 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.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
||||
{ |
||||
[Serializable] |
||||
public sealed class SpecializingMemberReference : IMemberReference |
||||
{ |
||||
IMemberReference memberDefinitionReference; |
||||
IList<ITypeReference> classTypeArgumentReferences; |
||||
IList<ITypeReference> methodTypeArgumentReferences; |
||||
|
||||
public SpecializingMemberReference(IMemberReference memberDefinitionReference, IList<ITypeReference> classTypeArgumentReferences = null, IList<ITypeReference> methodTypeArgumentReferences = null) |
||||
{ |
||||
if (memberDefinitionReference == null) |
||||
throw new ArgumentNullException("memberDefinitionReference"); |
||||
this.memberDefinitionReference = memberDefinitionReference; |
||||
this.classTypeArgumentReferences = classTypeArgumentReferences; |
||||
this.methodTypeArgumentReferences = methodTypeArgumentReferences; |
||||
} |
||||
|
||||
public IMember Resolve(ITypeResolveContext context) |
||||
{ |
||||
var memberDefinition = memberDefinitionReference.Resolve(context); |
||||
if (memberDefinition == null) |
||||
return null; |
||||
return memberDefinition.Specialize( |
||||
new TypeParameterSubstitution( |
||||
classTypeArgumentReferences != null ? classTypeArgumentReferences.Resolve(context) : null, |
||||
methodTypeArgumentReferences != null ? methodTypeArgumentReferences.Resolve(context) : null |
||||
) |
||||
); |
||||
} |
||||
|
||||
ISymbol ISymbolReference.Resolve(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context); |
||||
} |
||||
|
||||
public ITypeReference DeclaringTypeReference { |
||||
get { |
||||
if (classTypeArgumentReferences != null) |
||||
return new ParameterizedTypeReference(memberDefinitionReference.DeclaringTypeReference, classTypeArgumentReferences); |
||||
else |
||||
return memberDefinitionReference.DeclaringTypeReference; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,56 +0,0 @@
@@ -1,56 +0,0 @@
|
||||
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.Decompiler.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// References another project content in the same solution.
|
||||
/// Using the <see cref="ProjectReference"/> class requires that you
|
||||
/// </summary>
|
||||
[Serializable] |
||||
public class ProjectReference : IAssemblyReference |
||||
{ |
||||
readonly string projectFileName; |
||||
|
||||
/// <summary>
|
||||
/// Creates a new reference to the specified project (must be part of the same solution).
|
||||
/// </summary>
|
||||
/// <param name="projectFileName">Full path to the file name. Must be identical to <see cref="IProjectContent.ProjectFileName"/> of the target project; do not use a relative path.</param>
|
||||
public ProjectReference(string projectFileName) |
||||
{ |
||||
this.projectFileName = projectFileName; |
||||
} |
||||
|
||||
public IAssembly Resolve(ITypeResolveContext context) |
||||
{ |
||||
var solution = context.Compilation.SolutionSnapshot; |
||||
var pc = solution.GetProjectContent(projectFileName); |
||||
if (pc != null) |
||||
return pc.Resolve(context); |
||||
else |
||||
return null; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return string.Format("[ProjectReference {0}]", projectFileName); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue