Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

a number of fixes #546

Merged
merged 5 commits into from
Feb 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ environment:
secure: +9YfPnwJzGsvdyto85pHwg==
SONARQUBE_PASSWORD:
secure: Ptvd9aDNKfVhXvPpq6o1Fw==
DRDUMP_TOKEN:
secure: 16PEs46poxfT7drt6BdHSHPPzAymXBYrIaqoAsHvY49os5Azz4rNTp3QaUhtITZ+
cache:
- build/Version/opencover.snk
- build/Version/opencover.public.snk
Expand Down
3 changes: 3 additions & 0 deletions build/Version/AssemblyCopyright.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Reflection;

[assembly: AssemblyCopyright("Copyright � OpenCover 2011, 2012, 2013, 2014, 2015, 2016")]
6 changes: 6 additions & 0 deletions build/Version/AssemblyCopyright.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
using System.Reflection;

[assembly: AssemblyCopyright("Copyright � OpenCover <#= string.Join(", ", Enumerable.Range(2011, (DateTime.UtcNow.Year - 2011) + 1).Select(y => y.ToString())) #>")]
2 changes: 1 addition & 1 deletion build/Version/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyCompany("OpenCover")]
[assembly: AssemblyCopyright("Copyright � OpenCover 2011-2099")]
[assembly: AssemblyTrademark("")]

16 changes: 14 additions & 2 deletions default.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<property name="buildnumber.build" value="${ci.buildNumber}" />
<property name="buildnumber.revision" value="0" />
<property name="buildnumber.version" value="${buildnumber.major}.${buildnumber.minor}.${buildnumber.build}.${buildnumber.revision}" />

<loadtasks assembly="${build.folder}/nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />

<include buildfile="${build.folder}/version.build" />
Expand Down Expand Up @@ -61,7 +61,7 @@
tofile="${solution.folder}/bin/zip/opencover.${buildnumber.major}.${buildnumber.minor}.${buildnumber.build}.zip" />
</target>

<target name="create-release" depends="clean-all, build-environment, build-release-platforms, test, test-cpp, create-zip-package">
<target name="create-release" depends="clean-all, build-environment, replace-drdump-token, build-release-platforms, test, test-cpp, create-zip-package">
<call target="nuget-package" />
<call target="set-rc-property" />
<call target="nuget-package" />
Expand Down Expand Up @@ -154,6 +154,18 @@
</copy>
</target>

<target name="replace-drdump-token" if="${environment::variable-exists('DRDUMP_TOKEN')}" >
<property name="drdump.token" value="${environment::get-variable('DRDUMP_TOKEN')}" />

<copy file="main\OpenCover.Console\Program.cs" tofile="main\OpenCover.Console\Program.cx" overwrite="true" >
<filterchain>
<replacestring from="dbbb1d35-be49-45e2-b81d-84f1042c455d" to="${drdump.token}" />
</filterchain>
</copy>
<copy file="main\OpenCover.Console\Program.cx" tofile="main\OpenCover.Console\Program.cs" overwrite="true" />
<delete file="main\OpenCover.Console\Program.cx" />
</target>

