Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide EditorBrowsableNever members by default #4618

Merged
merged 6 commits into from
Nov 8, 2022

Conversation

JoshLove-msft
Copy link
Member

@JoshLove-msft JoshLove-msft commented Nov 4, 2022

Fixes #3900

  • EditorBrowsable attribute is itself now always hidden
  • Members attributed with this are hidden by default
  • There is a checkbox to show the hidden members - the checkbox is only visible if review contains hidden API elements.
  • Value is added to user preferences (just like show left nav, hide line numbers, etc) which is valid for current session - it does not get written to Cosmos like the more permanent settings such as preferred language
  • When diffing, if there is a change in any hidden members they are shown
  • Hidden members are italicized and grayed out
  • Namespaces with only hidden types are also hidden
  • Navigation items that correspond to hidden namespaces or types are hidden

EBN applied to constructor:
image

Show Hidden APIs checkbox:
image

Entire namespace and type is hidden:
image

Some hidden and some non-hidden APIs when Show Hidden is checked:
image

@@ -45,7 +48,7 @@ public override string ToString()

public bool Equals(CodeLine other)
{
return DisplayString == other.DisplayString && ElementId == other.ElementId;
return DisplayString == other.DisplayString && ElementId == other.ElementId && other.IsHiddenApi == IsHiddenApi;
Copy link
Member Author

@JoshLove-msft JoshLove-msft Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption is that this is safe because all out-dated codefiles will be updated in the background to the latest version. If we think this is too dangerous I can make the new property nullable and add a safeguard such that if either is null, we don't consider it a difference. This way old files containing hidden APIs will not trigger a diff against new files. We could also leave the values as null for non C# languages so that they would not run into the same issue if ever enabling support for hidden API hiding.

However, it would be a lot simpler if we could rely on the background update process.

@@ -58,6 +59,15 @@
codeLineDisplay = "hidden-row";
}

if (Model.CodeLine.IsHiddenApi)
{
hiddenApiRow = "hidden-api";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies the italicized style.

hiddenApiRow = "hidden-api";
if (Model.Kind == DiffLineKind.Unchanged)
{
hiddenApiRow += " hidden-api-toggleable d-none";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it toggleable. When there is a diff, it should not be toggleable.

@@ -8,7 +8,7 @@
<ul class="nav-list-children">
@foreach (var item in Model)
{
<li class="@navListGroupClass">
<li class="@navListGroupClass @(item.IsHiddenApi ? " hidden-api-toggleable d-none" : "")">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hides the navigation section if it represents a hidden namespace/type.

@maririos
Copy link
Member

maririos commented Nov 4, 2022

Show Hidden APIs checkbox:

image

Is it always available even for other languages that don't have this behavior?

@JoshLove-msft
Copy link
Member Author

JoshLove-msft commented Nov 4, 2022

Show Hidden APIs checkbox:

image

Is it always available even for other languages that don't have this behavior?

Its visibility is based on the presence of hidden APIs in the markup (I should have mentioned this in the description - now updated). This is similar to how the Show Documentation toggle works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C# API View specific: Add the ability to hide EditorBrowsable(Never) APIs
3 participants