/NRefactory/ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs

http://github.com/icsharpcode/ILSpy · C# · 159 lines · 32 code · 22 blank · 105 comment · 0 complexity · d80581344d183aabfab4a43faa97bc93 MD5 · raw file

  1. // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy of this
  4. // software and associated documentation files (the "Software"), to deal in the Software
  5. // without restriction, including without limitation the rights to use, copy, modify, merge,
  6. // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
  7. // to whom the Software is furnished to do so, subject to the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be included in all copies or
  10. // substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  13. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  14. // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  15. // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17. // DEALINGS IN THE SOFTWARE.
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Diagnostics.Contracts;
  21. namespace ICSharpCode.NRefactory.TypeSystem
  22. {
  23. /// <summary>
  24. /// Represents an assembly consisting of source code (parsed files).
  25. /// </summary>
  26. public interface IProjectContent : IUnresolvedAssembly
  27. {
  28. /// <summary>
  29. /// Gets the path to the project file (e.g. .csproj).
  30. /// </summary>
  31. string ProjectFileName { get; }
  32. /// <summary>
  33. /// Gets a parsed file by its file name.
  34. /// </summary>
  35. IUnresolvedFile GetFile(string fileName);
  36. /// <summary>
  37. /// Gets the list of all files in the project content.
  38. /// </summary>
  39. IEnumerable<IUnresolvedFile> Files { get; }
  40. /// <summary>
  41. /// Gets the referenced assemblies.
  42. /// </summary>
  43. IEnumerable<IAssemblyReference> AssemblyReferences { get; }
  44. /// <summary>
  45. /// Gets the compiler settings object.
  46. /// The concrete type of the settings object depends on the programming language used to implement this project.
  47. /// </summary>
  48. object CompilerSettings { get; }
  49. /// <summary>
  50. /// Creates a new <see cref="ICompilation"/> that allows resolving within this project.
  51. /// </summary>
  52. /// <remarks>
  53. /// This method does not support <see cref="ProjectReference"/>s. When dealing with a solution
  54. /// containing multiple projects, consider using <see cref="ISolutionSnapshot.GetCompilation"/> instead.
  55. /// </remarks>
  56. ICompilation CreateCompilation();
  57. /// <summary>
  58. /// Creates a new <see cref="ICompilation"/> that allows resolving within this project.
  59. /// </summary>
  60. /// <param name="solutionSnapshot">The parent solution snapshot to use for the compilation.</param>
  61. /// <remarks>
  62. /// This method is intended to be called by ISolutionSnapshot implementations. Other code should
  63. /// call <see cref="ISolutionSnapshot.GetCompilation"/> instead.
  64. /// This method always creates a new compilation, even if the solution snapshot already contains
  65. /// one for this project.
  66. /// </remarks>
  67. ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot);
  68. /// <summary>
  69. /// Changes the assembly name of this project content.
  70. /// </summary>
  71. IProjectContent SetAssemblyName(string newAssemblyName);
  72. /// <summary>
  73. /// Changes the project file name of this project content.
  74. /// </summary>
  75. IProjectContent SetProjectFileName(string newProjectFileName);
  76. /// <summary>
  77. /// Changes the path to the assembly location (the output path where the project compiles to).
  78. /// </summary>
  79. IProjectContent SetLocation(string newLocation);
  80. /// <summary>
  81. /// Add assembly references to this project content.
  82. /// </summary>
  83. IProjectContent AddAssemblyReferences(IEnumerable<IAssemblyReference> references);
  84. /// <summary>
  85. /// Add assembly references to this project content.
  86. /// </summary>
  87. IProjectContent AddAssemblyReferences(params IAssemblyReference[] references);
  88. /// <summary>
  89. /// Removes assembly references from this project content.
  90. /// </summary>
  91. IProjectContent RemoveAssemblyReferences(IEnumerable<IAssemblyReference> references);
  92. /// <summary>
  93. /// Removes assembly references from this project content.
  94. /// </summary>
  95. IProjectContent RemoveAssemblyReferences(params IAssemblyReference[] references);
  96. /// <summary>
  97. /// Adds the specified files to the project content.
  98. /// If a file with the same name already exists, updated the existing file.
  99. /// </summary>
  100. /// <remarks>
  101. /// You can create an unresolved file by calling <c>ToTypeSystem()</c> on a syntax tree.
  102. /// </remarks>
  103. IProjectContent AddOrUpdateFiles(IEnumerable<IUnresolvedFile> newFiles);
  104. /// <summary>
  105. /// Adds the specified files to the project content.
  106. /// If a file with the same name already exists, this method updates the existing file.
  107. /// </summary>
  108. /// <remarks>
  109. /// You can create an unresolved file by calling <c>ToTypeSystem()</c> on a syntax tree.
  110. /// </remarks>
  111. IProjectContent AddOrUpdateFiles(params IUnresolvedFile[] newFiles);
  112. /// <summary>
  113. /// Removes the files with the specified names.
  114. /// </summary>
  115. IProjectContent RemoveFiles(IEnumerable<string> fileNames);
  116. /// <summary>
  117. /// Removes the files with the specified names.
  118. /// </summary>
  119. IProjectContent RemoveFiles(params string[] fileNames);
  120. /// <summary>
  121. /// Removes types and attributes from oldFile from the project, and adds those from newFile.
  122. /// </summary>
  123. [Obsolete("Use RemoveFiles()/AddOrUpdateFiles() instead")]
  124. IProjectContent UpdateProjectContent(IUnresolvedFile oldFile, IUnresolvedFile newFile);
  125. /// <summary>
  126. /// Removes types and attributes from oldFiles from the project, and adds those from newFiles.
  127. /// </summary>
  128. [Obsolete("Use RemoveFiles()/AddOrUpdateFiles() instead")]
  129. IProjectContent UpdateProjectContent(IEnumerable<IUnresolvedFile> oldFiles, IEnumerable<IUnresolvedFile> newFiles);
  130. /// <summary>
  131. /// Sets the compiler settings object.
  132. /// The concrete type of the settings object depends on the programming language used to implement this project.
  133. /// Using the incorrect type of settings object results in an <see cref="ArgumentException"/>.
  134. /// </summary>
  135. IProjectContent SetCompilerSettings(object compilerSettings);
  136. }
  137. }