Browse Source

Remove unused IProjectContent+ISolutionSnapshot from type system.

pull/1143/head
Daniel Grunwald 7 years ago
parent
commit
7757d98672
  1. 3
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  2. 85
      ICSharpCode.Decompiler/TypeSystem/DefaultSolutionSnapshot.cs
  3. 2
      ICSharpCode.Decompiler/TypeSystem/ICompilation.cs
  4. 146
      ICSharpCode.Decompiler/TypeSystem/IProjectContent.cs
  5. 41
      ICSharpCode.Decompiler/TypeSystem/ISolutionSnapshot.cs
  6. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs
  7. 20
      ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs
  8. 17
      ICSharpCode.Decompiler/TypeSystem/TupleType.cs

3
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -438,7 +438,6 @@ @@ -438,7 +438,6 @@
<Compile Include="TypeSystem\CecilLoader.cs" />
<Compile Include="TypeSystem\ComHelper.cs" />
<Compile Include="TypeSystem\DecompilerTypeSystem.cs" />
<Compile Include="TypeSystem\DefaultSolutionSnapshot.cs" />
<Compile Include="TypeSystem\DomRegion.cs" />
<Compile Include="TypeSystem\Error.cs" />
<Compile Include="TypeSystem\FullTypeName.cs" />
@ -513,9 +512,7 @@ @@ -513,9 +512,7 @@
<Compile Include="TypeSystem\IntersectionType.cs" />
<Compile Include="TypeSystem\IParameter.cs" />
<Compile Include="TypeSystem\IParameterizedMember.cs" />
<Compile Include="TypeSystem\IProjectContent.cs" />
<Compile Include="TypeSystem\IProperty.cs" />
<Compile Include="TypeSystem\ISolutionSnapshot.cs" />
<Compile Include="TypeSystem\ISupportsInterning.cs" />
<Compile Include="TypeSystem\ISymbol.cs" />
<Compile Include="TypeSystem\IType.cs" />

85
ICSharpCode.Decompiler/TypeSystem/DefaultSolutionSnapshot.cs

@ -1,85 +0,0 @@ @@ -1,85 +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.Concurrent;
using System.Collections.Generic;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.TypeSystem
{
/// <summary>
/// Default implementation of ISolutionSnapshot.
/// </summary>
public class DefaultSolutionSnapshot : ISolutionSnapshot
{
readonly Dictionary<string, IProjectContent> projectDictionary = new Dictionary<string, IProjectContent>(Platform.FileNameComparer);
ConcurrentDictionary<IProjectContent, ICompilation> dictionary = new ConcurrentDictionary<IProjectContent, ICompilation>();
/// <summary>
/// Creates a new DefaultSolutionSnapshot with the specified projects.
/// </summary>
public DefaultSolutionSnapshot(IEnumerable<IProjectContent> projects)
{
foreach (var project in projects) {
if (project.ProjectFileName != null)
projectDictionary.Add(project.ProjectFileName, project);
}
}
/// <summary>
/// Creates a new DefaultSolutionSnapshot that does not support <see cref="ProjectReference"/>s.
/// </summary>
public DefaultSolutionSnapshot()
{
}
public IProjectContent GetProjectContent(string projectFileName)
{
IProjectContent pc;
lock (projectDictionary) {
if (projectDictionary.TryGetValue(projectFileName, out pc))
return pc;
else
return null;
}
}
public ICompilation GetCompilation(IProjectContent project)
{
if (project == null)
throw new ArgumentNullException("project");
return dictionary.GetOrAdd(project, p => p.CreateCompilation(this));
}
public void AddCompilation(IProjectContent project, ICompilation compilation)
{
if (project == null)
throw new ArgumentNullException("project");
if (compilation == null)
throw new ArgumentNullException("compilation");
if (!dictionary.TryAdd(project, compilation))
throw new InvalidOperationException();
if (project.ProjectFileName != null) {
lock (projectDictionary) {
projectDictionary.Add(project.ProjectFileName, project);
}
}
}
}
}

