Skip to content

Align the implementations of IAssemblySymbol.GivesAccessTo#26727

Merged
gafter merged 4 commits intodotnet:masterfrom
gafter:master-GAT
May 10, 2018
Merged

Align the implementations of IAssemblySymbol.GivesAccessTo#26727
gafter merged 4 commits intodotnet:masterfrom
gafter:master-GAT

Conversation

@gafter
Copy link
Copy Markdown
Member

@gafter gafter commented May 8, 2018

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

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
@gafter gafter added this to the 15.8 milestone May 8, 2018
@gafter gafter self-assigned this May 8, 2018
@gafter gafter requested review from a team as code owners May 8, 2018 21:40
@gafter gafter added the Concept-Design Debt Engineering Debt, Design Debt, or poor product code quality label May 8, 2018
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.
Copy link
Copy Markdown
Member Author

@gafter gafter May 8, 2018

Choose a reason for hiding this comment

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

That moment has passed. But rather than porting the logic we moved it to a shared layer. #ByDesign

@gafter
Copy link
Copy Markdown
Member Author

gafter commented May 8, 2018

@dotnet/roslyn-compiler Please review this refactoring of duplicate compiler code to shared code.
@AlekseyTs I suspect you are interested in this.
#Resolved

/// </summary>
NoRelationshipClaimed
}
}
Copy link
Copy Markdown
Member

@jcouv jcouv May 9, 2018

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I expect that and #26722 to be addressed at the same time.


In reply to: 187126129 [](ancestors = 187126129)

using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Collections;

namespace Microsoft.CodeAnalysis
Copy link
Copy Markdown
Member

@jcouv jcouv May 9, 2018

Choose a reason for hiding this comment

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

Nit: Should the filename use a dot as a separator instead of underscore, to be consistent with rest of codebase?
#ByDesign

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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?
Copy link
Copy Markdown
Member

@jcouv jcouv May 9, 2018

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

@jcouv jcouv May 9, 2018

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

@jcouv jcouv May 9, 2018

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

@jcouv jcouv May 9, 2018

Choose a reason for hiding this comment

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

[](start = 43, length = 2)

Nit: double space #ByDesign

Copy link
Copy Markdown
Member Author

@gafter gafter May 9, 2018

Choose a reason for hiding this comment

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

The double space is intentional, as it precedes a code quotation. #ByDesign

Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks

Assert.True(VB.ContainingAssembly.GivesAccessTo(CS.ContainingAssembly));
Assert.False(VB.ContainingAssembly.GivesAccessTo(CS2.ContainingAssembly));

}
Copy link
Copy Markdown
Contributor

@OmarTawfik OmarTawfik May 9, 2018

Choose a reason for hiding this comment

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

nit: empty line #Resolved

}

internal static bool IsNetModule(this IAssemblySymbol assembly) =>
assembly is ISourceAssemblySymbol sourceAssembly && sourceAssembly.Compilation.Options.OutputKind == OutputKind.NetModule;
Copy link
Copy Markdown
Contributor

@OmarTawfik OmarTawfik May 9, 2018

Choose a reason for hiding this comment

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

Compilation.Options.OutputKind == OutputKind.NetModule [](start = 79, length = 54)

perhaps use the OutputKind.IsNetModule() helper? #Resolved

Copy link
Copy Markdown
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

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

:shipit:

@gafter gafter merged commit cb21f0e into dotnet:master May 10, 2018
333fred added a commit that referenced this pull request May 14, 2018
* 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.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Concept-Design Debt Engineering Debt, Design Debt, or poor product code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants