提交 ec9f9753 编写于 作者: T Tomáš Matoušek

Merge pull request #2685 from tmat/PublicFields

Replace public fields with properties in Microsoft.CodeAnalysis
......@@ -28,42 +28,42 @@ public struct SubsystemVersion : IEquatable<SubsystemVersion>
/// <summary>
/// Major subsystem version
/// </summary>
public readonly int Major;
public int Major { get; }
/// <summary>
/// Minor subsystem version
/// </summary>
public readonly int Minor;
public int Minor { get; }
/// <summary>
/// Subsystem version not specified
/// </summary>
public static readonly SubsystemVersion None = new SubsystemVersion();
public static SubsystemVersion None => new SubsystemVersion();
/// <summary>
/// Subsystem version: Windows 2000
/// </summary>
public static readonly SubsystemVersion Windows2000 = new SubsystemVersion(5, 0);
public static SubsystemVersion Windows2000 => new SubsystemVersion(5, 0);
/// <summary>
/// Subsystem version: Windows XP
/// </summary>
public static readonly SubsystemVersion WindowsXP = new SubsystemVersion(5, 1);
public static SubsystemVersion WindowsXP => new SubsystemVersion(5, 1);
/// <summary>
/// Subsystem version: Windows Vista
/// </summary>
public static readonly SubsystemVersion WindowsVista = new SubsystemVersion(6, 0);
public static SubsystemVersion WindowsVista => new SubsystemVersion(6, 0);
/// <summary>
/// Subsystem version: Windows 7
/// </summary>
public static readonly SubsystemVersion Windows7 = new SubsystemVersion(6, 1);
public static SubsystemVersion Windows7 => new SubsystemVersion(6, 1);
/// <summary>
/// Subsystem version: Windows 8
/// </summary>
public static readonly SubsystemVersion Windows8 = new SubsystemVersion(6, 2);
public static SubsystemVersion Windows8 => new SubsystemVersion(6, 2);
private SubsystemVersion(int major, int minor)
{
......
......@@ -34,7 +34,7 @@ public sealed partial class DesktopAssemblyIdentityComparer : AssemblyIdentityCo
// Non-FX identities:
// if (isUnified1 && version1 > version2 || isUnified2 && version1 < version2) return EquivalentUnified.
public static new readonly DesktopAssemblyIdentityComparer Default = new DesktopAssemblyIdentityComparer(default(AssemblyPortabilityPolicy));
public static new DesktopAssemblyIdentityComparer Default { get; } = new DesktopAssemblyIdentityComparer(default(AssemblyPortabilityPolicy));
internal readonly AssemblyPortabilityPolicy policy;
......
......@@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis
/// </summary>
public abstract partial class DocumentationProvider
{
public static readonly DocumentationProvider Default = new NullDocumentationProvider();
public static DocumentationProvider Default { get; } = new NullDocumentationProvider();
protected DocumentationProvider()
{
......
......@@ -133,7 +133,7 @@ public static EmitBaseline CreateInitialBaseline(ModuleMetadata module, Func<Met
/// <summary>
/// The original metadata of the module.
/// </summary>
public readonly ModuleMetadata OriginalMetadata;
public ModuleMetadata OriginalMetadata { get; }
internal readonly Compilation Compilation;
internal readonly CommonPEModuleBuilder PEModuleBuilder;
......
......@@ -14,19 +14,19 @@ public struct SemanticEdit : IEquatable<SemanticEdit>
/// <summary>
/// The type of edit.
/// </summary>
public readonly SemanticEditKind Kind;
public SemanticEditKind Kind { get; }
/// <summary>
/// The symbol from the earlier compilation,
/// or null if the edit represents an addition.
/// </summary>
public readonly ISymbol OldSymbol;
public ISymbol OldSymbol { get; }
/// <summary>
/// The symbol from the later compilation,
/// or null if the edit represents a deletion.
/// </summary>
public readonly ISymbol NewSymbol;
public ISymbol NewSymbol { get; }
/// <summary>
/// A map from syntax node in the later compilation to syntax node in the previous compilation,
......@@ -37,13 +37,13 @@ public struct SemanticEdit : IEquatable<SemanticEdit>
/// The map does not need to map all syntax nodes in the active method, only those syntax nodes
/// that declare a local or generate a long lived local.
/// </remarks>
public readonly Func<SyntaxNode, SyntaxNode> SyntaxMap;
public Func<SyntaxNode, SyntaxNode> SyntaxMap { get; }
/// <summary>
/// True if the edit is an update of the active method and local values
/// should be preserved; false otherwise.
/// </summary>
public readonly bool PreserveLocalVariables;
public bool PreserveLocalVariables { get; }
/// <summary>
/// Initializes an instance of <see cref="SemanticEdit"/>.
......
......@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis
/// </summary>
public class AssemblyIdentityComparer
{
public static readonly AssemblyIdentityComparer Default = new AssemblyIdentityComparer();
public static AssemblyIdentityComparer Default { get; } = new AssemblyIdentityComparer();
public static StringComparer SimpleNameComparer
{
......
......@@ -21,12 +21,12 @@ public struct MetadataReferenceProperties : IEquatable<MetadataReferenceProperti
/// <summary>
/// Default properties for a module reference.
/// </summary>
public static readonly MetadataReferenceProperties Module = new MetadataReferenceProperties(MetadataImageKind.Module);
public static MetadataReferenceProperties Module => new MetadataReferenceProperties(MetadataImageKind.Module);
/// <summary>
/// Default properties for an assembly reference.
/// </summary>
public static readonly MetadataReferenceProperties Assembly = new MetadataReferenceProperties(MetadataImageKind.Assembly);
public static MetadataReferenceProperties Assembly => new MetadataReferenceProperties(MetadataImageKind.Assembly);
/// <summary>
/// Initializes reference properties.
......@@ -104,10 +104,7 @@ public MetadataReferenceProperties WithEmbedInteropTypes(bool embedInteropTypes)
/// <summary>
/// The image kind (assembly or module) the reference refers to.
/// </summary>
public MetadataImageKind Kind
{
get { return _kind; }
}
public MetadataImageKind Kind => _kind;
/// <summary>
/// Alias that represents a global declaration space.
......@@ -115,7 +112,7 @@ public MetadataImageKind Kind
/// <remarks>
/// Namespaces in references whose <see cref="Aliases"/> contain <see cref="GlobalAlias"/> are available in global declaration space.
/// </remarks>
public static readonly string GlobalAlias = "global";
public static string GlobalAlias => "global";
/// <summary>
/// Aliases for the metadata reference. Empty if the reference has no aliases.
......@@ -135,10 +132,7 @@ public ImmutableArray<string> Aliases
/// <summary>
/// True if interop types defined in the referenced metadata should be embedded into the compilation referencing the metadata.
/// </summary>
public bool EmbedInteropTypes
{
get { return _embedInteropTypes; }
}
public bool EmbedInteropTypes => _embedInteropTypes;
public override bool Equals(object obj)
{
......
......@@ -10,7 +10,7 @@ public class SymbolDisplayFormat
/// <summary>
/// Formats a symbol description as in a C# compiler error message.
/// </summary>
public static readonly SymbolDisplayFormat CSharpErrorMessageFormat =
public static SymbolDisplayFormat CSharpErrorMessageFormat { get; } =
new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.OmittedAsContaining,
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
......@@ -34,7 +34,7 @@ public class SymbolDisplayFormat
/// <summary>
/// Formats a symbol description as in a C# compiler short error message.
/// </summary>
public static readonly SymbolDisplayFormat CSharpShortErrorMessageFormat =
public static SymbolDisplayFormat CSharpShortErrorMessageFormat { get; } =
new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.OmittedAsContaining,
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes,
......@@ -58,7 +58,7 @@ public class SymbolDisplayFormat
/// <summary>
/// Formats a symbol description as in a Visual Basic compiler error message.
/// </summary>
public static readonly SymbolDisplayFormat VisualBasicErrorMessageFormat =
public static SymbolDisplayFormat VisualBasicErrorMessageFormat { get; } =
new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.OmittedAsContaining,
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
......@@ -90,7 +90,7 @@ public class SymbolDisplayFormat
/// <summary>
/// Formats a symbol description as in a Visual Basic compiler short error message.
/// </summary>
public static readonly SymbolDisplayFormat VisualBasicShortErrorMessageFormat =
public static SymbolDisplayFormat VisualBasicShortErrorMessageFormat { get; } =
new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.OmittedAsContaining,
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes,
......@@ -122,7 +122,7 @@ public class SymbolDisplayFormat
/// <summary>
/// Formats the names of all types and namespaces in a fully qualified style (including the global alias).
/// </summary>
public static readonly SymbolDisplayFormat FullyQualifiedFormat =
public static SymbolDisplayFormat FullyQualifiedFormat { get; } =
new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Included,
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
......@@ -134,7 +134,7 @@ public class SymbolDisplayFormat
/// <summary>
/// Formats a symbol description in a form that suits <see cref="ISymbol.ToMinimalDisplayString"/>.
/// </summary>
public static readonly SymbolDisplayFormat MinimallyQualifiedFormat =
public static SymbolDisplayFormat MinimallyQualifiedFormat { get; } =
new SymbolDisplayFormat(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
......
......@@ -18,7 +18,7 @@ public sealed class SyntaxAnnotation : IObjectWritable, IObjectReadable, IEquata
/// <summary>
/// A predefined syntax annotation that indicates whether the syntax element has elastic trivia.
/// </summary>
public static readonly SyntaxAnnotation ElasticAnnotation = new SyntaxAnnotation();
public static SyntaxAnnotation ElasticAnnotation { get; } = new SyntaxAnnotation();
// use a value identity instead of object identity so a deserialized instance matches the original instance.
private readonly long _id;
......
......@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis
[StructLayout(LayoutKind.Auto)]
public partial struct SyntaxTriviaList : IEquatable<SyntaxTriviaList>, IReadOnlyList<SyntaxTrivia>
{
public static readonly SyntaxTriviaList Empty = default(SyntaxTriviaList);
public static SyntaxTriviaList Empty => default(SyntaxTriviaList);
internal SyntaxTriviaList(SyntaxToken token, GreenNode node, int position, int index = 0)
{
......
......@@ -11,15 +11,14 @@ namespace Microsoft.CodeAnalysis
public abstract class SyntaxWalker
{
/// <summary>
/// True if this walker will descend into structured trivia.
/// Syntax the <see cref="SyntaxWalker"/> should descent into.
/// </summary>
protected readonly SyntaxWalkerDepth Depth;
protected SyntaxWalkerDepth Depth { get; }
/// <summary>
/// Creates a new walker instance.
/// </summary>
/// <param name="depth">specify how much this walker will descent into
/// trivia.</param>
/// <param name="depth">Syntax the <see cref="SyntaxWalker"/> should descent into.</param>
protected SyntaxWalker(SyntaxWalkerDepth depth = SyntaxWalkerDepth.Node)
{
this.Depth = depth;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// enum to specify how deep walker should decent into
/// Syntax the <see cref="SyntaxWalker"/> should descent into.
/// </summary>
public enum SyntaxWalkerDepth : int
{
......
......@@ -13,7 +13,7 @@ public struct LinePosition : IEquatable<LinePosition>, IComparable<LinePosition>
/// <summary>
/// A <see cref="LinePosition"/> that represents position 0 at line 0.
/// </summary>
public static readonly LinePosition Zero = new LinePosition(0, 0);
public static LinePosition Zero => default(LinePosition);
private readonly int _line;
private readonly int _character;
......
......@@ -86,6 +86,6 @@ public override int GetHashCode()
/// <summary>
/// An empty set of changes.
/// </summary>
public static readonly IReadOnlyList<TextChange> NoChanges = SpecializedCollections.EmptyReadOnlyList<TextChange>();
public static IReadOnlyList<TextChange> NoChanges => SpecializedCollections.EmptyReadOnlyList<TextChange>();
}
}
......@@ -85,7 +85,7 @@ public override int GetHashCode()
/// <summary>
/// An empty set of changes.
/// </summary>
public static readonly IReadOnlyList<TextChangeRange> NoChanges = SpecializedCollections.EmptyReadOnlyList<TextChangeRange>();
public static IReadOnlyList<TextChangeRange> NoChanges => SpecializedCollections.EmptyReadOnlyList<TextChangeRange>();
/// <summary>
/// Collapse a set of <see cref="TextChangeRange"/>s into a single encompassing range. If
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册