diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj index 98b084247..ba040fdaa 100644 --- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj +++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj @@ -438,7 +438,6 @@ - @@ -513,9 +512,7 @@ - - diff --git a/ICSharpCode.Decompiler/TypeSystem/DefaultSolutionSnapshot.cs b/ICSharpCode.Decompiler/TypeSystem/DefaultSolutionSnapshot.cs deleted file mode 100644 index 9aaa9d998..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/DefaultSolutionSnapshot.cs +++ /dev/null @@ -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 -{ - /// - /// Default implementation of ISolutionSnapshot. - /// - public class DefaultSolutionSnapshot : ISolutionSnapshot - { - readonly Dictionary projectDictionary = new Dictionary(Platform.FileNameComparer); - ConcurrentDictionary dictionary = new ConcurrentDictionary(); - - /// - /// Creates a new DefaultSolutionSnapshot with the specified projects. - /// - public DefaultSolutionSnapshot(IEnumerable projects) - { - foreach (var project in projects) { - if (project.ProjectFileName != null) - projectDictionary.Add(project.ProjectFileName, project); - } - } - - /// - /// Creates a new DefaultSolutionSnapshot that does not support s. - /// - 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); - } - } - } - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/ICompilation.cs b/ICSharpCode.Decompiler/TypeSystem/ICompilation.cs index 2a8c3b3c7..abd79c807 100644 --- a/ICSharpCode.Decompiler/TypeSystem/ICompilation.cs +++ b/ICSharpCode.Decompiler/TypeSystem/ICompilation.cs @@ -75,8 +75,6 @@ namespace ICSharpCode.Decompiler.TypeSystem /// StringComparer NameComparer { get; } - ISolutionSnapshot SolutionSnapshot { get; } - CacheManager CacheManager { get; } } diff --git a/ICSharpCode.Decompiler/TypeSystem/IProjectContent.cs b/ICSharpCode.Decompiler/TypeSystem/IProjectContent.cs deleted file mode 100644 index 0806033e9..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/IProjectContent.cs +++ /dev/null @@ -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 -{ - /// - /// Represents an assembly consisting of source code (parsed files). - /// - public interface IProjectContent : IUnresolvedAssembly - { - /// - /// Gets the path to the project file (e.g. .csproj). - /// - string ProjectFileName { get; } - - /// - /// Gets a parsed file by its file name. - /// - IUnresolvedFile GetFile(string fileName); - - /// - /// Gets the list of all files in the project content. - /// - IEnumerable Files { get; } - - /// - /// Gets the referenced assemblies. - /// - IEnumerable AssemblyReferences { get; } - - /// - /// Gets the compiler settings object. - /// The concrete type of the settings object depends on the programming language used to implement this project. - /// - object CompilerSettings { get; } - - /// - /// Creates a new that allows resolving within this project. - /// - /// - /// This method does not support s. When dealing with a solution - /// containing multiple projects, consider using instead. - /// - ICompilation CreateCompilation(); - - /// - /// Creates a new that allows resolving within this project. - /// - /// The parent solution snapshot to use for the compilation. - /// - /// This method is intended to be called by ISolutionSnapshot implementations. Other code should - /// call instead. - /// This method always creates a new compilation, even if the solution snapshot already contains - /// one for this project. - /// - ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot); - - /// - /// Changes the assembly name of this project content. - /// - IProjectContent SetAssemblyName(string newAssemblyName); - - /// - /// Changes the project file name of this project content. - /// - IProjectContent SetProjectFileName(string newProjectFileName); - - /// - /// Changes the path to the assembly location (the output path where the project compiles to). - /// - IProjectContent SetLocation(string newLocation); - - /// - /// Add assembly references to this project content. - /// - IProjectContent AddAssemblyReferences(IEnumerable references); - - /// - /// Add assembly references to this project content. - /// - IProjectContent AddAssemblyReferences(params IAssemblyReference[] references); - - /// - /// Removes assembly references from this project content. - /// - IProjectContent RemoveAssemblyReferences(IEnumerable references); - - /// - /// Removes assembly references from this project content. - /// - IProjectContent RemoveAssemblyReferences(params IAssemblyReference[] references); - - /// - /// Adds the specified files to the project content. - /// If a file with the same name already exists, updated the existing file. - /// - /// - /// You can create an unresolved file by calling ToTypeSystem() on a syntax tree. - /// - IProjectContent AddOrUpdateFiles(IEnumerable newFiles); - - /// - /// Adds the specified files to the project content. - /// If a file with the same name already exists, this method updates the existing file. - /// - /// - /// You can create an unresolved file by calling ToTypeSystem() on a syntax tree. - /// - IProjectContent AddOrUpdateFiles(params IUnresolvedFile[] newFiles); - - /// - /// Removes the files with the specified names. - /// - IProjectContent RemoveFiles(IEnumerable fileNames); - - /// - /// Removes the files with the specified names. - /// - IProjectContent RemoveFiles(params string[] fileNames); - - /// - /// 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 . - /// - IProjectContent SetCompilerSettings(object compilerSettings); - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/ISolutionSnapshot.cs b/ICSharpCode.Decompiler/TypeSystem/ISolutionSnapshot.cs deleted file mode 100644 index 99c964682..000000000 --- a/ICSharpCode.Decompiler/TypeSystem/ISolutionSnapshot.cs +++ /dev/null @@ -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 -{ - /// - /// Represents a snapshot of the whole solution (multiple compilations). - /// - public interface ISolutionSnapshot - { - /// - /// Gets the project content with the specified file name. - /// Returns null if no such project exists in the solution. - /// - /// - /// This method is used by the class. - /// - IProjectContent GetProjectContent(string projectFileName); - - /// - /// Gets the compilation for the specified project. - /// The project must be a part of the solution (passed to the solution snapshot's constructor). - /// - ICompilation GetCompilation(IProjectContent project); - } -} diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs index 52688763f..2bbfb1fa6 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MinimalCorlib.cs @@ -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") diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs index 944ca2c5c..607258166 100644 --- a/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs +++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/SimpleCompilation.cs @@ -27,7 +27,6 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation /// 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 INamespace rootNamespace; public SimpleCompilation(IUnresolvedAssembly mainAssembly, params IAssemblyReference[] assemblyReferences) - : this(new DefaultSolutionSnapshot(), mainAssembly, (IEnumerable)assemblyReferences) + : this(mainAssembly, (IEnumerable)assemblyReferences) { } public SimpleCompilation(IUnresolvedAssembly mainAssembly, IEnumerable assemblyReferences) - : this(new DefaultSolutionSnapshot(), mainAssembly, assemblyReferences) { - } - - public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, params IAssemblyReference[] assemblyReferences) - : this(solutionSnapshot, mainAssembly, (IEnumerable)assemblyReferences) - { - } - - public SimpleCompilation(ISolutionSnapshot solutionSnapshot, IUnresolvedAssembly mainAssembly, IEnumerable 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 assemblies = new List(); @@ -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 + "]"; diff --git a/ICSharpCode.Decompiler/TypeSystem/TupleType.cs b/ICSharpCode.Decompiler/TypeSystem/TupleType.cs new file mode 100644 index 000000000..80f343b4f --- /dev/null +++ b/ICSharpCode.Decompiler/TypeSystem/TupleType.cs @@ -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 + { + /// + /// Gets the underlying System.ValueType type. + /// + public ParameterizedType UnderlyingType { get; } + + public ImmutableArray TupleElements { get; } + } +}