1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6 * copy of the license can be found in the License.html file at the root of this distribution. If
7 * you cannot locate the Apache License, Version 2.0, please send an email to
8 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9 * by the terms of the Apache License, Version 2.0.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
17 using System.Dynamic.Utils;
20 namespace Microsoft.Scripting.Ast {
22 namespace System.Linq.Expressions {
25 /// Stores information needed to emit debugging symbol information for a
26 /// source file, in particular the file name and unique language identifier.
28 public class SymbolDocumentInfo {
29 private readonly string _fileName;
31 internal SymbolDocumentInfo(string fileName) {
32 ContractUtils.RequiresNotNull(fileName, "fileName");
37 /// The source file name.
39 public string FileName {
40 get { return _fileName; }
44 /// Returns the language's unique identifier, if any.
46 public virtual Guid Language {
47 get { return Guid.Empty; }
51 /// Returns the language vendor's unique identifier, if any.
53 public virtual Guid LanguageVendor {
54 get { return Guid.Empty; }
58 /// Returns the document type's unique identifier, if any.
59 /// Defaults to the guid for a text file.
61 public virtual Guid DocumentType {
62 get { return Compiler.SymbolGuids.DocumentType_Text; }
66 internal sealed class SymbolDocumentWithGuids : SymbolDocumentInfo {
67 private readonly Guid _language;
68 private readonly Guid _vendor;
69 private readonly Guid _documentType;
71 internal SymbolDocumentWithGuids(string fileName, ref Guid language)
74 _documentType = Compiler.SymbolGuids.DocumentType_Text;
77 internal SymbolDocumentWithGuids(string fileName, ref Guid language, ref Guid vendor)
81 _documentType = Compiler.SymbolGuids.DocumentType_Text;
84 internal SymbolDocumentWithGuids(string fileName, ref Guid language, ref Guid vendor, ref Guid documentType)
88 _documentType = documentType;
91 public override Guid Language {
92 get { return _language; }
95 public override Guid LanguageVendor {
96 get { return _vendor; }
99 public override Guid DocumentType {
100 get { return _documentType; }
104 public partial class Expression {
106 /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
108 /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
109 /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> property set to the specified value.</returns>
110 public static SymbolDocumentInfo SymbolDocument(string fileName) {
111 return new SymbolDocumentInfo(fileName);
115 /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
117 /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
118 /// <param name="language">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> equal to.</param>
119 /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" />
120 /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> properties set to the specified value.</returns>
121 public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language) {
122 return new SymbolDocumentWithGuids(fileName, ref language);
126 /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
128 /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
129 /// <param name="language">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> equal to.</param>
130 /// <param name="languageVendor">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" /> equal to.</param>
131 /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" />
132 /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" />
133 /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" /> properties set to the specified value.</returns>
134 public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor) {
135 return new SymbolDocumentWithGuids(fileName, ref language, ref languageVendor);
139 /// Creates an instance of <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" />.
141 /// <param name="fileName">A <see cref="T:System.String" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" /> equal to.</param>
142 /// <param name="language">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" /> equal to.</param>
143 /// <param name="languageVendor">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" /> equal to.</param>
144 /// <param name="documentType">A <see cref="T:System.Guid" /> to set the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.DocumentType" /> equal to.</param>
145 /// <returns>A <see cref="T:System.Linq.Expressions.SymbolDocumentInfo" /> that has the <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.FileName" />
146 /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.Language" />
147 /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.LanguageVendor" />
148 /// and <see cref="P:System.Linq.Expressions.SymbolDocumentInfo.DocumentType" /> properties set to the specified value.</returns>
149 public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor, Guid documentType) {
150 return new SymbolDocumentWithGuids(fileName, ref language, ref languageVendor, ref documentType);