<target name="prepare-sample-project" depends="get-version-number" >
<delete file="samples\SampleSln\coverage.bat" />
<copy file="samples\SampleSln\coverage.bat.tmp" tofile="samples\SampleSln\coverage.bat" >
Expand Down
15 changes: 14 additions & 1 deletion main/OpenCover.Console/OpenCover.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\build\Version\AssemblyCopyright.cs">
<Link>Properties\AssemblyCopyright.cs</Link>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AssemblyCopyright.tt</DependentUpon>
</Compile>
<Compile Include="..\..\build\Version\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
Expand All @@ -110,6 +116,11 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\build\Version\AssemblyCopyright.tt">
<Link>Properties\AssemblyCopyright.tt</Link>
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AssemblyCopyright.cs</LastGenOutput>
</Content>
<Content Include="..\OpenCover.Framework\log4net.config">
<Link>log4net.config</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down Expand Up @@ -150,7 +161,9 @@
<Link>Icon.ico</Link>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
12 changes: 6 additions & 6 deletions main/OpenCover.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Authentication;
using System.Security.Principal;
using System.ServiceProcess;
using CrashReporterDotNET.com.drdump;
Expand Down Expand Up @@ -40,7 +39,7 @@ static int Main(string[] args)
{
var returnCode = 0;
var returnCodeOffset = 0;

AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

try
Expand Down Expand Up @@ -72,7 +71,7 @@ static int Main(string[] args)

perfCounter.ResetCounters();
}
catch (ExitApplicationWithoutReportingException eex)
catch (ExitApplicationWithoutReportingException)
{
Logger.ErrorFormat("If you are unable to resolve the issue please contact the OpenCover development team");
Logger.ErrorFormat("see https://www.github.com/opencover/opencover/issues");
Expand Down Expand Up @@ -121,7 +120,7 @@ private static void ReportCrash(Exception exception)
{
AnonymousData = new AnonymousData
{
ApplicationGuid = new Guid("e6542474-21df-42f4-826b-15a12764da6f"),
ApplicationGuid = new Guid("dbbb1d35-be49-45e2-b81d-84f1042c455d"),
Exception = exception,
ToEmail = ""
}
Expand Down Expand Up @@ -376,7 +375,7 @@ private static int RunProcess(CommandLineParser parser, Action<StringDictionary>
returnCode = process.ExitCode;
return returnCode;
}
catch (Exception ex)
catch (Exception)
{
Logger.ErrorFormat("Failed to execute the following command '{0} {1}'", startInfo.FileName, startInfo.Arguments);
}
Expand Down Expand Up @@ -574,7 +573,8 @@ private static bool ParseCommandLine(string[] args, out CommandLineParser parser
{
var version = entryAssembly.GetName().Version;
System.Console.WriteLine("OpenCover version {0}", version);
return false;
if (args.Length == 1)
return false;
}
}

Expand Down
16 changes: 16 additions & 0 deletions main/OpenCover.Extensions/OpenCover.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\build\Version\AssemblyCopyright.cs">
<Link>Properties\AssemblyCopyright.cs</Link>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AssemblyCopyright.tt</DependentUpon>
</Compile>
<Compile Include="..\..\build\Version\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
Expand All @@ -90,6 +96,16 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\build\Version\AssemblyCopyright.tt">
<Link>Properties\AssemblyCopyright.tt</Link>
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AssemblyCopyright.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
1 change: 1 addition & 0 deletions main/OpenCover.Framework/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public string Usage()
builder.AppendLine(" [-enableperformancecounters]");
builder.AppendLine(" [-skipautoprops]");
builder.AppendLine(" [-oldStyle]");
builder.AppendLine(" -version");
builder.AppendLine("or");
builder.AppendLine(" -?");
builder.AppendLine("or");
Expand Down
39 changes: 30 additions & 9 deletions main/OpenCover.Framework/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -137,9 +136,9 @@ public void AddFilter(string processAssemblyClassFilter)
{
if (!RegExFilters)
{
processFilter = (string.IsNullOrEmpty(processFilter) ? "*" : processFilter).ValidateAndEscape("<>|\""); // Path.GetInvalidPathChars except *?
assemblyFilter = assemblyFilter.ValidateAndEscape();
classFilter = classFilter.ValidateAndEscape();
processFilter = ValidateAndEscape((string.IsNullOrEmpty(processFilter) ? "*" : processFilter), "<>|\"", "process"); // Path.GetInvalidPathChars except *?
assemblyFilter = ValidateAndEscape(assemblyFilter, @"\[]", "assembly");
classFilter = ValidateAndEscape(classFilter, @"\[]", "class/type");
}

var filter = new AssemblyAndClassFilter(processFilter, assemblyFilter, classFilter);
Expand Down Expand Up @@ -182,9 +181,9 @@ private static void GetAssemblyClassName(string processAssemblyClassFilter, bool
}
}

private static void HandleInvalidFilterFormat(string assemblyClassName)
private static void HandleInvalidFilterFormat(string filter)
{
Logger.ErrorFormat("Unable to process the filter '{0}'. Please check your syntax against the usage guide and try again.", assemblyClassName);
Logger.ErrorFormat("Unable to process the filter '{0}'. Please check your syntax against the usage guide and try again.", filter);
Logger.ErrorFormat("The usage guide can also be found at https://github.com/OpenCover/opencover/wiki/Usage.");
throw new ExitApplicationWithoutReportingException();
}
Expand All @@ -195,7 +194,7 @@ private static void HandleInvalidFilterFormat(string assemblyClassName)
/// <param name="exclusionFilters">An array of filters that are used to wildcard match an attribute</param>
public void AddAttributeExclusionFilters(string[] exclusionFilters)
{
ExcludedAttributes.AddFilters(exclusionFilters, RegExFilters);
AddFilters(ExcludedAttributes, exclusionFilters, RegExFilters, "attribute");
}

/// <summary>
Expand Down Expand Up @@ -305,7 +304,7 @@ public bool ExcludeByFile(string fileName)
/// <param name="exclusionFilters"></param>
public void AddFileExclusionFilters(string[] exclusionFilters)
{
ExcludedFiles.AddFilters(exclusionFilters, RegExFilters);
AddFilters(ExcludedFiles, exclusionFilters, RegExFilters, "file exclusion");
}

/// <summary>
Expand All @@ -327,7 +326,7 @@ public bool UseTestAssembly(string assemblyName)
/// <param name="testFilters"></param>
public void AddTestFileFilters(string[] testFilters)
{
TestFiles.AddFilters(testFilters, RegExFilters);
AddFilters(TestFiles, testFilters, RegExFilters, "test assembly");
}

/// <summary>
Expand Down Expand Up @@ -446,5 +445,27 @@ public static IFilter BuildFilter(CommandLineParser parser)

return filter;
}

static void AddFilters(ICollection<RegexFilter> target, IEnumerable<string> filters, bool isRegexFilter, string filterType)
{
if (filters == null)
return;

foreach (var regexFilter in filters.Where(x => x != null).Select(filter => isRegexFilter ? new RegexFilter(filter, false) : new RegexFilter(ValidateAndEscape(filter, @"[]", filterType))))
{
target.Add(regexFilter);
}
}

static string ValidateAndEscape(string match, string notAllowed, string filterType)
{
if (match.IndexOfAny(notAllowed.ToCharArray()) >= 0)
{
Logger.ErrorFormat("The string '{0}' is invalid for a{2} '{1}' filter name",
match, filterType, "aeiou".Contains(filterType[0]) ? "n" : "");
HandleInvalidFilterFormat(match);
}
return match.Replace(@"\", @"\\").Replace(@".", @"\.").Replace(@"*", @".*");
}
}
}
28 changes: 1 addition & 27 deletions main/OpenCover.Framework/Filtering/FilterHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ internal static string WrapWithAnchors(this string data)
return String.Format("^({0})$", data);
}