2
ICSharpCode.Decompiler/TypeSystem/ICompilation.cs

@ -75,8 +75,6 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -75,8 +75,6 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// </summary>
StringComparer NameComparer { get; }
ISolutionSnapshot SolutionSnapshot { get; }
CacheManager CacheManager { get; }
}

146
ICSharpCode.Decompiler/TypeSystem/IProjectContent.cs

@ -1,146 +0,0 @@ @@ -1,146 +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
{
/// <summary>
/// Represents an assembly consisting of source code (parsed files).
/// </summary>
public interface IProjectContent : IUnresolvedAssembly
{
/// <summary>
/// Gets the path to the project file (e.g. .csproj).
/// </summary>
string ProjectFileName { get; }
/// <summary>
/// Gets a parsed file by its file name.
/// </summary>
IUnresolvedFile GetFile(string fileName);
/// <summary>
/// Gets the list of all files in the project content.
/// </summary>
IEnumerable<IUnresolvedFile> Files { get; }
/// <summary>
/// Gets the referenced assemblies.
/// </summary>
IEnumerable<IAssemblyReference> AssemblyReferences { get; }
/// <summary>
/// Gets the compiler settings object.
/// The concrete type of the settings object depends on the programming language used to implement this project.
/// </summary>
object CompilerSettings { get; }
/// <summary>
/// Creates a new <see cref="ICompilation"/> that allows resolving within this project.
/// </summary>
/// <remarks>
/// This method does not support <see cref="ProjectReference"/>s. When dealing with a solution
/// containing multiple projects, consider using <see cref="ISolutionSnapshot.GetCompilation"/> instead.
/// </remarks>
ICompilation CreateCompilation();
/// <summary>
/// Creates a new <see cref="ICompilation"/> that allows resolving within this project.
/// </summary>
/// <param name="solutionSnapshot">The parent solution snapshot to use for the compilation.</param>
/// <remarks>
/// This method is intended to be called by ISolutionSnapshot implementations. Other code should
/// call <see cref="ISolutionSnapshot.GetCompilation"/> instead.
/// This method always creates a new compilation, even if the solution snapshot already contains
/// one for this project.
/// </remarks>
ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot);
/// <summary>
/// Changes the assembly name of this project content.
/// </summary>
IProjectContent SetAssemblyName(string newAssemblyName);
/// <summary>
/// Changes the project file name of this project content.
/// </summary>
IProjectContent SetProjectFileName(string newProjectFileName);
/// <summary>
/// Changes the path to the assembly location (the output path where the project compiles to).
/// </summary>
IProjectContent SetLocation(string newLocation);
/// <summary>
/// Add assembly references to this project content.
/// </summary>
IProjectContent AddAssemblyReferences(IEnumerable<IAssemblyReference> references);
/// <summary>
/// Add assembly references to this project content.
/// </summary>
IProjectContent AddAssemblyReferences(params IAssemblyReference[] references);
/// <summary>
/// Removes assembly references from this project content.
/// </summary>
IProjectContent RemoveAssemblyReferences(IEnumerable<IAssemblyReference> references);
/// <summary>
/// Removes assembly references from this project content.
/// </summary>
IProjectContent RemoveAssemblyReferences(params IAssemblyReference[] references);
/// <summary>
/// Adds the specified files to the project content.
/// If a file with the same name already exists, updated the existing file.
/// </summary>
/// <remarks>
/// You can create an unresolved file by calling <c>ToTypeSystem()</c> on a syntax tree.
/// </remarks>
IProjectContent AddOrUpdateFiles(IEnumerable<IUnresolvedFile> newFiles);
/// <summary>
/// Adds the specified files to the project content.
/// If a file with the same name already exists, this method updates the existing file.
/// </summary>
/// <remarks>
/// You can create an unresolved file by calling <c>ToTypeSystem()</c> on a syntax tree.
/// </remarks>
IProjectContent AddOrUpdateFiles(params IUnresolvedFile[] newFiles);
/// <summary>
/// Removes the files with the specified names.
/// </summary>
IProjectContent RemoveFiles(IEnumerable<string> fileNames);
/// <summary>
/// Removes the files with the specified names.
/// </summary>
IProjectContent RemoveFiles(params string[] fileNames);
/// <summary>
/// Sets the compiler settings object.
/// The concrete type of the settings object depends on the programming language used to implement this project.
/// Using the incorrect type of settings object results in an <see cref="ArgumentException"/>.
/// </summary>
IProjectContent SetCompilerSettings(object compilerSettings);
}
}

41
ICSharpCode.Decompiler/TypeSystem/ISolutionSnapshot.cs

@ -1,41 +0,0 @@ @@ -1,41 +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.
namespace ICSharpCode.Decompiler.TypeSystem
{
/// <summary>
/// Represents a snapshot of the whole solution (multiple compilations).
/// </summary>
public interface ISolutionSnapshot
{
/// <summary>
/// Gets the project content with the specified file name.
/// Returns null if no such project exists in the solution.
/// </summary>
/// <remarks>
/// This method is used by the <see cref="ProjectReference"/> class.
/// </remarks>
IProjectContent GetProjectContent(string projectFileName);
/// <summary>
/// Gets the compilation for the specified project.
/// The project must be a part of the solution (passed to the solution snapshot's constructor).
/// </summary>
ICompilation GetCompilation(IProjectContent project);
}
}

2
ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public ICompilation CreateCompilation()
{
return new SimpleCompilation(new DefaultSolutionSnapshot(), this);
return new SimpleCompilation(this);
}
private MinimalCorlib() : base("corlib")

20
ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs

@ -27,7 +27,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -27,7 +27,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// </summary>
public class SimpleCompilation : ICompilation
{
readonly ISolutionSnapshot solutionSnapshot;
readonly ITypeResolveContext context;
readonly CacheManager cacheManager = new CacheManager();
readonly KnownTypeCache knownTypeCache;
@ -37,29 +36,16 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -37,29 +36,16 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
INamespace rootNamespace;
public SimpleCompilation(IUnresolvedAssembly mainAssembly, params IAssemblyReference[] assemblyReferences)
: this(new DefaultSolutionSnapshot(), mainAssembly, (IEnumerable<IAssemblyReference>)assemblyReferences)
: this(mainAssembly, (IEnumerable<IAssemblyReference>)assemblyReferences)
{
}
public SimpleCompilation(IUnresolvedAssembly mainAssembly, IEnumerable<IAssemblyReference> assemblyReferences)
: this(new DefaultSolutionSnapshot(), mainAssembly, assemblyReferences)
{
}
public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, params IAssemblyReference[] assemblyReferences)
: this(solutionSnapshot, mainAssembly, (IEnumerable<IAssemblyReference>)assemblyReferences)
{
}
public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, IEnumerable<IAssemblyReference> assemblyReferences)
{
if (solutionSnapshot == null)
throw new ArgumentNullException("solutionSnapshot");
if (mainAssembly == null)
throw new ArgumentNullException("mainAssembly");
if (assemblyReferences == null)
throw new ArgumentNullException("assemblyReferences");
this.solutionSnapshot = solutionSnapshot;
this.context = new SimpleTypeResolveContext(this);
this.mainAssembly = mainAssembly.Resolve(context);
List<IAssembly> assemblies = new List<IAssembly>();
@ -156,10 +142,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -156,10 +142,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
get { return StringComparer.Ordinal; }
}
public ISolutionSnapshot SolutionSnapshot {
get { return solutionSnapshot; }
}
public override string ToString()
{
return "[SimpleCompilation " + mainAssembly.AssemblyName + "]";

17
ICSharpCode.Decompiler/TypeSystem/TupleType.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
namespace ICSharpCode.Decompiler.TypeSystem
{
public sealed class TupleType
{
/// <summary>
/// Gets the underlying <c>System.ValueType</c> type.
/// </summary>
public ParameterizedType UnderlyingType { get; }
public ImmutableArray<IField> TupleElements { get; }
}
}
Loading…
Cancel
Save