This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add -excludeApiList (-xal) option to GenAPI
This allows folks to specify which APIs should be specifically excluded in addition to other API selection parameters.
- Loading branch information
Showing
5 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/Microsoft.Cci.Extensions/Filters/DocIdExcludeListFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.Cci.Extensions; | ||
using System.IO; | ||
|
||
namespace Microsoft.Cci.Filters | ||
{ | ||
public class DocIdExcludeListFilter : ICciFilter | ||
{ | ||
private readonly HashSet<string> _docIds; | ||
|
||
public DocIdExcludeListFilter(IEnumerable<string> docIds) | ||
{ | ||
_docIds = new HashSet<string>(docIds); | ||
} | ||
|
||
public DocIdExcludeListFilter(string whiteListFilePath) | ||
{ | ||
_docIds = DocIdExtensions.ReadDocIds(whiteListFilePath); | ||
} | ||
|
||
public bool Include(INamespaceDefinition ns) | ||
{ | ||
// Only include non-empty namespaces | ||
return ns.GetTypes().Any(Include); | ||
} | ||
|
||
public bool Include(ITypeDefinition type) | ||
{ | ||
string typeId = type.DocId(); | ||
|
||
// include so long as it isn't in the exclude list. | ||
return !_docIds.Contains(typeId); | ||
} | ||
|
||
public bool Include(ITypeDefinitionMember member) | ||
{ | ||
string memberId = member.DocId(); | ||
// include so long as it isn't in the exclude list. | ||
return !_docIds.Contains(memberId); | ||
} | ||
|
||
public bool Include(ICustomAttribute attribute) | ||
{ | ||
string typeId = attribute.DocId(); | ||
string removeUsages = "RemoveUsages:" + typeId; | ||
|
||
// special case: attribute usage can be removed without removing | ||
// the attribute itself | ||
if (_docIds.Contains(removeUsages)) | ||
return false; | ||
|
||
// include so long as it isn't in the exclude list. | ||
return !_docIds.Contains(typeId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Microsoft.Cci.Extensions/Filters/IntersectionFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Cci.Filters | ||
{ | ||
/// <summary> | ||
/// Combines multiple filters together to only include if all filters include. | ||
/// </summary> | ||
public class IntersectionFilter : ICciFilter | ||
{ | ||
public IntersectionFilter(params ICciFilter[] filters) | ||
{ | ||
Filters = new List<ICciFilter>(filters); | ||
} | ||
|
||
public IList<ICciFilter> Filters { get; private set; } | ||
|
||
public bool Include(ITypeDefinitionMember member) | ||
{ | ||
return Filters.All(filter => filter.Include(member)); | ||
} | ||
|
||
public bool Include(ICustomAttribute attribute) | ||
{ | ||
return Filters.All(filter => filter.Include(attribute)); | ||
} | ||
|
||
public bool Include(ITypeDefinition type) | ||
{ | ||
return Filters.All(filter => filter.Include(type)); | ||
} | ||
|
||
public bool Include(INamespaceDefinition ns) | ||
{ | ||
return Filters.All(filter => filter.Include(ns)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters