mirror of https://github.com/icsharpcode/ILSpy.git
8 changed files with 19 additions and 297 deletions
@ -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); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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); |
|
||||||
} |
|
||||||
} |
|
@ -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); |
|
||||||
} |
|
||||||
} |
|
@ -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…
Reference in new issue