-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed property getter/setter access modifier not taken into account (f…
…ixes #151)
- Loading branch information
Showing
7 changed files
with
110 additions
and
31 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
38 changes: 38 additions & 0 deletions
38
source/DefaultDocumentation.Api/Extensions/IEntityExtensions.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,38 @@ | ||
using System.Linq; | ||
using DefaultDocumentation; | ||
|
||
namespace ICSharpCode.Decompiler.TypeSystem | ||
{ | ||
/// <summary> | ||
/// Provides extension methods on the <see cref="IEntity"/> type. | ||
/// </summary> | ||
public static class IEntityExtensions | ||
{ | ||
/// <summary> | ||
/// Returns wether an <see cref="IEntity"/> should be part of the documentation or not based on its accessibility. | ||
/// </summary> | ||
/// <param name="entity">The <see cref="IEntity"/> to check.</param> | ||
/// <param name="settings">The <see cref="ISettings"/> used to generate the documentation.</param> | ||
/// <returns><see langword="true"/> if the entity should be part of the documentation; otherwise <see langword="false"/>.</returns> | ||
public static bool IsVisibleInDocumentation(this IEntity? entity, ISettings settings) | ||
{ | ||
ArgumentNullException.ThrowIfNull(settings); | ||
|
||
return entity?.EffectiveAccessibility() switch | ||
{ | ||
Accessibility.Public => (settings.GeneratedAccessModifiers & GeneratedAccessModifiers.Public) != 0, | ||
Accessibility.Private => entity switch | ||
{ | ||
IProperty property when property.IsExplicitInterfaceImplementation => property.ExplicitlyImplementedInterfaceMembers.First().DeclaringTypeDefinition.IsVisibleInDocumentation(settings), | ||
IMethod method when method.IsExplicitInterfaceImplementation => method.ExplicitlyImplementedInterfaceMembers.First().DeclaringTypeDefinition.IsVisibleInDocumentation(settings), | ||
_ => (settings.GeneratedAccessModifiers & GeneratedAccessModifiers.Private) != 0 | ||
}, | ||
Accessibility.Protected => (settings.GeneratedAccessModifiers & GeneratedAccessModifiers.Protected) != 0, | ||
Accessibility.Internal => (settings.GeneratedAccessModifiers & GeneratedAccessModifiers.Internal) != 0, | ||
Accessibility.ProtectedOrInternal => (settings.GeneratedAccessModifiers & GeneratedAccessModifiers.ProtectedInternal) != 0, | ||
Accessibility.ProtectedAndInternal => (settings.GeneratedAccessModifiers & GeneratedAccessModifiers.PrivateProtected) != 0, | ||
_ => false | ||
}; | ||
} | ||
} | ||
} |
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
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
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
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
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