Skip to content

Commit

Permalink
Merge branch 'develop' into #264_nuget_spec_deprecation_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
csoltenborn committed Apr 28, 2019
2 parents b69853b + 15d479c commit 3314e5b
Show file tree
Hide file tree
Showing 232 changed files with 7,441 additions and 2,820 deletions.
3 changes: 0 additions & 3 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 2 additions & 0 deletions GoogleTestAdapter/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<Reference Include="System.ServiceModel" />
</ItemGroup>
<ItemGroup>
<Compile Include="EnumConverterBase.cs" />
<Compile Include="ProcessUtils.cs" />
<Compile Include="DebuggerAttacherServiceConfiguration.cs" />
<Compile Include="Functional.cs" />
Expand All @@ -61,6 +62,7 @@
<Compile Include="ProcessWaiter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Strings.cs" />
<Compile Include="SummaryMode.cs" />
<Compile Include="Win32Utils.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
64 changes: 64 additions & 0 deletions GoogleTestAdapter/Common/EnumConverterBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;

namespace GoogleTestAdapter.Common
{
public abstract class EnumConverterBase<TEnum> : EnumConverter
{
private readonly IDictionary<TEnum, string> _stringMap;

protected EnumConverterBase(IDictionary<TEnum, string> stringMap) : base(typeof(TEnum))
{
if (stringMap == null)
throw new ArgumentNullException(nameof(stringMap));

if (stringMap.Count != Enum.GetValues(typeof(TEnum)).Length)
throw new ArgumentException(nameof(stringMap), "Map must have the same size as the enum");

if (stringMap.Values.Distinct().Count() != stringMap.Values.Count)
throw new ArgumentException(nameof(stringMap), "Values of map must be pairwise distinct strings");

_stringMap = stringMap;
}

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(TEnum) ||
base.CanConvertFrom(context, sourceType);
}

public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string) ||
base.CanConvertTo(context, destinationType);
}

public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string valueString)
{
foreach (KeyValuePair<TEnum, string> kvp in _stringMap)
{
if (kvp.Value == valueString)
return kvp.Key;
}
}

return base.ConvertFrom(context, culture, value);
}

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (!(value is TEnum enumLiteral) || destinationType != typeof(string))
return base.ConvertTo(context, culture, value, destinationType);

if (_stringMap.TryGetValue(enumLiteral, out string stringValue))
return stringValue;

return base.ConvertTo(context, culture, value, destinationType);
}
}
}
9 changes: 8 additions & 1 deletion GoogleTestAdapter/Common/IDebuggerAttacherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

namespace GoogleTestAdapter.Common
{
public enum DebuggerEngine
{
Native, ManagedAndNative
}


/// <summary>
/// Interface of DebuggerAttacherService.
/// </summary>
Expand All @@ -17,9 +23,10 @@ public interface IDebuggerAttacherService
/// Attaches the debugger to the specified process.
/// </summary>
/// <param name="processId">ID of a process to attach to</param>
/// <param name="debuggerEngine">Engine kind to be attached</param>
[OperationContract]
[FaultContract(typeof(DebuggerAttacherServiceFault))]
void AttachDebugger(int processId);
void AttachDebugger(int processId, DebuggerEngine debuggerEngine);
}

/// <summary>
Expand Down
37 changes: 37 additions & 0 deletions GoogleTestAdapter/Common/ILogger.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
using System.Collections.Generic;
using System.ComponentModel;

namespace GoogleTestAdapter.Common
{

public enum Severity { Info, Warning, Error }
public enum OutputMode { None = 0, Info = 10, Debug = 20, Verbose = 30 }

[TypeConverter(typeof(TimestampModeConverter))]
public enum TimestampMode { Automatic, PrintTimestamp, DoNotPrintTimestamp }

[TypeConverter(typeof(SeverityModeConverter))]
public enum SeverityMode { Automatic, PrintSeverity, DoNotPrintSeverity }

public interface ILogger
{
Expand All @@ -13,9 +21,38 @@ public interface ILogger
void DebugInfo(string message);
void DebugWarning(string message);
void DebugError(string message);
void VerboseInfo(string message);

IList<string> GetMessages(params Severity[] severities);

}

public class TimestampModeConverter : EnumConverterBase<TimestampMode>
{
public const string Automatic = "Automatic";
public const string PrintTimeStamp = "Print timestamp";
public const string DoNotPrintTimeStamp = "Do not print timestamp";

public TimestampModeConverter() : base(new Dictionary<TimestampMode, string>
{
{TimestampMode.Automatic, Automatic},
{TimestampMode.PrintTimestamp, PrintTimeStamp},
{TimestampMode.DoNotPrintTimestamp, DoNotPrintTimeStamp}
}){}
}

public class SeverityModeConverter : EnumConverterBase<SeverityMode>
{
public const string Automatic = "Automatic";
public const string PrintSeverity = "Print severity";
public const string DoNotPrintSeverity = "Do not print severity";

public SeverityModeConverter() : base(new Dictionary<SeverityMode, string>
{
{SeverityMode.Automatic, Automatic},
{SeverityMode.PrintSeverity, PrintSeverity},
{SeverityMode.DoNotPrintSeverity, DoNotPrintSeverity}
}){}
}

}
33 changes: 21 additions & 12 deletions GoogleTestAdapter/Common/LoggerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ protected class LogEntry