internal static string ValidateAndEscape(this string match, string notAllowed = @"\[]")
{
if (match.IndexOfAny(notAllowed.ToCharArray()) >= 0)
throw new InvalidOperationException(String.Format("The string is invalid for an filter name {0}", match));
return match.Replace(@"\", @"\\").Replace(@".", @"\.").Replace(@"*", @".*");
}

internal static IList<AssemblyAndClassFilter> GetMatchingFiltersForAssemblyName(this IEnumerable<AssemblyAndClassFilter> filters, string assemblyName)
{
var matchingFilters = filters
Expand All @@ -41,25 +34,6 @@ internal static void AddRange<T> (this ICollection<T> collection, IEnumerable<T>
}
}

internal static void AddFilters(this ICollection<RegexFilter> target, IEnumerable<string> filters, bool isRegexFilter)
{
if (filters == null)
return;

foreach (var filter in filters.Where(x => x != null))
{
RegexFilter regexFilter;
if (isRegexFilter)
{
regexFilter = new RegexFilter(filter, false);
}
else
{
regexFilter = new RegexFilter(filter.ValidateAndEscape(@"[]"));
}

target.Add(regexFilter);
}
}

}
}
8 changes: 8 additions & 0 deletions main/OpenCover.Framework/Manager/MemoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ public void RemoveDeactivatedBlock(ManagedBufferBlock block)
}
}

/// <summary>
/// Wait for the blocks to close
/// </summary>
/// <param name="bufferWaitCount"></param>
public void WaitForBlocksToClose(int bufferWaitCount)
{
// we need to let the profilers dump the thread buffers over before they close - max 15s (ish)
Expand All @@ -379,6 +383,10 @@ public void WaitForBlocksToClose(int bufferWaitCount)
}
}

/// <summary>
/// fetch remaining buffer data
/// </summary>
/// <param name="processBuffer"></param>
public void FetchRemainingBufferData(Action<byte[]> processBuffer)
{
lock (_lockObject)
Expand Down
13 changes: 13 additions & 0 deletions main/OpenCover.Framework/Model/CoverageSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace OpenCover.Framework.Model
{
Expand All @@ -15,13 +16,16 @@ namespace OpenCover.Framework.Model
/// </summary>
public class CoverageSession
{
private string _version;

/// <summary>
/// initialise a coverage session
/// </summary>
public CoverageSession()
{
Modules = new Module[0];
Summary = new Summary();
_version = GetType().Assembly.GetName().Version.ToString();
}
/// <summary>
/// A unique session identifier
Expand All @@ -37,5 +41,14 @@ public CoverageSession()
/// A list of modules that have been profiled under the session
/// </summary>
public Module[] Modules { get; set; }

/// <summary>
/// The current version
/// </summary>
[XmlAttribute("Version")]
public string Version {
get { return _version; }
// ReSharper disable once ValueParameterNotUsed
set { /* intentionally left blank */} }
}
}
Loading