-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Diagnostic Improvements for error #0281 #27052
Changes from 1 commit
37ed85e
6eb8ea7
de25429
ee189b0
ab9faaf
af6f5ac
0b3c9f1
080de89
3191a12
44e6815
e24f1a6
cf7eb19
200acb1
816472a
6f57496
56bb172
7eba065
72b880a
28f0a80
15176b2
6a36501
e9baab9
b095767
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
using System.Collections.Immutable; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis.Collections; | ||
using Microsoft.CodeAnalysis.CSharp.Symbols; | ||
using Microsoft.CodeAnalysis.PooledObjects; | ||
using Roslyn.Utilities; | ||
|
@@ -1148,21 +1147,33 @@ internal SingleLookupResult CheckViability(Symbol symbol, int arity, LookupOptio | |
return LookupResult.Inaccessible(symbol, diagInfo); | ||
} | ||
else if (!InCref && | ||
!this.IsAccessible(unwrappedSymbol, | ||
!this.IsAccessible(unwrappedSymbol, | ||
RefineAccessThroughType(options, accessThroughType), | ||
out inaccessibleViaQualifier, | ||
ref useSiteDiagnostics, | ||
basesBeingResolved)) | ||
{ | ||
if (inaccessibleViaQualifier) | ||
{ | ||
bool friendRefNotEqualToThis = unwrappedSymbol.ContainingAssembly.GetInternalsVisibleToPublicKeys(this.ContainingType.ContainingAssembly.Name).Any() | ||
&& unwrappedSymbol.DeclaredAccessibility.Equals(Accessibility.Internal); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to use |
||
|
||
foreach (ImmutableArray<byte> key in unwrappedSymbol.ContainingAssembly.GetInternalsVisibleToPublicKeys(this.ContainingType.ContainingAssembly.Name)) | ||
{ | ||
friendRefNotEqualToThis = key.SequenceEqual(this.ContainingType.ContainingAssembly.Identity.PublicKey) ? false : friendRefNotEqualToThis; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation seems off here... |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be combined with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would capture There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake, there is no |
||
|
||
if (inaccessibleViaQualifier) | ||
{ | ||
diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadProtectedAccess, unwrappedSymbol, accessThroughType, this.ContainingType) : null; | ||
} | ||
else | ||
{ | ||
} | ||
else if (friendRefNotEqualToThis) | ||
{ | ||
diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_FriendRefNotEqualToThis, unwrappedSymbol.ContainingAssembly.Identity.ToString(), this.ContainingType.ContainingAssembly.PublicKey.PublicKeyToString()) : null; | ||
} | ||
else | ||
{ | ||
var unwrappedSymbols = ImmutableArray.Create<Symbol>(unwrappedSymbol); | ||
diagInfo = diagnose ? new CSDiagnosticInfo(ErrorCode.ERR_BadAccess, new[] { unwrappedSymbol }, unwrappedSymbols, additionalLocations: ImmutableArray<Location>.Empty) : null; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider checking
|
||
|
||
return LookupResult.Inaccessible(symbol, diagInfo); | ||
} | ||
|
@@ -1196,7 +1207,7 @@ internal SingleLookupResult CheckViability(Symbol symbol, int arity, LookupOptio | |
return LookupResult.Good(symbol); | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidental whitespace change. |
||
private CSDiagnosticInfo MakeCallMethodsDirectlyDiagnostic(Symbol symbol) | ||
{ | ||
Debug.Assert(symbol.MustCallMethodsDirectly()); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1909,7 +1909,7 @@ private void CheckOptimisticIVTAccessGrants(DiagnosticBag bag) | |
|
||
if (conclusion == IVTConclusion.PublicKeyDoesntMatch) | ||
bag.Add(ErrorCode.ERR_FriendRefNotEqualToThis, NoLocation.Singleton, | ||
otherAssembly.Identity); | ||
otherAssembly.Identity.ToString(), this.ContainingAssembly.Identity.ToString()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe we should be calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually prefer to be explicit on how things get serialized to strings -- Jared's comment reflects that this is usually a very deliberate decision and being explicit signals intent better, IMHO. |
||
else if (conclusion == IVTConclusion.OneSignedOneNot) | ||
bag.Add(ErrorCode.ERR_FriendRefSigningMismatch, NoLocation.Singleton, | ||
otherAssembly.Identity); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the old whitespace was correct