private readonly IList<LogEntry> _messages = new List<LogEntry>();

private readonly Func<bool> _inDebugMode;
private readonly Func<OutputMode> _outputMode;

protected LoggerBase(Func<bool> inDebugMode)
protected LoggerBase(Func<OutputMode> outputMode)
{
_inDebugMode = inDebugMode;
_outputMode = outputMode;
}

public abstract void Log(Severity severity, string message);
Expand All @@ -45,35 +45,44 @@ public IList<string> GetMessages(params Severity[] severities)

public virtual void LogInfo(string message)
{
Log(Severity.Info, message);
if (_outputMode() >= OutputMode.Info)
Log(Severity.Info, message);
}

public virtual void LogWarning(string message)
{
Log(Severity.Warning, message);
if (_outputMode() >= OutputMode.Info)
Log(Severity.Warning, message);
}

public virtual void LogError(string message)
{
Log(Severity.Error, message);
if (_outputMode() >= OutputMode.Info)
Log(Severity.Error, message);
}

public void DebugInfo(string message)
{
if (_inDebugMode())
LogInfo(message);
if (_outputMode() >= OutputMode.Debug)
Log(Severity.Info, message);
}

public void DebugWarning(string message)
{
if (_inDebugMode())
LogWarning(message);
if (_outputMode() >= OutputMode.Debug)
Log(Severity.Warning, message);
}

public void DebugError(string message)
{
if (_inDebugMode())
LogError(message);
if (_outputMode() >= OutputMode.Debug)
Log(Severity.Error, message);
}

public void VerboseInfo(string message)
{
if (_outputMode() >= OutputMode.Verbose)
Log(Severity.Info, message);
}
}

Expand Down
3 changes: 1 addition & 2 deletions GoogleTestAdapter/Common/ProcessWaiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public int WaitForExit()

private void OnExited(object sender, EventArgs e)
{
var process = sender as Process;
if (process != null)
if (sender is Process process)
{
lock (this)
{
Expand Down
28 changes: 28 additions & 0 deletions GoogleTestAdapter/Common/SummaryMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.ComponentModel;

namespace GoogleTestAdapter.Common
{
[TypeConverter(typeof(SummaryModeConverter))]
public enum SummaryMode
{
Never,
Error,
WarningOrError
}

public class SummaryModeConverter : EnumConverterBase<SummaryMode>
{
public const string Never = "Never";
public const string Error = "If errors occured";
public const string WarningOrError = "If warnings or errors occured";

public SummaryModeConverter() : base(new Dictionary<SummaryMode, string>
{
{ SummaryMode.Never, Never},
{ SummaryMode.Error, Error},
{ SummaryMode.WarningOrError, WarningOrError},
}) {}
}

}
1 change: 0 additions & 1 deletion GoogleTestAdapter/Core.Tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
app.config
Key.snk
32 changes: 19 additions & 13 deletions GoogleTestAdapter/Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -40,26 +42,30 @@
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="FluentAssertions, Version=5.4.2.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\FluentAssertions.5.4.2\lib\net45\FluentAssertions.dll</HintPath>
<Reference Include="FluentAssertions, Version=5.6.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\FluentAssertions.5.6.0\lib\net45\FluentAssertions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq, Version=4.10.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\Moq.4.10.0\lib\net45\Moq.dll</HintPath>
<HintPath>..\..\NuGetPackages\Moq.4.10.1\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Threading.Tasks.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\System.Threading.Tasks.Extensions.4.5.2\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\NuGetPackages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
Expand Down Expand Up @@ -92,13 +98,17 @@
<Compile Include="Helpers\ByteUtilsTests.cs" />
<Compile Include="Helpers\UtilsTests.cs" />
<Compile Include="Runners\CommandLineGeneratorTests.cs" />
<Compile Include="Runners\DebuggerKindConverterTests.cs" />
<Compile Include="Runners\SequentialTestRunnerTests.cs" />
<Compile Include="Settings\HelperFilesCacheTests.cs" />
<Compile Include="Settings\PlaceholderReplacerTests.cs" />
<Compile Include="TestCases\TestCaseResolverTests.cs" />
<Compile Include="TestCases\TestCaseFactoryTests.cs" />
<Compile Include="TestCases\ListTestsParserTests.cs" />
<Compile Include="TestResults\ExitCodeTestsReporterTests.cs" />
<Compile Include="TestResults\StreamingStandardOutputTestResultParserTests.cs" />
<Compile Include="TestResults\StandardOutputTestResultParserTests.cs" />
<Compile Include="TestResults\ErrorMessageParserTests.cs" />
<Compile Include="TestResults\ExitCodeTestsAggregatorTests.cs" />
<Compile Include="TestResults\XmlTestResultParserTests.cs" />
<Compile Include="Scheduling\DurationBasedTestsSplitterTests.cs" />
<Compile Include="Scheduling\NumberBasedTestsSplitterTests.cs" />
Expand All @@ -108,7 +118,6 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Key.snk" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
Expand All @@ -131,9 +140,6 @@
<Name>Tests.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\..\NuGetPackages\FluentAssertions.Analyzers.0.11.4\analyzers\dotnet\cs\FluentAssertions.Analyzers.dll" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
Loading

0 comments on commit 3314e5b

Please sign in to comment.