Align the implementations of IAssemblySymbol.GivesAccessTo#26727
Align the implementations of IAssemblySymbol.GivesAccessTo#26727gafter merged 4 commits intodotnet:masterfrom
Conversation
It now has a shared core implementation that permits operation across IAssemblySymbol implementations. Fixes dotnet#26459 Fixes dotnet#26723 One remaining difference is in the treatment of a strong named assembly and a weak named assembly. C# treats them as being (capable of being) related for error recovery. VB does not. We would like to strengthen C# but that may be a breaking change, so we're leaving it as is, at least for now. See also dotnet#26722
| Protected Function PerformIVTCheck(key As ImmutableArray(Of Byte), otherIdentity As AssemblyIdentity) As IVTConclusion | ||
| ' Implementation of this function in C# compiler is somewhat different, but we believe | ||
| ' that the difference doesn't affect any real world scenarios that we know/care about. | ||
| ' At the moment we don't feel it is worth porting the logic, but we might reconsider in the future. |
There was a problem hiding this comment.
That moment has passed. But rather than porting the logic we moved it to a shared layer. #ByDesign
|
@dotnet/roslyn-compiler Please review this refactoring of duplicate compiler code to shared code. |
| /// </summary> | ||
| NoRelationshipClaimed | ||
| } | ||
| } |
There was a problem hiding this comment.
Not related to this PR, but I thought I should mention it since you're working in that area: #17322 (improving diagnostics related to IVT) #Resolved
| using System.Collections.Immutable; | ||
| using Microsoft.CodeAnalysis.Collections; | ||
|
|
||
| namespace Microsoft.CodeAnalysis |
There was a problem hiding this comment.
Nit: Should the filename use a dot as a separator instead of underscore, to be consistent with rest of codebase?
#ByDesign
There was a problem hiding this comment.
The convention I've seen is to use dot as a separator for a nested type and underscore as a separator for a part of a partial type.
In reply to: 187126565 [](ancestors = 187126565)
| // assembly is "Jones.DLL", and that Smith has named Jones as a friend (that is a precondition | ||
| // to calling this method). Whether we allow Jones to see internals of Smith depends on these four factors: | ||
| // | ||
| // q1) Is Smith strong-named? |
There was a problem hiding this comment.
Nit: Could I suggest "Granting.dll" and "Wanting.dll" to align on terminology? (no "this"/"other", "Smith"/"Jones")
I recognize this is just moved code/comment though... #Resolved
There was a problem hiding this comment.
I tried doing that and now the comment is readable!
In reply to: 187128624 [](ancestors = 187128624)
| // to strong-named Jones, which then references Smith. However, we still want to give friend | ||
| // access to Jones for the purposes of semantic analysis. | ||
| // | ||
| // TODO: Roslyn C# does not yet give an error in other circumstances whereby a strong-named assembly |
There was a problem hiding this comment.
TODO's should be replaced with open issues. #Resolved
| // We allow John to access Paul's internal Goo even though strong-named John should not be referencing weak-named Paul. | ||
| // Paul has, after all, specifically granted access to John. | ||
|
|
||
| // TODO: During emit time we should produce an error that says that a strong-named assembly cannot reference |
There was a problem hiding this comment.
TODO [](start = 15, length = 4)
Nit: TODO #Resolved
| result = potentialGiverOfAccess.Identity.PerformIVTCheck(Me.PublicKey, key) | ||
|
|
||
| If result = IVTConclusion.Match Then | ||
| ' Note that C# includes OrElse result = IVTConclusion.OneSignedOneNot |
There was a problem hiding this comment.
[](start = 43, length = 2)
Nit: double space #ByDesign
There was a problem hiding this comment.
The double space is intentional, as it precedes a code quotation. #ByDesign
| Assert.True(VB.ContainingAssembly.GivesAccessTo(CS.ContainingAssembly)); | ||
| Assert.False(VB.ContainingAssembly.GivesAccessTo(CS2.ContainingAssembly)); | ||
|
|
||
| } |
There was a problem hiding this comment.
nit: empty line #Resolved
| } | ||
|
|
||
| internal static bool IsNetModule(this IAssemblySymbol assembly) => | ||
| assembly is ISourceAssemblySymbol sourceAssembly && sourceAssembly.Compilation.Options.OutputKind == OutputKind.NetModule; |
There was a problem hiding this comment.
Compilation.Options.OutputKind == OutputKind.NetModule [](start = 79, length = 54)
perhaps use the OutputKind.IsNetModule() helper? #Resolved
* dotnet/master: (732 commits) Disable procdump on Spanish runs use named args. Exclude System.Diagnostics.DiagnosticSource from PortableFacades Exclude System.Net.Http from PortableFacades Align the implementations of IAssemblySymbol.GivesAccessTo (#26727) Fixed exception message in GetSemanticModel (#26659) Implement IDiscardSymbol.Equals and GetHashCode (#26720) Produce correct diagnostics on implicit operator conversions for stackalloc expressions (#26248) Remove special case handling of CreateDiagnosticProviderAndFixer throwing an exception Add verbose logging to DevDivInsertionFiles if you want it Exclude Microsoft.Composition as something we build a dependency map for Fix the message for Make Field Readonly Update LangVersion to 7.3 (#26698) fix extension deployment and add explainatory comment Add TaskExtensions to compiler package Add System.Diagnostics.DiagnosticSource to SignToolData.json Include missing facade: System.Diagnostics.DiagnosticSource Use default expressions. Remove forwarding method. Revert project chnage. ...
It now has a shared core implementation that permits operation across IAssemblySymbol implementations.
Fixes #26459
Fixes #26723
One remaining difference is in the treatment of a strong named assembly and a weak named assembly. C# treats them as being (capable of being) related for error recovery. VB does not. We would like to strengthen C# but that may be a breaking change, so we're leaving it as is, at least for now.
See also #26722