提交 176159b9 编写于 作者: B beep boop 提交者: Jared Parsons

Format TestUtilities

This type was mistakenly not formatted when the code was added to
GitHub.
上级 8ef96d00
......@@ -16,8 +16,8 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
{
public static class CLRHelpers
{
private static readonly Guid ClsIdClrRuntimeHost = new Guid("90F1A06E-7712-4762-86B5-7A5EBA6BDB02");
private static readonly Guid ClsIdCorMetaDataDispenser = new Guid("E5CB7A31-7512-11d2-89CE-0080C792E5D8");
private static readonly Guid s_clsIdClrRuntimeHost = new Guid("90F1A06E-7712-4762-86B5-7A5EBA6BDB02");
private static readonly Guid s_clsIdCorMetaDataDispenser = new Guid("E5CB7A31-7512-11d2-89CE-0080C792E5D8");
public static event ResolveEventHandler ReflectionOnlyAssemblyResolve;
......@@ -64,21 +64,21 @@ public static string[] PeVerify(string filePath)
return PeVerify(File.ReadAllBytes(filePath), AppDomain.CurrentDomain.Id, filePath);
}
private static readonly object Guard = new object();
private static readonly object s_guard = new object();
private static string[] PeVerify(byte[] peImage, int domainId, string assemblyPath)
{
lock (Guard)
lock (s_guard)
{
GCHandle pinned = GCHandle.Alloc(peImage, GCHandleType.Pinned);
try
{
IntPtr buffer = pinned.AddrOfPinnedObject();
ICLRValidator validator = (ICLRValidator)RuntimeEnvironment.GetRuntimeInterfaceAsObject(ClsIdClrRuntimeHost, typeof(ICLRRuntimeHost).GUID);
ICLRValidator validator = (ICLRValidator)RuntimeEnvironment.GetRuntimeInterfaceAsObject(s_clsIdClrRuntimeHost, typeof(ICLRRuntimeHost).GUID);
ValidationErrorHandler errorHandler = new ValidationErrorHandler(validator);
IMetaDataDispenser dispenser = (IMetaDataDispenser)RuntimeEnvironment.GetRuntimeInterfaceAsObject(ClsIdCorMetaDataDispenser, typeof(IMetaDataDispenser).GUID);
IMetaDataDispenser dispenser = (IMetaDataDispenser)RuntimeEnvironment.GetRuntimeInterfaceAsObject(s_clsIdCorMetaDataDispenser, typeof(IMetaDataDispenser).GUID);
// the buffer needs to be pinned during validation
Guid riid = typeof(IMetaDataImport).GUID;
......@@ -110,14 +110,14 @@ private static string[] PeVerify(byte[] peImage, int domainId, string assemblyPa
private class ValidationErrorHandler : IVEHandler
{
private readonly ICLRValidator m_validator;
private readonly List<string> m_output;
private readonly ICLRValidator _validator;
private readonly List<string> _output;
private const int MessageLength = 256;
public ValidationErrorHandler(ICLRValidator validator)
{
m_validator = validator;
m_output = new List<string>();
_validator = validator;
_output = new List<string>();
}
public void SetReporterFtn(long lFnPtr)
......@@ -143,29 +143,29 @@ public void VEHandler(int VECode, tag_VerError Context, Array psa)
}
else
{
m_validator.FormatEventInfo(VECode, Context, sb, (uint)MessageLength - 1, psa);
_validator.FormatEventInfo(VECode, Context, sb, (uint)MessageLength - 1, psa);
message = sb.ToString();
}
// retail version of peverify.exe filters out CLS warnings...
if (!message.Contains("[CLS]"))
{
m_output.Add(message);
_output.Add(message);
}
}
public string[] GetOutput()
{
return m_output.ToArray();
return _output.ToArray();
}
private static readonly string ResourceFilePath = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "mscorrc.dll");
private static readonly string s_resourceFilePath = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "mscorrc.dll");
private const uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
private static readonly IntPtr hMod = LoadLibraryEx(ResourceFilePath, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE);
private static readonly IntPtr s_hMod = LoadLibraryEx(s_resourceFilePath, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE);
private static void GetErrorResourceString(int code, StringBuilder message)
{
LoadString(hMod, (uint)(code & 0x0000FFFF), message, MessageLength - 1);
LoadString(s_hMod, (uint)(code & 0x0000FFFF), message, MessageLength - 1);
}
[DllImport("kernel32.dll", SetLastError = true)]
......@@ -233,7 +233,7 @@ public interface ICLRValidator
[ComImport, Guid("856CA1B2-7DAB-11D3-ACEC-00C04F86C309"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), TypeIdentifier]
public interface IVEHandler
{
void VEHandler([In, MarshalAs(UnmanagedType.Error)] int VECode,[In] tag_VerError Context,[In, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array psa);
void VEHandler([In, MarshalAs(UnmanagedType.Error)] int VECode, [In] tag_VerError Context, [In, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array psa);
void SetReporterFtn([In] long lFnPtr);
}
......@@ -268,7 +268,7 @@ public interface IMetaDataImport
[ComImport, Guid("4709C9C6-81FF-11D3-9FC7-00C04F79A0A3"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), TypeIdentifier]
public interface IMetaDataValidate
{
void ValidatorInit([In] CorValidatorModuleType dwModuleType,[In, MarshalAs(UnmanagedType.IUnknown)] object pUnk);
void ValidatorInit([In] CorValidatorModuleType dwModuleType, [In, MarshalAs(UnmanagedType.IUnknown)] object pUnk);
void ValidateMetaData();
}
......
......@@ -24,50 +24,50 @@ public abstract partial class CommonTestBase
{
public class CompilationVerifier
{
private readonly CommonTestBase test;
private readonly Compilation compilation;
private CompilationTestData testData;
private readonly IEnumerable<ModuleData> dependencies;
private ImmutableArray<Diagnostic> diagnostics;
private IModuleSymbol lazyModuleSymbol;
private IList<ModuleData> allModuleData;
private readonly CommonTestBase _test;
private readonly Compilation _compilation;
private CompilationTestData _testData;
private readonly IEnumerable<ModuleData> _dependencies;
private ImmutableArray<Diagnostic> _diagnostics;
private IModuleSymbol _lazyModuleSymbol;
private IList<ModuleData> _allModuleData;
internal ImmutableArray<byte> EmittedAssemblyData;
internal ImmutableArray<byte> EmittedAssemblyPdb;
public CompilationVerifier(
CommonTestBase test,
CommonTestBase test,
Compilation compilation,
IEnumerable<ModuleData> dependencies = null)
{
this.test = test;
this.compilation = compilation;
this.dependencies = dependencies;
_test = test;
_compilation = compilation;
_dependencies = dependencies;
}
public CompilationVerifier Clone()
{
return new CompilationVerifier(test, compilation, dependencies);
return new CompilationVerifier(_test, _compilation, _dependencies);
}
internal CompilationTestData TestData
{
get { return testData; }
get { return _testData; }
}
public Compilation Compilation
{
get { return compilation; }
get { return _compilation; }
}
public TempRoot Temp
{
get { return test.Temp; }
get { return _test.Temp; }
}
internal ImmutableArray<Diagnostic> Diagnostics
{
get { return diagnostics; }
get { return _diagnostics; }
}
internal ImmutableArray<ModuleMetadata> GetAllModuleMetadata()
......@@ -79,9 +79,9 @@ internal ImmutableArray<ModuleMetadata> GetAllModuleMetadata()
ImmutableArray<ModuleMetadata> modules = ImmutableArray.Create(ModuleMetadata.CreateFromImage(EmittedAssemblyData));
if (allModuleData != null)
if (_allModuleData != null)
{
var netModules = allModuleData.Where(m => m.Kind == OutputKind.NetModule);
var netModules = _allModuleData.Where(m => m.Kind == OutputKind.NetModule);
if (netModules.Any())
{
modules = modules.Concat(
......@@ -94,10 +94,10 @@ internal ImmutableArray<ModuleMetadata> GetAllModuleMetadata()
public void Emit(string expectedOutput, IEnumerable<ResourceDescription> manifestResources, bool peVerify, SignatureDescription[] expectedSignatures)
{
using (var testEnvironment = new HostedRuntimeEnvironment(dependencies))
using (var testEnvironment = new HostedRuntimeEnvironment(_dependencies))
{
string mainModuleName = Emit(testEnvironment, manifestResources);
allModuleData = testEnvironment.GetAllModuleData();
_allModuleData = testEnvironment.GetAllModuleData();
if (peVerify)
{
......@@ -120,7 +120,7 @@ public void Emit(string expectedOutput, IEnumerable<ResourceDescription> manifes
// Replace bool verify parameter with string[] expectedPeVerifyOutput. If null, no verification. If empty verify have to succeed. Otherwise compare errors.
public void EmitAndVerify(params string[] expectedPeVerifyOutput)
{
using (var testEnvironment = new HostedRuntimeEnvironment(dependencies))
using (var testEnvironment = new HostedRuntimeEnvironment(_dependencies))
{
string mainModuleName = Emit(testEnvironment, null);
string[] actualOutput = testEnvironment.PeVerifyModules(new[] { mainModuleName }, throwOnError: false);
......@@ -130,20 +130,20 @@ public void EmitAndVerify(params string[] expectedPeVerifyOutput)
private string Emit(HostedRuntimeEnvironment testEnvironment, IEnumerable<ResourceDescription> manifestResources)
{
testEnvironment.Emit(compilation, manifestResources);
testEnvironment.Emit(_compilation, manifestResources);
diagnostics = testEnvironment.GetDiagnostics();
_diagnostics = testEnvironment.GetDiagnostics();
EmittedAssemblyData = testEnvironment.GetMainImage();
EmittedAssemblyPdb = testEnvironment.GetMainPdb();
testData = testEnvironment.GetCompilationTestData();
_testData = testEnvironment.GetCompilationTestData();
return compilation.Assembly.Identity.GetDisplayName();
return _compilation.Assembly.Identity.GetDisplayName();
}
public CompilationVerifier VerifyIL(
string qualifiedMethodName,
XCData expectedIL,
bool realIL = false,
string qualifiedMethodName,
XCData expectedIL,
bool realIL = false,
string sequencePoints = null,
[CallerFilePath]string callerPath = null,
[CallerLineNumber]int callerLine = 0)
......@@ -174,7 +174,7 @@ private string Emit(HostedRuntimeEnvironment testEnvironment, IEnumerable<Resour
// TODO: Currently the qualifiedMethodName is a symbol display name while PDB need metadata name.
// So we need to pass the PDB metadata name of the method to sequencePoints (instead of just bool).
var methodData = testData.GetMethodData(qualifiedMethodName);
var methodData = _testData.GetMethodData(qualifiedMethodName);
// verify IL emitted via CCI, if any:
string actualCciIL = VisualizeIL(methodData, realIL, sequencePoints, useRefEmitter: false);
......@@ -192,7 +192,7 @@ private string Emit(HostedRuntimeEnvironment testEnvironment, IEnumerable<Resour
[CallerLineNumber]int expectedValueSourceLine = 0,
[CallerFilePath]string expectedValueSourcePath = null)
{
this.compilation.VerifyPdb(expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
_compilation.VerifyPdb(expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
return this;
}
......@@ -201,7 +201,7 @@ private string Emit(HostedRuntimeEnvironment testEnvironment, IEnumerable<Resour
[CallerLineNumber]int expectedValueSourceLine = 0,
[CallerFilePath]string expectedValueSourcePath = null)
{
this.compilation.VerifyPdb(expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
_compilation.VerifyPdb(expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
return this;
}
......@@ -211,7 +211,7 @@ private string Emit(HostedRuntimeEnvironment testEnvironment, IEnumerable<Resour
[CallerLineNumber]int expectedValueSourceLine = 0,
[CallerFilePath]string expectedValueSourcePath = null)
{
this.compilation.VerifyPdb(qualifiedMethodName, expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
_compilation.VerifyPdb(qualifiedMethodName, expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
return this;
}
......@@ -221,7 +221,7 @@ private string Emit(HostedRuntimeEnvironment testEnvironment, IEnumerable<Resour
[CallerLineNumber]int expectedValueSourceLine = 0,
[CallerFilePath]string expectedValueSourcePath = null)
{
this.compilation.VerifyPdb(qualifiedMethodName, expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
_compilation.VerifyPdb(qualifiedMethodName, expectedPdb, expectedValueSourceLine, expectedValueSourcePath);
return this;
}
......@@ -252,7 +252,7 @@ public DebugInfoProvider CreatePdbInfoProvider()
public string VisualizeIL(string qualifiedMethodName, bool realIL = false, string sequencePoints = null, bool useRefEmitter = false)
{
return VisualizeIL(testData.GetMethodData(qualifiedMethodName), realIL, sequencePoints, useRefEmitter);
return VisualizeIL(_testData.GetMethodData(qualifiedMethodName), realIL, sequencePoints, useRefEmitter);
}
private string VisualizeIL(CompilationTestData.MethodData methodData, bool realIL, string sequencePoints, bool useRefEmitter)
......@@ -262,9 +262,9 @@ private string VisualizeIL(CompilationTestData.MethodData methodData, bool realI
if (sequencePoints != null)
{
var actualPdbXml = PdbToXmlConverter.ToXml(
pdbStream: new MemoryStream(EmittedAssemblyPdb.ToArray()),
peStream: new MemoryStream(EmittedAssemblyData.ToArray()),
options: PdbToXmlOptions.ResolveTokens | PdbToXmlOptions.ThrowOnError,
pdbStream: new MemoryStream(EmittedAssemblyPdb.ToArray()),
peStream: new MemoryStream(EmittedAssemblyData.ToArray()),
options: PdbToXmlOptions.ResolveTokens | PdbToXmlOptions.ThrowOnError,
methodName: sequencePoints);
markers = GetMarkers(actualPdbXml);
......@@ -276,24 +276,24 @@ private string VisualizeIL(CompilationTestData.MethodData methodData, bool realI
}
var module = this.GetModuleSymbolForEmittedImage();
return module != null ? test.VisualizeRealIL(module, methodData, markers) : null;
return module != null ? _test.VisualizeRealIL(module, methodData, markers) : null;
}
public CompilationVerifier VerifyMemberInIL(string methodName, bool expected)
{
Assert.Equal(expected, testData.Methods.ContainsKey(methodName));
Assert.Equal(expected, _testData.Methods.ContainsKey(methodName));
return this;
}
public CompilationVerifier VerifyDiagnostics(params DiagnosticDescription[] expected)
{
diagnostics.Verify(expected);
_diagnostics.Verify(expected);
return this;
}
public IModuleSymbol GetModuleSymbolForEmittedImage()
{
return GetModuleSymbolForEmittedImage(ref lazyModuleSymbol, EmittedAssemblyData);
return GetModuleSymbolForEmittedImage(ref _lazyModuleSymbol, EmittedAssemblyData);
}
private IModuleSymbol GetModuleSymbolForEmittedImage(ref IModuleSymbol moduleSymbol, ImmutableArray<byte> peImage)
......@@ -307,9 +307,9 @@ private IModuleSymbol GetModuleSymbolForEmittedImage(ref IModuleSymbol moduleSym
{
Debug.Assert(!peImage.IsDefault);
var targetReference = LoadTestEmittedExecutableForSymbolValidation(peImage, compilation.Options.OutputKind, display: compilation.AssemblyName);
var references = compilation.References.Concat(new[] { targetReference });
var assemblies = test.ReferencesToModuleSymbols(references, compilation.Options.MetadataImportOptions);
var targetReference = LoadTestEmittedExecutableForSymbolValidation(peImage, _compilation.Options.OutputKind, display: _compilation.AssemblyName);
var references = _compilation.References.Concat(new[] { targetReference });
var assemblies = _test.ReferencesToModuleSymbols(references, _compilation.Options.MetadataImportOptions);
var module = assemblies.Last();
moduleSymbol = module;
}
......
......@@ -27,7 +27,7 @@ static CommonTestBase()
{
var configFileName = Path.GetFileName(Assembly.GetExecutingAssembly().Location) + ".config";
var configFilePath = Path.Combine(Environment.CurrentDirectory, configFileName);
if (File.Exists(configFilePath))
{
var assemblyConfig = XDocument.Load(configFilePath);
......@@ -70,7 +70,7 @@ static CommonTestBase()
throw new Exception("Unable to load any emitter");
}
emitters = builder.ToImmutableArray();
s_emitters = builder.ToImmutableArray();
}
}
}
......@@ -79,7 +79,7 @@ static CommonTestBase()
internal abstract IEnumerable<IModuleSymbol> ReferencesToModuleSymbols(IEnumerable<MetadataReference> references, MetadataImportOptions importOptions = MetadataImportOptions.Public);
#region Emit
protected abstract Compilation GetCompilationForEmit(
IEnumerable<string> source,
IEnumerable<MetadataReference> additionalRefs,
......@@ -100,7 +100,7 @@ static CommonTestBase()
bool collectEmittedAssembly,
bool verify);
private static readonly ImmutableArray<Emitter> emitters;
private static readonly ImmutableArray<Emitter> s_emitters;
internal CompilationVerifier CompileAndVerify(
string source,
......@@ -181,7 +181,7 @@ static CommonTestBase()
{
Assert.NotNull(compilation);
Assert.True(expectedOutput == null ||
Assert.True(expectedOutput == null ||
(compilation.Options.OutputKind == OutputKind.ConsoleApplication || compilation.Options.OutputKind == OutputKind.WindowsApplication),
"Compilation must be executable if output is expected.");
......@@ -198,7 +198,7 @@ static CommonTestBase()
sourceSymbolValidator(module, emitOptions);
}
if (emitters.IsDefaultOrEmpty)
if (s_emitters.IsDefaultOrEmpty)
{
throw new InvalidOperationException(
@"You must specify at least one Emitter.
......@@ -217,7 +217,7 @@ static CommonTestBase()
CompilationVerifier result = null;
foreach (var emit in emitters)
foreach (var emit in s_emitters)
{
var verifier = emit(this,
compilation,
......@@ -260,16 +260,16 @@ static CommonTestBase()
return null;
}
}
internal CompilationVerifier CompileAndVerifyFieldMarshal(string source, Dictionary<string, byte[]> expectedBlobs, bool isField = true, TestEmitters emitOptions = TestEmitters.All)
{
return CompileAndVerifyFieldMarshal(
source,
(s, _omitted1, _omitted2) =>
{
source,
(s, _omitted1, _omitted2) =>
{
Assert.True(expectedBlobs.ContainsKey(s), "Expecting marshalling blob for " + (isField ? "field " : "parameter ") + s);
return expectedBlobs[s];
},
return expectedBlobs[s];
},
isField,
emitOptions);
}
......@@ -482,7 +482,7 @@ internal static MetadataReference CreateReflectionEmitAssembly(Action<ModuleBuil
{
assemblyName = GetUniqueName();
}
if (parseOptions == null)
{
parseOptions = CSharp.CSharpParseOptions.Default.WithDocumentationMode(DocumentationMode.None);
......@@ -537,7 +537,7 @@ internal static MetadataReference CreateReflectionEmitAssembly(Action<ModuleBuil
{
assemblyName = GetUniqueName();
}
if (parseOptions == null)
{
parseOptions = VisualBasic.VisualBasicParseOptions.Default;
......@@ -599,7 +599,7 @@ private void AddReferencedCompilations(IEnumerable<Compilation> referencedCompil
DocumentationProvider documentation = null,
string filePath = null)
{
if(image == null)
if (image == null)
{
throw new ArgumentNullException(nameof(image));
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
extern alias PDB;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
......@@ -28,9 +27,9 @@ internal sealed class CompilationDifference
public readonly ImmutableArray<MethodDefinitionHandle> UpdatedMethods;
public CompilationDifference(
ImmutableArray<byte> metadata,
ImmutableArray<byte> il,
Stream pdbStream,
ImmutableArray<byte> metadata,
ImmutableArray<byte> il,
Stream pdbStream,
CompilationTestData testData,
EmitDifferenceResult result,
ImmutableArray<MethodDefinitionHandle> methodHandles)
......@@ -64,11 +63,11 @@ public PinnedMetadata GetMetadata()
}
public void VerifyIL(
string qualifiedMethodName,
string expectedIL,
Func<Cci.ILocalDefinition, ILVisualizer.LocalInfo> mapLocal = null,
string qualifiedMethodName,
string expectedIL,
Func<Cci.ILocalDefinition, ILVisualizer.LocalInfo> mapLocal = null,
MethodDefinitionHandle methodToken = default(MethodDefinitionHandle),
[CallerFilePath]string callerPath = null,
[CallerFilePath]string callerPath = null,
[CallerLineNumber]int callerLine = 0)
{
var ilBuilder = TestData.GetMethodData(qualifiedMethodName).ILBuilder;
......
......@@ -16,9 +16,9 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
public static class CompilationExtensions
{
internal static ImmutableArray<byte> EmitToArray(
this Compilation compilation,
this Compilation compilation,
EmitOptions options = null,
CompilationTestData testData = null,
CompilationTestData testData = null,
DiagnosticDescription[] expectedWarnings = null)
{
var stream = new MemoryStream();
......@@ -59,10 +59,10 @@ public static Stream EmitToStream(this Compilation compilation, EmitOptions opti
}
public static MetadataReference EmitToImageReference(
this Compilation comp,
this Compilation comp,
EmitOptions options = null,
bool embedInteropTypes = false,
ImmutableArray<string> aliases = default(ImmutableArray<string>),
ImmutableArray<string> aliases = default(ImmutableArray<string>),
DiagnosticDescription[] expectedWarnings = null)
{
var image = comp.EmitToArray(options, expectedWarnings: expectedWarnings);
......
......@@ -8,37 +8,37 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
{
public static class ConsoleOutput
{
private static readonly object ConsoleGuard = new object();
private static readonly object s_consoleGuard = new object();
private sealed class CappedStringWriter : StringWriter
{
private readonly int expectedLength;
private int remaining;
private readonly int _expectedLength;
private int _remaining;
public CappedStringWriter(int expectedLength)
: base(System.Globalization.CultureInfo.InvariantCulture)
{
if (expectedLength < 0)
{
this.expectedLength = this.remaining = 1024 * 1024;
_expectedLength = _remaining = 1024 * 1024;
}
else
{
this.expectedLength = expectedLength;
this.remaining = Math.Max(256, expectedLength * 4);
_expectedLength = expectedLength;
_remaining = Math.Max(256, expectedLength * 4);
}
}
private void CapReached()
{
Assert.True(false, "Test produced more output than expected (" + expectedLength + " characters). Is it in an infinite loop? Output so far:\r\n" + GetStringBuilder());
Assert.True(false, "Test produced more output than expected (" + _expectedLength + " characters). Is it in an infinite loop? Output so far:\r\n" + GetStringBuilder());
}
public override void Write(char value)
{
if (1 <= remaining)
if (1 <= _remaining)
{
remaining--;
_remaining--;
base.Write(value);
}
else
......@@ -49,9 +49,9 @@ public override void Write(char value)
public override void Write(char[] buffer, int index, int count)
{
if (count <= remaining)
if (count <= _remaining)
{
remaining -= count;
_remaining -= count;
base.Write(buffer, index, count);
}
else
......@@ -62,9 +62,9 @@ public override void Write(char[] buffer, int index, int count)
public override void Write(string value)
{
if (value.Length <= remaining)
if (value.Length <= _remaining)
{
remaining -= value.Length;
_remaining -= value.Length;
base.Write(value);
}
else
......@@ -79,7 +79,7 @@ public static void Capture(Action action, int expectedLength, out string output,
TextWriter errorOutputWriter = new CappedStringWriter(expectedLength);
TextWriter outputWriter = new CappedStringWriter(expectedLength);
lock (ConsoleGuard)
lock (s_consoleGuard)
{
TextWriter originalOut = Console.Out;
TextWriter originalError = Console.Error;
......
......@@ -8,16 +8,16 @@ namespace Roslyn.Test.Utilities
{
public class CultureContext : IDisposable
{
private readonly CultureInfo threadCulture = CultureInfo.InvariantCulture;
private readonly CultureInfo _threadCulture = CultureInfo.InvariantCulture;
public CultureContext(string testCulture)
{
threadCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo(testCulture, useUserOverride:false);
_threadCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo(testCulture, useUserOverride: false);
}
public void Dispose()
{
Thread.CurrentThread.CurrentCulture = threadCulture;
Thread.CurrentThread.CurrentCulture = _threadCulture;
}
}
}
......@@ -19,31 +19,31 @@ public sealed class DiagnosticDescription
public static readonly DiagnosticDescription[] Any = null;
// common fields for all DiagnosticDescriptions
private readonly object code;
private readonly bool isWarningAsError;
private readonly string squiggledText;
private readonly object[] arguments;
private readonly LinePosition? startPosition; // May not have a value only in the case that we're constructed via factories
private bool showPosition; // show start position in ToString if comparison fails
private readonly bool argumentOrderDoesNotMatter;
private readonly Type errorCodeType;
private readonly bool ignoreArgumentsWhenComparing;
private readonly object _code;
private readonly bool _isWarningAsError;
private readonly string _squiggledText;
private readonly object[] _arguments;
private readonly LinePosition? _startPosition; // May not have a value only in the case that we're constructed via factories
private bool _showPosition; // show start position in ToString if comparison fails
private readonly bool _argumentOrderDoesNotMatter;
private readonly Type _errorCodeType;
private readonly bool _ignoreArgumentsWhenComparing;
// fields for DiagnosticDescriptions constructed via factories
private readonly Func<SyntaxNode, bool> syntaxPredicate;
private bool showPredicate; // show predicate in ToString if comparison fails
private readonly Func<SyntaxNode, bool> _syntaxPredicate;
private bool _showPredicate; // show predicate in ToString if comparison fails
// fields for DiagnosticDescriptions constructed from Diagnostics
private readonly Location location;
private readonly Location _location;
private IEnumerable<string> argumentsAsStrings;
private IEnumerable<string> _argumentsAsStrings;
private IEnumerable<string> GetArgumentsAsStrings()
{
if (argumentsAsStrings == null)
if (_argumentsAsStrings == null)
{
// We'll use IFormattable here, because it is more explicit than just calling .ToString()
// (and is closer to what the compiler actually does when displaying error messages)
argumentsAsStrings = arguments.Select(o =>
_argumentsAsStrings = _arguments.Select(o =>
{
var embedded = o as DiagnosticInfo;
if (embedded != null)
......@@ -54,27 +54,27 @@ private IEnumerable<string> GetArgumentsAsStrings()
return String.Format(EnsureEnglishUICulture.PreferredOrNull, "{0}", o);
});
}
return argumentsAsStrings;
return _argumentsAsStrings;
}
public DiagnosticDescription(
object code,
object code,
bool isWarningAsError,
string squiggledText,
object[] arguments,
object[] arguments,
LinePosition? startLocation,
Func<SyntaxNode, bool> syntaxNodePredicate,
Func<SyntaxNode, bool> syntaxNodePredicate,
bool argumentOrderDoesNotMatter,
Type errorCodeType = null)
{
this.code = code;
this.isWarningAsError = isWarningAsError;
this.squiggledText = squiggledText;
this.arguments = arguments;
startPosition = startLocation;
syntaxPredicate = syntaxNodePredicate;
this.argumentOrderDoesNotMatter = argumentOrderDoesNotMatter;
this.errorCodeType = errorCodeType ?? code.GetType();
_code = code;
_isWarningAsError = isWarningAsError;
_squiggledText = squiggledText;
_arguments = arguments;
_startPosition = startLocation;
_syntaxPredicate = syntaxNodePredicate;
_argumentOrderDoesNotMatter = argumentOrderDoesNotMatter;
_errorCodeType = errorCodeType ?? code.GetType();
}
public DiagnosticDescription(
......@@ -86,93 +86,93 @@ private IEnumerable<string> GetArgumentsAsStrings()
bool argumentOrderDoesNotMatter,
Type errorCodeType = null)
{
this.code = code;
this.isWarningAsError = false;
this.squiggledText = squiggledText;
this.arguments = arguments;
startPosition = startLocation;
syntaxPredicate = syntaxNodePredicate;
this.argumentOrderDoesNotMatter = argumentOrderDoesNotMatter;
this.errorCodeType = errorCodeType ?? code.GetType();
_code = code;
_isWarningAsError = false;
_squiggledText = squiggledText;
_arguments = arguments;
_startPosition = startLocation;
_syntaxPredicate = syntaxNodePredicate;
_argumentOrderDoesNotMatter = argumentOrderDoesNotMatter;
_errorCodeType = errorCodeType ?? code.GetType();
}
internal DiagnosticDescription(Diagnostic d, bool errorCodeOnly, bool showPosition = false)
{
this.code = d.Code;
this.isWarningAsError = d.IsWarningAsError;
this.location = d.Location;
_code = d.Code;
_isWarningAsError = d.IsWarningAsError;
_location = d.Location;
DiagnosticWithInfo dinfo = null;
if (d.Code == 0)
{
code = d.Id;
errorCodeType = typeof(string);
_code = d.Id;
_errorCodeType = typeof(string);
}
else
{
dinfo = d as DiagnosticWithInfo;
if (dinfo == null)
{
code = d.Code;
errorCodeType = typeof(int);
_code = d.Code;
_errorCodeType = typeof(int);
}
else
{
errorCodeType = dinfo.Info.MessageProvider.ErrorCodeType;
code = d.Code;
_errorCodeType = dinfo.Info.MessageProvider.ErrorCodeType;
_code = d.Code;
}
}
this.ignoreArgumentsWhenComparing = errorCodeOnly;
this.showPosition = showPosition;
_ignoreArgumentsWhenComparing = errorCodeOnly;
_showPosition = showPosition;
if (!this.ignoreArgumentsWhenComparing)
if (!_ignoreArgumentsWhenComparing)
{
if (this.location.IsInSource)
if (_location.IsInSource)
{
// we don't just want to do SyntaxNode.GetText(), because getting the text via the SourceTree validates the public API
this.squiggledText = this.location.SourceTree.GetText().ToString(this.location.SourceSpan);
_squiggledText = _location.SourceTree.GetText().ToString(_location.SourceSpan);
}
if (dinfo != null)
{
arguments = dinfo.Info.Arguments;
_arguments = dinfo.Info.Arguments;
}
else
{
var args = d.Arguments;
if (args == null || args.Count == 0)
{
arguments = null;
_arguments = null;
}
else
{
arguments = d.Arguments.ToArray();
_arguments = d.Arguments.ToArray();
}
}
if (this.arguments != null && this.arguments.Length == 0)
if (_arguments != null && _arguments.Length == 0)
{
this.arguments = null;
_arguments = null;
}
}
this.startPosition = this.location.GetMappedLineSpan().StartLinePosition;
_startPosition = _location.GetMappedLineSpan().StartLinePosition;
}
public DiagnosticDescription WithArguments(params string[] arguments)
{
return new DiagnosticDescription(code, isWarningAsError, squiggledText, arguments, startPosition, syntaxPredicate, false, errorCodeType);
return new DiagnosticDescription(_code, _isWarningAsError, _squiggledText, arguments, _startPosition, _syntaxPredicate, false, _errorCodeType);
}
public DiagnosticDescription WithArgumentsAnyOrder(params string[] arguments)
{
return new DiagnosticDescription(code, isWarningAsError, squiggledText, arguments, startPosition, syntaxPredicate, true, errorCodeType);
return new DiagnosticDescription(_code, _isWarningAsError, _squiggledText, arguments, _startPosition, _syntaxPredicate, true, _errorCodeType);
}
public DiagnosticDescription WithWarningAsError(bool isWarningAsError)
{
return new DiagnosticDescription(code, isWarningAsError, squiggledText, arguments, startPosition, syntaxPredicate, true, errorCodeType);
return new DiagnosticDescription(_code, isWarningAsError, _squiggledText, _arguments, _startPosition, _syntaxPredicate, true, _errorCodeType);
}
/// <summary>
......@@ -180,7 +180,7 @@ public DiagnosticDescription WithWarningAsError(bool isWarningAsError)
/// </summary>
public DiagnosticDescription WithLocation(int line, int column)
{
return new DiagnosticDescription(code, isWarningAsError, squiggledText, arguments, new LinePosition(line - 1, column - 1), syntaxPredicate, argumentOrderDoesNotMatter, errorCodeType);
return new DiagnosticDescription(_code, _isWarningAsError, _squiggledText, _arguments, new LinePosition(line - 1, column - 1), _syntaxPredicate, _argumentOrderDoesNotMatter, _errorCodeType);
}
/// <summary>
......@@ -189,7 +189,7 @@ public DiagnosticDescription WithLocation(int line, int column)
/// <param name="syntaxPredicate">The argument to syntaxPredicate will be the nearest SyntaxNode whose Span contains first squiggled character.</param>
public DiagnosticDescription WhereSyntax(Func<SyntaxNode, bool> syntaxPredicate)
{
return new DiagnosticDescription(code, isWarningAsError, squiggledText, arguments, startPosition, syntaxPredicate, argumentOrderDoesNotMatter, errorCodeType);
return new DiagnosticDescription(_code, _isWarningAsError, _squiggledText, _arguments, _startPosition, syntaxPredicate, _argumentOrderDoesNotMatter, _errorCodeType);
}
public override bool Equals(object obj)
......@@ -199,80 +199,80 @@ public override bool Equals(object obj)
if (obj == null)
return false;
if (!code.Equals(d.code))
if (!_code.Equals(d._code))
return false;
if (isWarningAsError != d.isWarningAsError)
if (_isWarningAsError != d._isWarningAsError)
return false;
if (!ignoreArgumentsWhenComparing)
if (!_ignoreArgumentsWhenComparing)
{
if (squiggledText != d.squiggledText)
if (_squiggledText != d._squiggledText)
return false;
}
if (startPosition != null)
if (_startPosition != null)
{
if (d.startPosition != null)
if (d._startPosition != null)
{
if (startPosition.Value != d.startPosition.Value)
if (_startPosition.Value != d._startPosition.Value)
{
showPosition = true;
d.showPosition = true;
_showPosition = true;
d._showPosition = true;
return false;
}
showPosition = false;
d.showPosition = false;
_showPosition = false;
d._showPosition = false;
}
}
if (syntaxPredicate != null)
if (_syntaxPredicate != null)
{
if (d.location == null)
if (d._location == null)
return false;
if (!syntaxPredicate(d.location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start, true).Parent))
if (!_syntaxPredicate(d._location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start, true).Parent))
{
showPredicate = true;
_showPredicate = true;
return false;
}
showPredicate = false;
_showPredicate = false;
}
if (d.syntaxPredicate != null)
if (d._syntaxPredicate != null)
{
if (location == null)
if (_location == null)
return false;
if (!d.syntaxPredicate(location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start, true).Parent))
if (!d._syntaxPredicate(_location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start, true).Parent))
{
d.showPredicate = true;
d._showPredicate = true;
return false;
}
d.showPredicate = false;
d._showPredicate = false;
}
// If ignoring arguments, we can skip the rest of this method.
if (ignoreArgumentsWhenComparing || d.ignoreArgumentsWhenComparing)
if (_ignoreArgumentsWhenComparing || d._ignoreArgumentsWhenComparing)
return true;
// Only validation of arguments should happen between here and the end of this method.
if (arguments == null)
if (_arguments == null)
{
if (d.arguments != null)
if (d._arguments != null)
return false;
}
else // _arguments != null
{
if (d.arguments == null)
if (d._arguments == null)
return false;
// we'll compare the arguments as strings
var args1 = GetArgumentsAsStrings();
var args2 = d.GetArgumentsAsStrings();
if (argumentOrderDoesNotMatter || d.argumentOrderDoesNotMatter)
if (_argumentOrderDoesNotMatter || d._argumentOrderDoesNotMatter)
{
if (args1.Count() != args2.Count() || !args1.SetEquals(args2))
return false;
......@@ -290,14 +290,14 @@ public override bool Equals(object obj)
public override int GetHashCode()
{
int hashCode;
hashCode = code.GetHashCode();
hashCode = Hash.Combine(isWarningAsError.GetHashCode(), hashCode);
hashCode = _code.GetHashCode();
hashCode = Hash.Combine(_isWarningAsError.GetHashCode(), hashCode);
// TODO: !!! This implementation isn't consistent with Equals, which might ignore inequality of some members based on ignoreArgumentsWhenComparing flag, etc.
hashCode = Hash.Combine(squiggledText, hashCode);
hashCode = Hash.Combine(arguments, hashCode);
if (startPosition != null)
hashCode = Hash.Combine(hashCode, startPosition.Value.GetHashCode());
hashCode = Hash.Combine(_squiggledText, hashCode);
hashCode = Hash.Combine(_arguments, hashCode);
if (_startPosition != null)
hashCode = Hash.Combine(hashCode, _startPosition.Value.GetHashCode());
return hashCode;
}
......@@ -306,28 +306,28 @@ public override string ToString()
var sb = new StringBuilder();
sb.Append("Diagnostic(");
if (errorCodeType == typeof(string))
if (_errorCodeType == typeof(string))
{
sb.Append("\"").Append(code).Append("\"");
sb.Append("\"").Append(_code).Append("\"");
}
else
{
sb.Append(errorCodeType.Name);
sb.Append(_errorCodeType.Name);
sb.Append(".");
sb.Append(Enum.GetName(errorCodeType, code));
sb.Append(Enum.GetName(_errorCodeType, _code));
}
if (squiggledText != null)
if (_squiggledText != null)
{
if (squiggledText.Contains("\n") || squiggledText.Contains("\\") || squiggledText.Contains("\""))
if (_squiggledText.Contains("\n") || _squiggledText.Contains("\\") || _squiggledText.Contains("\""))
{
sb.Append(", @\"");
sb.Append(squiggledText.Replace("\"", "\"\""));
sb.Append(_squiggledText.Replace("\"", "\"\""));
}
else
{
sb.Append(", \"");
sb.Append(squiggledText);
sb.Append(_squiggledText);
}
sb.Append('"');
......@@ -335,7 +335,7 @@ public override string ToString()
sb.Append(")");
if (arguments != null)
if (_arguments != null)
{
sb.Append(".WithArguments(");
var argumentStrings = GetArgumentsAsStrings().GetEnumerator();
......@@ -344,7 +344,7 @@ public override string ToString()
sb.Append("\"");
sb.Append(argumentStrings.Current);
sb.Append("\"");
if (i < arguments.Length - 1)
if (i < _arguments.Length - 1)
{
sb.Append(", ");
}
......@@ -352,21 +352,21 @@ public override string ToString()
sb.Append(")");
}
if (startPosition != null && showPosition)
if (_startPosition != null && _showPosition)
{
sb.Append(".WithLocation(");
sb.Append(startPosition.Value.Line + 1);
sb.Append(_startPosition.Value.Line + 1);
sb.Append(", ");
sb.Append(startPosition.Value.Character + 1);
sb.Append(_startPosition.Value.Character + 1);
sb.Append(")");
}
if (isWarningAsError)
if (_isWarningAsError)
{
sb.Append(".WithWarningAsError(true)");
}
if (syntaxPredicate != null && showPredicate)
if (_syntaxPredicate != null && _showPredicate)
{
sb.Append(".WhereSyntax(...)");
}
......@@ -382,7 +382,7 @@ public static string GetAssertText(DiagnosticDescription[] expected, IEnumerable
const int CSharp = 1;
const int VisualBasic = 2;
var language = actual.Any() && actual.First().Id.StartsWith("CS") ? CSharp : VisualBasic;
if (language == CSharp)
{
includeDiagnosticMessagesAsComments = true;
......
......@@ -31,7 +31,7 @@ public enum TestEmitters
RefEmitUnsupported_646014 = RefEmitUnsupported, // FieldBuilder.SetConstant fails on a field whose type is a type builder instantiatiation
RefEmitUnsupported_646021 = RefEmitUnsupported, // TypeBuilder.CreateType fails if the type contains a static method marked with PreserveSig flag.
RefEmitUnsupported_646023 = RefEmitUnsupported, // Custom modifiers not supported on element type of array type
RefEmitBug_646048 = RefEmitBug, // ParameterBuilder.SetConstant throws if the type of the value doesn't match the type of the parameter
RefEmitBug_646048 = RefEmitBug, // ParameterBuilder.SetConstant throws if the type of the value doesn't match the type of the parameter
RefEmitUnsupported_646042 = RefEmitUnsupported, // Types with certain dependencies are not possible to emit
}
}
......@@ -23,31 +23,31 @@ public static CultureInfo PreferredOrNull
}
}
private bool needToRestore;
private readonly CultureInfo threadUICulture;
private readonly int threadId;
private bool _needToRestore;
private readonly CultureInfo _threadUICulture;
private readonly int _threadId;
public EnsureEnglishUICulture()
{
threadId = Thread.CurrentThread.ManagedThreadId;
_threadId = Thread.CurrentThread.ManagedThreadId;
var preferred = PreferredOrNull;
if (preferred != null)
{
threadUICulture = Thread.CurrentThread.CurrentUICulture;
needToRestore = true;
_threadUICulture = Thread.CurrentThread.CurrentUICulture;
_needToRestore = true;
Thread.CurrentThread.CurrentUICulture = preferred;
}
}
public void Dispose()
{
Debug.Assert(threadId == Thread.CurrentThread.ManagedThreadId);
Debug.Assert(_threadId == Thread.CurrentThread.ManagedThreadId);
if (needToRestore && threadId == Thread.CurrentThread.ManagedThreadId)
if (_needToRestore && _threadId == Thread.CurrentThread.ManagedThreadId)
{
needToRestore = false;
Thread.CurrentThread.CurrentUICulture = threadUICulture;
_needToRestore = false;
Thread.CurrentThread.CurrentUICulture = _threadUICulture;
}
}
}
......
......@@ -8,7 +8,7 @@ namespace Roslyn.Test.Utilities
{
public class EqualityUnit<T>
{
private static readonly ReadOnlyCollection<T> EmptyCollection = new ReadOnlyCollection<T>(new T[] { });
private static readonly ReadOnlyCollection<T> s_emptyCollection = new ReadOnlyCollection<T>(new T[] { });
public readonly T Value;
public readonly ReadOnlyCollection<T> EqualValues;
......@@ -21,8 +21,8 @@ public IEnumerable<T> AllValues
public EqualityUnit(T value)
{
Value = value;
EqualValues = EmptyCollection;
NotEqualValues = EmptyCollection;
EqualValues = s_emptyCollection;
NotEqualValues = s_emptyCollection;
}
public EqualityUnit(
......
......@@ -15,18 +15,18 @@ namespace Roslyn.Test.Utilities
/// </summary>
public sealed class EqualityUtil<T>
{
private readonly ReadOnlyCollection<EqualityUnit<T>> equalityUnits;
private readonly Func<T, T, bool> compareWithEqualityOperator;
private readonly Func<T, T, bool> compareWithInequalityOperator;
private readonly ReadOnlyCollection<EqualityUnit<T>> _equalityUnits;
private readonly Func<T, T, bool> _compareWithEqualityOperator;
private readonly Func<T, T, bool> _compareWithInequalityOperator;
public EqualityUtil(
IEnumerable<EqualityUnit<T>> equalityUnits,
Func<T, T, bool> compEquality,
Func<T, T, bool> compInequality)
{
this.equalityUnits = equalityUnits.ToList().AsReadOnly();
this.compareWithEqualityOperator = compEquality;
this.compareWithInequalityOperator = compInequality;
_equalityUnits = equalityUnits.ToList().AsReadOnly();
_compareWithEqualityOperator = compEquality;
_compareWithInequalityOperator = compInequality;
}
public void RunAll()
......@@ -40,18 +40,18 @@ public void RunAll()
private void EqualityOperator1()
{
foreach (var unit in equalityUnits)
foreach (var unit in _equalityUnits)
{
foreach (var value in unit.EqualValues)
{
Assert.True(compareWithEqualityOperator(unit.Value, value));
Assert.True(compareWithEqualityOperator(value, unit.Value));
Assert.True(_compareWithEqualityOperator(unit.Value, value));
Assert.True(_compareWithEqualityOperator(value, unit.Value));
}
foreach (var value in unit.NotEqualValues)
{
Assert.False(compareWithEqualityOperator(unit.Value, value));
Assert.False(compareWithEqualityOperator(value, unit.Value));
Assert.False(_compareWithEqualityOperator(unit.Value, value));
Assert.False(_compareWithEqualityOperator(value, unit.Value));
}
}
}
......@@ -63,27 +63,27 @@ private void EqualityOperator2()
return;
}
foreach (var value in equalityUnits.SelectMany(x => x.AllValues))
foreach (var value in _equalityUnits.SelectMany(x => x.AllValues))
{
Assert.False(compareWithEqualityOperator(default(T), value));
Assert.False(compareWithEqualityOperator(value, default(T)));
Assert.False(_compareWithEqualityOperator(default(T), value));
Assert.False(_compareWithEqualityOperator(value, default(T)));
}
}
private void InEqualityOperator1()
{
foreach (var unit in equalityUnits)
foreach (var unit in _equalityUnits)
{
foreach (var value in unit.EqualValues)
{
Assert.False(compareWithInequalityOperator(unit.Value, value));
Assert.False(compareWithInequalityOperator(value, unit.Value));
Assert.False(_compareWithInequalityOperator(unit.Value, value));
Assert.False(_compareWithInequalityOperator(value, unit.Value));
}
foreach (var value in unit.NotEqualValues)
{
Assert.True(compareWithInequalityOperator(unit.Value, value));
Assert.True(compareWithInequalityOperator(value, unit.Value));
Assert.True(_compareWithInequalityOperator(unit.Value, value));
Assert.True(_compareWithInequalityOperator(value, unit.Value));
}
}
}
......@@ -95,10 +95,10 @@ private void InEqualityOperator2()
return;
}
foreach (var value in equalityUnits.SelectMany(x => x.AllValues))
foreach (var value in _equalityUnits.SelectMany(x => x.AllValues))
{
Assert.True(compareWithInequalityOperator(default(T), value));
Assert.True(compareWithInequalityOperator(value, default(T)));
Assert.True(_compareWithInequalityOperator(default(T), value));
Assert.True(_compareWithInequalityOperator(value, default(T)));
}
}
......@@ -111,7 +111,7 @@ private void ImplementsIEquatable()
private void ObjectEquals1()
{
foreach (var unit in equalityUnits)
foreach (var unit in _equalityUnits)
{
var unitValue = unit.Value;
foreach (var value in unit.EqualValues)
......@@ -132,7 +132,7 @@ private void ObjectEquals2()
return;
}
var allValues = equalityUnits.SelectMany(x => x.AllValues);
var allValues = _equalityUnits.SelectMany(x => x.AllValues);
foreach (var value in allValues)
{
Assert.NotNull(value);
......@@ -144,7 +144,7 @@ private void ObjectEquals2()
/// </summary>
private void ObjectEquals3()
{
var allValues = equalityUnits.SelectMany(x => x.AllValues);
var allValues = _equalityUnits.SelectMany(x => x.AllValues);
foreach (var value in allValues)
{
Assert.NotEqual((object)42, value);
......@@ -153,7 +153,7 @@ private void ObjectEquals3()
private void GetHashCode1()
{
foreach (var unit in equalityUnits)
foreach (var unit in _equalityUnits)
{
foreach (var value in unit.EqualValues)
{
......@@ -164,7 +164,7 @@ private void GetHashCode1()
private void EquatableEquals1()
{
foreach (var unit in equalityUnits)
foreach (var unit in _equalityUnits)
{
var equatableUnit = (IEquatable<T>)unit.Value;
foreach (var value in unit.EqualValues)
......@@ -193,7 +193,7 @@ private void EquatableEquals2()
return;
}
foreach (var cur in equalityUnits.SelectMany(x => x.AllValues))
foreach (var cur in _equalityUnits.SelectMany(x => x.AllValues))
{
var value = (IEquatable<T>)cur;
Assert.NotNull(value);
......
......@@ -32,7 +32,7 @@ public static List<string> DiagnoseMefProblems()
{
var list = new List<string>();
var dllList = GetWellKnownDllsWithVersion().ToList();
foreach (var tuple in dllList)
foreach (var tuple in dllList)
{
if (tuple.Item3 == DllVersion.RC)
{
......
......@@ -14,8 +14,8 @@ namespace Roslyn.Test.Utilities
/// </summary>
public sealed class EventWaiter : IDisposable
{
private ManualResetEvent eventSignal = new ManualResetEvent(false);
private Exception capturedException;
private ManualResetEvent _eventSignal = new ManualResetEvent(false);
private Exception _capturedException;
/// <summary>
/// Returns the lambda given with method calls to this class inserted of the form:
......@@ -42,11 +42,11 @@ public EventHandler<T> Wrap<T>(EventHandler<T> input)
}
catch (Exception ex)
{
this.capturedException = ex;
_capturedException = ex;
}
finally
{
eventSignal.Set();
_eventSignal.Set();
}
};
}
......@@ -58,8 +58,8 @@ public EventHandler<T> Wrap<T>(EventHandler<T> input)
/// <returns></returns>
public bool WaitForEventToFire(TimeSpan timeout)
{
var result = eventSignal.WaitOne(timeout);
eventSignal.Reset();
var result = _eventSignal.WaitOne(timeout);
_eventSignal.Reset();
return result;
}
......@@ -70,8 +70,8 @@ public bool WaitForEventToFire(TimeSpan timeout)
/// <returns></returns>
public void WaitForEventToFire()
{
eventSignal.WaitOne();
eventSignal.Reset();
_eventSignal.WaitOne();
_eventSignal.Reset();
return;
}
......@@ -80,10 +80,10 @@ public void WaitForEventToFire()
/// </summary>
public void Dispose()
{
eventSignal.Dispose();
if (this.capturedException != null)
_eventSignal.Dispose();
if (_capturedException != null)
{
throw this.capturedException;
throw _capturedException;
}
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
extern alias PDB;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
......@@ -16,21 +15,21 @@ namespace Roslyn.Test.Utilities
{
internal sealed class ILBuilderVisualizer : ILVisualizer
{
private readonly ITokenDeferral tokenDeferral;
private readonly ITokenDeferral _tokenDeferral;
public ILBuilderVisualizer(ITokenDeferral tokenDeferral)
{
this.tokenDeferral = tokenDeferral;
_tokenDeferral = tokenDeferral;
}
public override string VisualizeUserString(uint token)
{
return "\"" + tokenDeferral.GetStringFromToken(token) + "\"";
return "\"" + _tokenDeferral.GetStringFromToken(token) + "\"";
}
public override string VisualizeSymbol(uint token)
{
Cci.IReference reference = tokenDeferral.GetReferenceFromToken(token);
Cci.IReference reference = _tokenDeferral.GetReferenceFromToken(token);
ISymbol symbol = reference as ISymbol;
return string.Format("\"{0}\"", symbol == null ? (object)reference : symbol.ToDisplayString(SymbolDisplayFormat.ILVisualizationFormat));
}
......
......@@ -40,7 +40,7 @@ public static class MarkupTestFile
private const string NamedSpanStartString = "{|";
private const string NamedSpanEndString = "|}";
private static readonly Regex NamedSpanStartRegex = new Regex(@"\{\| ([-_.A-Za-z0-9]+) \:",
private static readonly Regex s_namedSpanStartRegex = new Regex(@"\{\| ([-_.A-Za-z0-9]+) \:",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);
private static void Parse(string input, out string output, out int? position, out IDictionary<string, IList<TextSpan>> spans)
......@@ -70,7 +70,7 @@ private static void Parse(string input, out string output, out int? position, ou
AddMatch(input, SpanEndString, currentIndexInInput, matches);
AddMatch(input, NamedSpanEndString, currentIndexInInput, matches);
var namedSpanStartMatch = NamedSpanStartRegex.Match(input, currentIndexInInput);
var namedSpanStartMatch = s_namedSpanStartRegex.Match(input, currentIndexInInput);
if (namedSpanStartMatch.Success)
{
matches.Add(Tuple.Create(namedSpanStartMatch.Index, namedSpanStartMatch.Value));
......
......@@ -20,7 +20,7 @@ internal static IEnumerable<MetadataReference> CreateMetadataReferences(params o
if ((path = item as string) != null)
{
var kind = (string.Equals(Path.GetExtension(path), ".netmodule", StringComparison.OrdinalIgnoreCase)) ?
var kind = (string.Equals(Path.GetExtension(path), ".netmodule", StringComparison.OrdinalIgnoreCase)) ?
MetadataImageKind.Module : MetadataImageKind.Assembly;
yield return MetadataReference.CreateFromFile(path, new MetadataReferenceProperties(kind));
......
......@@ -77,7 +77,7 @@ internal static bool Requires64Bits(this PEHeaders headers)
}
public static string GetString(this MetadataReader[] readers, StringHandle handle)
{
{
int index = MetadataTokens.GetHeapOffset(handle);
foreach (var reader in readers)
{
......
......@@ -99,9 +99,9 @@ static private void AppendParameterInfo(ParameterInfo parameter, StringBuilder s
foreach (var attribute in parameter.GetCustomAttributesData())
{
// these are pseudo-custom attributes that are added by Reflection but don't appear in metadata as custom attributes:
if (attribute.AttributeType != typeof(OptionalAttribute) &&
attribute.AttributeType != typeof(InAttribute) &&
attribute.AttributeType != typeof(OutAttribute) &&
if (attribute.AttributeType != typeof(OptionalAttribute) &&
attribute.AttributeType != typeof(InAttribute) &&
attribute.AttributeType != typeof(OutAttribute) &&
attribute.AttributeType != typeof(MarshalAsAttribute))
{
AppendCustomAttributeData(attribute, sb);
......@@ -220,7 +220,7 @@ public static StringBuilder AppendFieldAttributes(StringBuilder sb, FieldAttribu
if ((attributes & FieldAttributes.HasDefault) != 0) sb.Append(" default");
if ((attributes & FieldAttributes.HasFieldRVA) != 0) sb.Append(" rva");
}
return sb;
}
......@@ -254,8 +254,8 @@ public static StringBuilder AppendMethodAttributes(StringBuilder sb, MethodAttri
if ((attributes & MethodAttributes.Virtual) != 0) sb.Append(" virtual");
if ((attributes & MethodAttributes.Final) != 0) sb.Append(" final");
sb.Append((attributes & MethodAttributes.Static) != 0 ? " static" : " instance");
sb.Append((attributes & MethodAttributes.Static) != 0 ? " static" : " instance");
if (all)
{
if ((attributes & MethodAttributes.PinvokeImpl) != 0) sb.Append(" pinvokeimpl");
......@@ -276,7 +276,7 @@ public static StringBuilder AppendMethodImplAttributes(StringBuilder sb, MethodI
default:
throw new InvalidOperationException();
}
}
sb.Append(codeType);
sb.Append(" ");
......@@ -292,7 +292,7 @@ public static StringBuilder AppendMethodImplAttributes(StringBuilder sb, MethodI
return sb;
}
public static StringBuilder AppendTypeAttributes(StringBuilder sb, TypeAttributes attributes)
{
string visibility;
......@@ -351,7 +351,7 @@ public static StringBuilder AppendTypeAttributes(StringBuilder sb, TypeAttribute
if ((attributes & TypeAttributes.BeforeFieldInit) != 0) sb.Append(" beforefieldinit");
if ((attributes & TypeAttributes.SpecialName) != 0) sb.Append(" specialname");
if ((attributes & TypeAttributes.RTSpecialName) != 0) sb.Append(" rtspecialname");
return sb;
}
......@@ -581,7 +581,7 @@ static public IEnumerable<string> GetMemberSignatures(System.Reflection.Assembly
var type = assembly.GetType(fullyQualifiedTypeName);
if (type != null)
{
foreach (var constructor in type.GetConstructors(BINDING_FLAGS).OrderBy((member)=>member.Name))
foreach (var constructor in type.GetConstructors(BINDING_FLAGS).OrderBy((member) => member.Name))
{
AppendConstructorInfo(constructor, sb);
candidates.Add(sb.ToString());
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
extern alias PDB;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using Microsoft.CodeAnalysis.Emit;
......@@ -8,7 +7,7 @@
namespace Roslyn.Test.Utilities
{
static class PdbTestUtilities
internal static class PdbTestUtilities
{
public static EditAndContinueMethodDebugInformation GetEncMethodDebugInfo(this ISymUnmanagedReader symReader, MethodDefinitionHandle handle)
{
......
......@@ -9,22 +9,22 @@ namespace Roslyn.Test.Utilities
{
internal class PinnedMetadata : IDisposable
{
private GCHandle bytes; // non-readonly as Free() mutates to prevent double-free.
private GCHandle _bytes; // non-readonly as Free() mutates to prevent double-free.
public readonly MetadataReader Reader;
public readonly IntPtr Pointer;
public readonly int Size;
public unsafe PinnedMetadata(ImmutableArray<byte> metadata)
{
this.bytes = GCHandle.Alloc(metadata.DangerousGetUnderlyingArray(), GCHandleType.Pinned);
this.Pointer = this.bytes.AddrOfPinnedObject();
_bytes = GCHandle.Alloc(metadata.DangerousGetUnderlyingArray(), GCHandleType.Pinned);
this.Pointer = _bytes.AddrOfPinnedObject();
this.Size = metadata.Length;
this.Reader = new MetadataReader((byte*)this.Pointer, this.Size, MetadataReaderOptions.None, null);
}
public void Dispose()
{
bytes.Free();
_bytes.Free();
}
}
}
......@@ -17,15 +17,15 @@ public static ProcessResult Run(string fileName, string arguments, string workin
if (fileName == null) throw new ArgumentNullException("fileName");
var startInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = arguments,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = workingDirectory
};
{
FileName = fileName,
Arguments = arguments,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = workingDirectory
};
if (additionalEnvironmentVars != null)
{
......@@ -39,15 +39,15 @@ public static ProcessResult Run(string fileName, string arguments, string workin
{
StringBuilder outputBuilder = new StringBuilder();
StringBuilder errorBuilder = new StringBuilder();
process.OutputDataReceived += (sender, args) =>
{
process.OutputDataReceived += (sender, args) =>
{
if (args.Data != null)
outputBuilder.AppendLine(args.Data);
outputBuilder.AppendLine(args.Data);
};
process.ErrorDataReceived += (sender, args) =>
{
process.ErrorDataReceived += (sender, args) =>
{
if (args.Data != null)
errorBuilder.AppendLine(args.Data);
errorBuilder.AppendLine(args.Data);
};
process.Start();
......
......@@ -19,8 +19,6 @@ public ProcessResult(int exitCode, string output, string errors)
ExitCode = exitCode;
Output = output;
Errors = errors;
}
public override string ToString()
......
......@@ -54,7 +54,7 @@ internal static CompilationTestData.MethodData GetMethodData(this CompilationTes
}
internal static void VerifyIL(
this CompilationTestData.MethodData method,
this CompilationTestData.MethodData method,
string expectedIL,
[CallerLineNumber]int expectedValueSourceLine = 0,
[CallerFilePath]string expectedValueSourcePath = null)
......@@ -276,11 +276,8 @@ public static void CleanupAllGeneratedFiles(string filename)
{
// Swallow any exceptions as the cleanup should not necessarily block the test
}
}
}
}
}
}
......@@ -19,7 +19,7 @@ internal static class SigningTestHelpers
internal static string KeyPairFile2 = @"R:\__Test__\KeyPair2_" + Guid.NewGuid() + ".snk";
internal static string PublicKeyFile2 = @"R:\__Test__\PublicKey2_" + Guid.NewGuid() + ".snk";
private static bool keyInstalled;
private static bool s_keyInstalled;
internal const string TestContainerName = "RoslynTestContainer";
internal static readonly ImmutableArray<byte> PublicKey = new DesktopStrongNameProvider().GetPublicKey(TestResources.SymbolsTests.General.snKey);
......@@ -27,10 +27,10 @@ internal static class SigningTestHelpers
// Modifies machine wide state.
internal unsafe static void InstallKey()
{
if (!keyInstalled)
if (!s_keyInstalled)
{
InstallKey(TestResources.SymbolsTests.General.snKey, TestContainerName);
keyInstalled = true;
s_keyInstalled = true;
}
}
......@@ -63,7 +63,7 @@ public VirtualizedStrongNameProvider(ImmutableArray<string> searchPaths)
private static bool PathEquals(string left, string right)
{
return string.Equals(FileUtilities.NormalizeAbsolutePath(left), FileUtilities.NormalizeAbsolutePath(right), StringComparison.OrdinalIgnoreCase);
}
}
internal override bool FileExists(string fullPath)
{
......
......@@ -28,7 +28,7 @@ public SourceWithMarkedNodes(string markedSource, Func<string, SyntaxTree> parse
private static IEnumerable<ValueTuple<TextSpan, int>> GetSpansRecursive(string markedSource, int offset, Func<string, int> getSyntaxKind)
{
foreach (var match in MarkerPattern.Matches(markedSource).ToEnumerable())
foreach (var match in s_markerPattern.Matches(markedSource).ToEnumerable())
{
var markedSyntax = match.Groups["MarkedSyntax"];
var syntaxKindOpt = match.Groups["SyntaxKind"].Value;
......@@ -42,18 +42,18 @@ public SourceWithMarkedNodes(string markedSource, Func<string, SyntaxTree> parse
yield return nestedSpan;
}
}
}
}
internal static string ClearTags(string source)
{
return Tags.Replace(source, m => new string(' ', m.Length));
return s_tags.Replace(source, m => new string(' ', m.Length));
}
private static readonly Regex Tags = new Regex(
private static readonly Regex s_tags = new Regex(
@"[<][/]?N[:][:A-Za-z0-9]+[>]",
RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
private static readonly Regex MarkerPattern = new Regex(
private static readonly Regex s_markerPattern = new Regex(
@"[<]N[:] (?<Id>[0-9]+) ([:](?<SyntaxKind>[A-Za-z]+))? [>]
(?<MarkedSyntax>.*)
[<][/]N[:](\k<Id>) [>]",
......
......@@ -8,10 +8,10 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
{
public class TempDirectory
{
private readonly string path;
private readonly TempRoot root;
private readonly string _path;
private readonly TempRoot _root;
protected TempDirectory(TempRoot root)
protected TempDirectory(TempRoot root)
: this(CreateUniqueDirectory(TempRoot.Root), root)
{
}
......@@ -21,8 +21,8 @@ private TempDirectory(string path, TempRoot root)
Debug.Assert(path != null);
Debug.Assert(root != null);
this.path = path;
this.root = root;
_path = path;
_root = root;
}
private static string CreateUniqueDirectory(string basePath)
......@@ -44,7 +44,7 @@ private static string CreateUniqueDirectory(string basePath)
public string Path
{
get { return path; }
get { return _path; }
}
/// <summary>
......@@ -53,9 +53,9 @@ public string Path
/// <param name="name">File name.</param>
public TempFile CreateFile(string name)
{
string filePath = System.IO.Path.Combine(path, name);
string filePath = System.IO.Path.Combine(_path, name);
TempRoot.CreateStream(filePath);
return root.AddFile(new DisposableFile(filePath));
return _root.AddFile(new DisposableFile(filePath));
}
/// <summary>
......@@ -64,14 +64,14 @@ public TempFile CreateFile(string name)
/// <param name="name">Directory name or unrooted directory path.</param>
public TempDirectory CreateDirectory(string name)
{
string dirPath = System.IO.Path.Combine(path, name);
string dirPath = System.IO.Path.Combine(_path, name);
Directory.CreateDirectory(dirPath);
return new TempDirectory(dirPath, root);
return new TempDirectory(dirPath, _root);
}
public override string ToString()
{
return path;
return _path;
}
}
}
......@@ -14,12 +14,12 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
{
public class TempFile
{
private readonly string path;
private readonly string _path;
internal TempFile(string path)
{
Debug.Assert(PathUtilities.IsAbsolute(path));
this.path = path;
_path = path;
}
internal TempFile(string prefix, string extension, string directory, string callerSourcePath, int callerLineNumber)
......@@ -31,11 +31,11 @@ internal TempFile(string prefix, string extension, string directory, string call
prefix = System.IO.Path.GetFileName(callerSourcePath) + "_" + callerLineNumber.ToString() + "_";
}
path = System.IO.Path.Combine(directory ?? TempRoot.Root, prefix + Guid.NewGuid() + (extension ?? ".tmp"));
_path = System.IO.Path.Combine(directory ?? TempRoot.Root, prefix + Guid.NewGuid() + (extension ?? ".tmp"));
try
{
TempRoot.CreateStream(path);
TempRoot.CreateStream(_path);
break;
}
catch (PathTooLongException)
......@@ -55,29 +55,29 @@ internal TempFile(string prefix, string extension, string directory, string call
public FileStream Open(FileAccess access = FileAccess.ReadWrite)
{
return new FileStream(path, FileMode.Open, access);
return new FileStream(_path, FileMode.Open, access);
}
public string Path
{
get { return path; }
get { return _path; }
}
public TempFile WriteAllText(string content, Encoding encoding)
{
File.WriteAllText(path, content, encoding);
File.WriteAllText(_path, content, encoding);
return this;
}
public TempFile WriteAllText(string content)
{
File.WriteAllText(path, content);
File.WriteAllText(_path, content);
return this;
}
public async Task<TempFile> WriteAllTextAsync(string content, Encoding encoding)
{
using (var sw = new StreamWriter(File.Create(path), encoding))
using (var sw = new StreamWriter(File.Create(_path), encoding))
{
await sw.WriteAsync(content).ConfigureAwait(false);
}
......@@ -92,19 +92,19 @@ public Task<TempFile> WriteAllTextAsync(string content)
public TempFile WriteAllBytes(byte[] content)
{
File.WriteAllBytes(path, content);
File.WriteAllBytes(_path, content);
return this;
}
public TempFile WriteAllBytes(ImmutableArray<byte> content)
{
content.WriteToFile(path);
content.WriteToFile(_path);
return this;
}
public string ReadAllText()
{
return File.ReadAllText(path);
return File.ReadAllText(_path);
}
public TempFile CopyContentFrom(string path)
......@@ -114,7 +114,7 @@ public TempFile CopyContentFrom(string path)
public override string ToString()
{
return path;
return _path;
}
}
}
......@@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
{
public sealed class TempRoot : IDisposable
{
private readonly List<IDisposable> temps = new List<IDisposable>();
private readonly List<IDisposable> _temps = new List<IDisposable>();
public static readonly string Root;
static TempRoot()
......@@ -20,10 +20,10 @@ static TempRoot()
public void Dispose()
{
if (temps != null)
if (_temps != null)
{
DisposeAll(temps);
temps.Clear();
DisposeAll(_temps);
_temps.Clear();
}
}
......@@ -48,7 +48,7 @@ private static void DisposeAll(IEnumerable<IDisposable> temps)
public TempDirectory CreateDirectory()
{
var dir = new DisposableDirectory(this);
temps.Add(dir);
_temps.Add(dir);
return dir;
}
......@@ -59,7 +59,7 @@ public TempFile CreateFile(string prefix = null, string extension = null, string
public DisposableFile AddFile(DisposableFile file)
{
temps.Add(file);
_temps.Add(file);
return file;
}
......
此差异已折叠。
......@@ -9,21 +9,21 @@ namespace Roslyn.Test.Utilities
{
public class TestMetadataReference : PortableExecutableReference
{
private readonly Metadata metadata;
private readonly string display;
private readonly Metadata _metadata;
private readonly string _display;
public TestMetadataReference(Metadata metadata = null, string fullPath = null, string display = null)
: base(MetadataReferenceProperties.Assembly, fullPath)
{
this.metadata = metadata;
this.display = display;
_metadata = metadata;
_display = display;
}
public override string Display
{
get
{
return display;
return _display;
}
}
......@@ -34,12 +34,12 @@ protected override DocumentationProvider CreateDocumentationProvider()
protected override Metadata GetMetadataImpl()
{
if (metadata == null)
if (_metadata == null)
{
throw new FileNotFoundException();
}
return metadata;
return _metadata;
}
protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties)
......@@ -50,8 +50,8 @@ protected override PortableExecutableReference WithPropertiesImpl(MetadataRefere
public class TestImageReference : PortableExecutableReference
{
private readonly ImmutableArray<byte> metadataBytes;
private readonly string display;
private readonly ImmutableArray<byte> _metadataBytes;
private readonly string _display;
public TestImageReference(byte[] metadataBytes, string display)
: this(ImmutableArray.Create(metadataBytes), display)
......@@ -61,15 +61,15 @@ public TestImageReference(byte[] metadataBytes, string display)
public TestImageReference(ImmutableArray<byte> metadataBytes, string display)
: base(MetadataReferenceProperties.Assembly)
{
this.metadataBytes = metadataBytes;
this.display = display;
_metadataBytes = metadataBytes;
_display = display;
}
public override string Display
{
get
{
return display;
return _display;
}
}
......@@ -80,7 +80,7 @@ protected override DocumentationProvider CreateDocumentationProvider()
protected override Metadata GetMetadataImpl()
{
return AssemblyMetadata.CreateFromImage(metadataBytes);
return AssemblyMetadata.CreateFromImage(_metadataBytes);
}
protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties)
......
......@@ -23,13 +23,13 @@ public TestMetadataReferenceResolver()
internal class MappingReferenceResolver : TestMetadataReferenceResolver
{
private readonly Dictionary<string, string> assemblyNames;
private readonly Dictionary<string, string> files;
private readonly Dictionary<string, string> _assemblyNames;
private readonly Dictionary<string, string> _files;
public MappingReferenceResolver(Dictionary<string, string> assemblyNames = null, Dictionary<string, string> files = null)
{
this.assemblyNames = assemblyNames;
this.files = files;
_assemblyNames = assemblyNames;
_files = files;
}
public override string ResolveReference(string reference, string baseFilePath)
......@@ -42,32 +42,32 @@ public override string ResolveReference(string reference, string baseFilePath)
}
string result;
return files != null && files.TryGetValue(reference, out result) ? result : null;
return _files != null && _files.TryGetValue(reference, out result) ? result : null;
}
else
{
string result;
return assemblyNames != null && assemblyNames.TryGetValue(reference, out result) ? result : null;
return _assemblyNames != null && _assemblyNames.TryGetValue(reference, out result) ? result : null;
}
}
}
internal class VirtualizedFileReferenceResolver : MetadataFileReferenceResolver
{
private readonly HashSet<string> existingFullPaths;
private readonly HashSet<string> _existingFullPaths;
public VirtualizedFileReferenceResolver(
IEnumerable<string> existingFullPaths = null,
IEnumerable<string> existingFullPaths = null,
string baseDirectory = null,
ImmutableArray<string> searchPaths = default(ImmutableArray<string>))
: base(searchPaths.NullToEmpty(), baseDirectory)
{
this.existingFullPaths = new HashSet<string>(existingFullPaths, StringComparer.OrdinalIgnoreCase);
_existingFullPaths = new HashSet<string>(existingFullPaths, StringComparer.OrdinalIgnoreCase);
}
protected override bool FileExists(string fullPath)
{
return fullPath != null && existingFullPaths != null && existingFullPaths.Contains(FileUtilities.NormalizeAbsolutePath(fullPath));
return fullPath != null && _existingFullPaths != null && _existingFullPaths.Contains(FileUtilities.NormalizeAbsolutePath(fullPath));
}
}
}
......@@ -7,20 +7,20 @@ namespace Roslyn.Test.Utilities
{
public class TestStream : Stream
{
private readonly bool canRead, canSeek, canWrite;
private readonly bool _canRead,_canSeek,_canWrite;
public TestStream(bool canRead = false, bool canSeek = false, bool canWrite = false)
{
this.canRead = canRead;
this.canSeek = canSeek;
this.canWrite = canWrite;
_canRead = canRead;
_canSeek = canSeek;
_canWrite = canWrite;
}
public override bool CanRead
{
get
{
return canRead;
return _canRead;
}
}
......@@ -28,7 +28,7 @@ public override bool CanSeek
{
get
{
return canSeek;
return _canSeek;
}
}
......@@ -36,7 +36,7 @@ public override bool CanWrite
{
get
{
return canWrite;
return _canWrite;
}
}
......
......@@ -22,7 +22,7 @@ namespace Microsoft.CodeAnalysis
// </configuration>
public sealed class TraceListener : System.Diagnostics.TraceListener
{
private readonly bool continueOnFailure;
private readonly bool _continueOnFailure;
public TraceListener()
{
......@@ -30,7 +30,7 @@ public TraceListener()
public TraceListener(bool continueOnFailure)
{
this.continueOnFailure = continueOnFailure;
_continueOnFailure = continueOnFailure;
}
public override void Fail(string message, string detailMessage)
......@@ -38,7 +38,7 @@ public override void Fail(string message, string detailMessage)
// Tools currently depend on the prefix appearing as an exception.
WriteLine(new AssertFailureException(string.Format("{0}\r\n{1}", message, detailMessage)));
WriteLine(new StackTrace(fNeedFileInfo: true));
if (!this.continueOnFailure)
if (!_continueOnFailure)
{
Environment.Exit(-1);
}
......
......@@ -13,13 +13,13 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
public class Win32Res
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr FindResource(IntPtr hModule, string lpName, string lpType);
private static extern IntPtr FindResource(IntPtr hModule, string lpName, string lpType);
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr LoadResource(IntPtr hModule, IntPtr hResInfo);
private static extern IntPtr LoadResource(IntPtr hModule, IntPtr hResInfo);
[DllImport("kernel32.dll")]
static extern IntPtr LockResource(IntPtr hResData);
private static extern IntPtr LockResource(IntPtr hResData);
[DllImport("kernel32.dll", SetLastError = true)]
static extern uint SizeofResource(IntPtr hModule, IntPtr hResInfo);
private static extern uint SizeofResource(IntPtr hModule, IntPtr hResInfo);
public static IntPtr GetResource(IntPtr lib, string resourceId, string resourceType, out uint size)
{
......@@ -232,7 +232,7 @@ public static string VersionResourceToXml(IntPtr versionRsrc)
return sw.ToString();
}
static Tuple<string, string> GetVerStringPair(BinaryReader reader)
private static Tuple<string, string> GetVerStringPair(BinaryReader reader)
{
System.Diagnostics.Debug.Assert((reader.BaseStream.Position & 3) == 0);
long startPos = reader.BaseStream.Position;
......
......@@ -11,17 +11,17 @@ namespace Roslyn.Test.Utilities
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public sealed class WorkItemAttribute : Attribute
{
private readonly int id;
private readonly string description;
private readonly int _id;
private readonly string _description;
public int Id
{
get { return id; }
get { return _id; }
}
public string Description
{
get { return description; }
get { return _description; }
}
public WorkItemAttribute(int id)
......@@ -31,8 +31,8 @@ public WorkItemAttribute(int id)
public WorkItemAttribute(int id, string description)
{
this.id = id;
this.description = description;
_id = id;
_description = description;
}
}
}
......@@ -51,7 +51,7 @@ public int GetHashCode(XElement element)
/// Compare two XElements. Assumed to be non-null.
/// </summary>
public static void AssertEqual(
XElement expectedRoot,
XElement expectedRoot,
XElement actualRoot,
string expectedValueSourcePath,
int expectedValueSourceLine,
......@@ -85,10 +85,10 @@ private static string GetXmlString(XElement node, bool expectedIsXmlLiteral)
/// Helpful diff output message. Can be printed as either an XML literal (VB) or a string literal (C#).
/// </summary>
private static string GetAssertText(
string expected,
string expected,
string actual,
XElement expectedRoot,
Tuple<XElement, XElement> firstMismatch,
XElement expectedRoot,
Tuple<XElement, XElement> firstMismatch,
string expectedValueSourcePath,
int expectedValueSourceLine,
bool expectedIsXmlLiteral)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册