-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Regression: XML documentation respects accessibility now? #77
Regression: XML documentation respects accessibility now? #77
Comments
I just found this item. I also got a discussion for this here: https://roslyn.codeplex.com/discussions/547624 I'm very interested in a fix for this. With our solution, I got dozens of errors from this and I would need to disable the warn-as-error for this accross several (10+ projects). That would mean I can't try Roslyn on the trunk. And that in turn makes it no fun to try Roslyn at all, give it performance spins etc... |
Not a solution, but because I don't like to ignore warnings, could you disable that warning project-wide? |
Hi Paulo! |
The C# compiler's processing for For example: /// Normal reference:
/// <see cref="X._privateField"/>
/// Explicit reference:
/// <see cref="F:Full.Namespace.Of.X._privateField"/> |
Hi sharwell! Thanks for bringing the fully qualified reference up. I only reported this workaround in my Connect issue but didn't add it to jonskeet's original CodePlex issue. Yes, this would solve the reference problem, but it would cost me refactoring safety. R# can update references to members inside xml doc, but only if they are not using fully qualified references. I'm assuming, because the fully qualified form is no longer bound to a specific member within R#'s or Roslyn's code model. This is (I'm assuming) the reason why Roslyn no longer compains when you use the fully qualified form - it simply does not check if the specified member exists. Therefor, it's not really an option for me to change all the usages to the fully qualified form (there's probably at least a hundred of them across the code base) unless I learn that this will not be fixed by Roslyn and a breaking change in the way the C# works will be made. Best Regards, Michael |
@MichaelKetting Your comment is closely related to #45. I absolutely agree that accessibility should not be checked while resolving documentation comments, even across assemblies. However, it would probably make sense to continue filtering the IntelliSense lists to showing accessible members. Either that or use a rule like the following:
This rule is based on the fact that projects which publish API documentation will generally filter the output to the exposed API surface. It would be undesirable for documentation associated with these items to include references to items which are not also included in that documentation. Also note that features like QuickInfo, Go To Declaration, and Find All References would not filter documentation references, as that would completely defeat the purpose of allowing references. For reference, I originally thought of the following more complicated set of rules, but decided the rules above are better overall. The following represents my original thoughts, but is no longer my suggestion.
|
As of e1e49e9, crefs no longer respect accessibility. ☺ A little background: dev12 actually used a two-pass algorithm – the first pass respected accessibility and the second pass did not. This had the advantage that ambiguities would be resolved in favor or accessible symbols. It turns out that implementing this two-pass approach is much more difficult in Roslyn because of the new SemanticModel functionality (let me know if you want more details). We started respecting accessibility because we found some corner cases where a cref might report an ambiguity because a source type/member and an internal one in another assembly. Clearly, this is undesirable, but, as it turns out, not as undesirable as being unable to reference your own inaccessible types/members. ☺ -Andrew @MichaelKettinghttps://github.com/MichaelKetting Your comment is closely related to #45#45. I absolutely agree that accessibility should not be checked while resolving documentation comments, even across assemblies. However, it would probably make sense to continue filtering the IntelliSense lists to showing accessible members. Either that or use a rule like the following:
This rule is based on the fact that projects which publish API documentation will generally filter the output to the exposed API surface. It would be undesirable for documentation associated with these items to include references to items which are not also included in that documentation. For reference, I originally thought of the following more complicated set of rules, but decided the rules above are better overall. The following represents my original thoughts, but is no longer my suggestion.
For example, if the documentation comment is on a public type or member and the target of the reference is internal or private, the member is not shown in IntelliSense. However, if the documentation comment is on an internal member and the reference is internal the item is shown in IntelliSense. The only way an out-of-scope private member shows in IntelliSense is when the documentation comment is on a private member.
— |
Even cross-assemblies, @amcasey? If so, just on the same solution, right? |
The compiler has no concept of project or solution. There are a few places where we check whether something is coming from another Compilation, but this isn’t one of them. It should be the usual lookup rules (plus a few cref-specific quirks) without accessibility checks. However, at a high level, you can think of it as being able to refer to any type/member in any assembly referenced by the containing project. From: Paulo [mailto:notifications@github.com] Even cross-assemblies, @amcaseyhttps://github.com/amcasey? If so, just on the same solution, right? — |
So, reflection might be involved regarding non public methods, right? |
I’m not sure I understand your question. Crefs don’t have a runtime component. The attribute value is bound to a symbol at compile-time and then transformed into another format to be written to the xml documentation file for the assembly. From: Paulo [mailto:notifications@github.com] So, reflection might be involved regarding non public methods, right? — |
I know crefs don't have a run-time component. I'm asking about compile-time. Does the compiler use reflection to get information about external non public symbols. Is that any different from getting information about public symbols? |
@sharwell I can see how #45 might end up requiring the same code paths but the underlying concepts are quite different, from a consumer's POV, as the method groups are a feature that wasn't previously supported and deals with referencing something that is not a member in the most direct sense of the word. To me, they're more related to referencing namespaces. Regardless of that, I'll happily take the method groups, too :) As for Intellisense, I guess that starting to type the name and getting completion on that would be sufficient. @amcasey That's great news, Andrew! Can't wait for the next VS 2015 drop! How do you handle open issues? Should I close it based on this thread or would you close the issue based on your workflow? Regards, Michael |
@paulomorgado Crefs are bound against the same symbols as source code. As during regular compilation, symbols from metadata are constructed based on output from a metadata reader. To the best of my knowledge, the compiler never inspects symbols using .NET reflection. @MichaelKetting You're right, I should probably close this thread since the change has already been made. :) |
Original reported on [CodePlex](unter https://roslyn.codeplex.com/workitem/69) by jonskeet
Repro Sample on CodePlex: Test.cs
The text was updated successfully, but these errors were encountered: