本文整理汇总了C#中OpenCover.Framework.Filter.AddAttributeExclusionFilters方法的典型用法代码示例。如果您正苦于以下问题:C# Filter.AddAttributeExclusionFilters方法的具体用法?C# Filter.AddAttributeExclusionFilters怎么用?C# Filter.AddAttributeExclusionFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCover.Framework.Filter
的用法示例。
在下文中一共展示了Filter.AddAttributeExclusionFilters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildFilter
private static IFilter BuildFilter(CommandLineParser parser)
{
var filter = new Filter();
// apply filters
if (!parser.NoDefaultFilters)
{
filter.AddFilter("-[mscorlib]*");
filter.AddFilter("-[mscorlib.*]*");
filter.AddFilter("-[System]*");
filter.AddFilter("-[System.*]*");
filter.AddFilter("-[Microsoft.VisualBasic]*");
}
if (parser.Filters.Count == 0)
{
filter.AddFilter("+[*]*");
}
else
{
parser.Filters.ForEach(filter.AddFilter);
}
filter.AddAttributeExclusionFilters(parser.AttributeExclusionFilters.ToArray());
filter.AddFileExclusionFilters(parser.FileExclusionFilters.ToArray());
filter.AddTestFileFilters(parser.TestFilters.ToArray());
return filter;
}
示例2: AddAttributeExclusionFilters_Handles_Null_Elements
public void AddAttributeExclusionFilters_Handles_Null_Elements()
{
var filter = new Filter(false);
filter.AddAttributeExclusionFilters(new[] { null, "" });
Assert.Equal(1, filter.ExcludedAttributes.Count);
}
示例3: BuildFilter
private static IFilter BuildFilter(CommandLineParser parser)
{
var filter = new Filter();
// apply filters
if (!parser.NoDefaultFilters)
{
filter.AddFilter("-[mscorlib]*");
filter.AddFilter("-[mscorlib.*]*");
filter.AddFilter("-[System]*");
filter.AddFilter("-[System.*]*");
filter.AddFilter("-[Microsoft.VisualBasic]*");
}
if (parser.Filters.Count == 0 && string.IsNullOrEmpty(parser.FilterFile))
{
filter.AddFilter("+[*]*");
}
else
{
if (!string.IsNullOrEmpty(parser.FilterFile))
{
if (!File.Exists(parser.FilterFile))
System.Console.WriteLine("FilterFile '{0}' cannot be found - have you specified your arguments correctly?", parser.FilterFile);
else
{
var filters = File.ReadAllLines(parser.FilterFile);
filters.ToList().ForEach(filter.AddFilter);
}
}
if (parser.Filters.Count > 0)
{
parser.Filters.ForEach(filter.AddFilter);
}
}
filter.AddAttributeExclusionFilters(parser.AttributeExclusionFilters.ToArray());
filter.AddFileExclusionFilters(parser.FileExclusionFilters.ToArray());
filter.AddTestFileFilters(parser.TestFilters.ToArray());
return filter;
}
示例4: Can_Identify_Excluded_Properties
public void Can_Identify_Excluded_Properties()
{
var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);
var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof(Samples.Concrete).FullName);
var filter = new Filter();
filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });
foreach (var propertyDefinition in type.Properties)
{
Assert.True(filter.ExcludeByAttribute(propertyDefinition));
}
}
示例5: Can_Identify_Excluded_Methods
public void Can_Identify_Excluded_Methods()
{
var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);
var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof (Samples.Concrete).FullName);
var filter = new Filter();
filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });
foreach (var methodDefinition in type.Methods)
{
if (methodDefinition.IsSetter || methodDefinition.IsGetter) continue;
Assert.True(filter.ExcludeByAttribute(methodDefinition));
}
}
示例6: AddAttributeExclusionFilters_Escapes_Elements_And_Matches
public void AddAttributeExclusionFilters_Escapes_Elements_And_Matches()
{
var filter = new Filter();
filter.AddAttributeExclusionFilters(new[] { ".*" });
Assert.IsTrue(filter.ExcludedAttributes[0].Value.Match(".ABC").Success);
}
示例7: AddAttributeExclusionFilters_HandlesNull
public void AddAttributeExclusionFilters_HandlesNull()
{
var filter = new Filter();
filter.AddAttributeExclusionFilters(null);
Assert.AreEqual(0, filter.ExcludedAttributes.Count);
}
示例8: Handles_Issue117
public void Handles_Issue117()
{
var filter = new Filter();
filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });
var mockDefinition = new Mock<IMemberDefinition>();
mockDefinition.SetupGet(x => x.HasCustomAttributes).Returns(true);
mockDefinition.SetupGet(x => x.CustomAttributes).Returns(new Collection<CustomAttribute>());
mockDefinition.SetupGet(x => x.Name).Returns("<>f_ddd");
mockDefinition.SetupGet(x => x.DeclaringType).Returns(new TypeDefinition("","f_ddd", TypeAttributes.Public));
Assert.DoesNotThrow(() => filter.ExcludeByAttribute(mockDefinition.Object));
}
示例9: Can_Identify_Included_Anonymous_Issue99
public void Can_Identify_Included_Anonymous_Issue99()
{
var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Anonymous).Assembly.Location);
var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof(Samples.Anonymous).FullName);
var filter = new Filter();
filter.AddAttributeExclusionFilters(new[] { "*ExcludeMethodAttribute" });
foreach (var methodDefinition in type.Methods.Where(x => x.Name.Contains("INCLUDE")))
{
if (methodDefinition.IsSetter || methodDefinition.IsGetter || methodDefinition.IsConstructor) continue;
Assert.False(filter.ExcludeByAttribute(methodDefinition), "failed to include {0}", methodDefinition.Name);
}
}
示例10: BuildFilter
/// <summary>
/// Create a filter entity from parser parameters
/// </summary>
/// <param name="parser"></param>
/// <returns></returns>
public static IFilter BuildFilter(CommandLineParser parser)
{
var filter = new Filter(parser.RegExFilters);
// apply filters
if (!parser.NoDefaultFilters)
{
if (parser.RegExFilters)
{
filter.AddFilter(@"-[(mscorlib)](.*)");
filter.AddFilter(@"-[(mscorlib\..*)](.*)");
filter.AddFilter(@"-[(System)](.*)");
filter.AddFilter(@"-[(System\..*)](.*)");
filter.AddFilter(@"-[(Microsoft.VisualBasic)](.*)");
}
else
{
filter.AddFilter("-[mscorlib]*");
filter.AddFilter("-[mscorlib.*]*");
filter.AddFilter("-[System]*");
filter.AddFilter("-[System.*]*");
filter.AddFilter("-[Microsoft.VisualBasic]*");
}
}
if (parser.Filters.Count > 0)
{
parser.Filters.ForEach(filter.AddFilter);
}
filter.AddAttributeExclusionFilters(parser.AttributeExclusionFilters.ToArray());
filter.AddFileExclusionFilters(parser.FileExclusionFilters.ToArray());
filter.AddTestFileFilters(parser.TestFilters.ToArray());
foreach (var excludeDir in parser.ExcludeDirs)
{
filter.AddExcludedFolder(excludeDir);
}
return filter;
}
示例11: Can_Identify_Excluded_Methods_UsingRegularExpressions
public void Can_Identify_Excluded_Methods_UsingRegularExpressions()
{
// arrange
var filter = new Filter(true);
filter.AddAttributeExclusionFilters(new[] { ".*ExcludeMethodAttribute" });
// act
var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);
var type = sourceAssembly.MainModule.Types.First(x => x.FullName == typeof(Samples.Concrete).FullName);
// assert
foreach (var methodDefinition in type.Methods.Where(methodDefinition => !methodDefinition.IsSetter && !methodDefinition.IsGetter))
{
Assert.True(filter.ExcludeByAttribute(methodDefinition));
}
}
示例12: Can_Identify_Excluded_Types
public void Can_Identify_Excluded_Types(string typeName)
{
// arrange
var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);
// act
var filter = new Filter(false);
var allTypes = AllTypes(sourceAssembly.MainModule);
var typeDefinition = allTypes.First(x => x.Name == typeName);
Assert.False(filter.ExcludeByAttribute(typeDefinition));
// assert
filter.AddAttributeExclusionFilters(new[] { "*ExcludeClassAttribute" });
foreach (var methodDefinition in typeDefinition.Methods)
{
if (methodDefinition.IsSetter || methodDefinition.IsGetter) continue;
Assert.True(filter.ExcludeByAttribute(methodDefinition));
}
Assert.True(filter.ExcludeByAttribute(typeDefinition));
foreach (var nestedType in AllNestedTypes(typeDefinition))
{
Assert.True(filter.ExcludeByAttribute(nestedType));
}
}
示例13: Can_Identify_Excluded_Assemblies
public void Can_Identify_Excluded_Assemblies()
{
// arrange
var sourceAssembly = AssemblyDefinition.ReadAssembly(typeof(Samples.Concrete).Assembly.Location);
// act
var filter = new Filter(false);
Assert.False(filter.ExcludeByAttribute(sourceAssembly));
// assert
filter.AddAttributeExclusionFilters(new[] { "*ExcludeAssemblyAttribute" });
Assert.True(filter.ExcludeByAttribute(sourceAssembly));
}
示例14: AddAttributeExclustionFilters_DoesNotWrap_ForRegexFilters
public void AddAttributeExclustionFilters_DoesNotWrap_ForRegexFilters()
{
var filter = new Filter(true);
const string stringToMatch = "some string on the line before EXPRESSION some string after the expression";
filter.AddAttributeExclusionFilters(new[] { "EXPRESSION" });
var excludedAttributeRegexFilter = filter.ExcludedAttributes[0];
Assert.IsTrue(excludedAttributeRegexFilter.IsMatchingExpression(stringToMatch));
}
示例15: AddAttributeExclusionFilters_Escapes_Elements_And_Matches
public void AddAttributeExclusionFilters_Escapes_Elements_And_Matches()
{
var filter = new Filter(false);
filter.AddAttributeExclusionFilters(new[] { ".*" });
Assert.IsTrue(filter.ExcludedAttributes[0].IsMatchingExpression(".ABC"));
}