Skip to content

Move to the use site tracking for the purpose of recording used assemblies in VB#40640

Merged
AlekseyTs merged 2 commits intodotnet:features/UsedAssemblyReferencesfrom
AlekseyTs:UsedAssemblies_09
Jan 4, 2020
Merged

Move to the use site tracking for the purpose of recording used assemblies in VB#40640
AlekseyTs merged 2 commits intodotnet:features/UsedAssemblyReferencesfrom
AlekseyTs:UsedAssemblies_09

Conversation

@AlekseyTs
Copy link
Copy Markdown
Contributor

@AlekseyTs AlekseyTs commented Dec 30, 2019

This change is continuing work started in #40560. It makes similar changes on VB side.

@AlekseyTs AlekseyTs marked this pull request as ready for review December 31, 2019 20:33
@AlekseyTs AlekseyTs requested a review from a team as a code owner December 31, 2019 20:33
@AlekseyTs AlekseyTs requested review from 333fred and gafter December 31, 2019 20:33
}
}

// PROTOTYPE(UsedAssemblyReferences): Mesure performace impact of collecting more information during binding by using this class.
Copy link
Copy Markdown
Member

@gafter gafter Dec 31, 2019

Choose a reason for hiding this comment

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

Mesure [](start = 42, length = 6)

misspelled. #Resolved

return hashSet == null || hashSet.Count == 0;
}

internal static bool IsNullOrEmpty<T>([NotNullWhen(returnValue: false)] this IReadOnlyCollection<T>? hashSet)
Copy link
Copy Markdown
Member

@gafter gafter Dec 31, 2019

Choose a reason for hiding this comment

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

hashSet [](start = 109, length = 7)

please select a more apropos name. #Resolved

{
internal static class CollectionsExtensions
{
internal static bool IsNullOrEmpty<T>([NotNullWhen(returnValue: false)] this ICollection<T>? hashSet)
Copy link
Copy Markdown
Member

@gafter gafter Dec 31, 2019

Choose a reason for hiding this comment

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

hashSet [](start = 101, length = 7)

please select a more apropos name. #Resolved

End If
End Sub

<Extension()>
Copy link
Copy Markdown
Member

@gafter gafter Dec 31, 2019

Choose a reason for hiding this comment

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

() [](start = 14, length = 2)

Please drop the () (or add them everywhere else).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please drop the () (or add them everywhere else).

This doesn't violate any rules or guidelines.


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

Copy link
Copy Markdown
Member

@gafter gafter Dec 31, 2019

Choose a reason for hiding this comment

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

Writing code in an internally inconsistent style is a bad programming practice. I am not reviewing only for things we have explicit rules for. I am reviewing for poor programming practices, among other things.

In any case, the "rule or guideline" violated here is in https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md which is referenced by https://github.com/dotnet/roslyn/blob/master/CONTRIBUTING.md and which states

When editing files, keep new code and changes consistent with the style in the files.


In reply to: 362283849 [](ancestors = 362283849,362283395)

' STMT: this.builder.AwaitUnsafeOnCompleted(Of TAwaiter,TSM)((ByRef) $awaiterTemp, (ByRef) Me)
' or
' STMT: this.builder.AwaitOnCompleted(Of TAwaiter,TSM)((ByRef) $awaiterTemp, (ByRef) Me)
Dim useSiteInfo As CompoundUseSiteInfo(Of AssemblySymbol) = Nothing
Copy link
Copy Markdown
Member

@gafter gafter Dec 31, 2019

Choose a reason for hiding this comment

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

Dim [](start = 24, length = 3)

Is this intended to be a bug fix? If so, do we have a test for it? If yes, please identify that test. #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this intended to be a bug fix? If so, do we have a test for it? If yes, please identify that test.

This is intended as a change to follow a long standing requirement to report use-site errors for all operations/symbols that might have it. We don't have a test for this particular change and I do not believe it is worth spending time coming up with specific scenario demonstrating the problem. It is always safe to report use-site errors, at worse this can lead to a duplicate diagnostic being reported. If you prefer, I can undo the change and open an issue instead.


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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, I was just wondering.


In reply to: 362286535 [](ancestors = 362286535,362285747)

Copy link
Copy Markdown
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

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

Other than as noted (two parameters need renaming in CollectionsExtensions.cs, misspelling in core BindingDiagnosticBag.cs, and a style consistency issue in Extensions.vb), this looks good.

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@dotnet/roslyn-compiler, @333fred Please review, need a second sign-off

1 similar comment
@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@dotnet/roslyn-compiler, @333fred Please review, need a second sign-off

}
}

// PROTOTYPE(UsedAssemblyReferences): Mesure performace impact of collecting more information during binding by using this class.
Copy link
Copy Markdown
Member

@333fred 333fred Jan 2, 2020

Choose a reason for hiding this comment

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

performace [](start = 49, length = 10)

Also misspelled :) #Resolved

}
}

internal void AddDependencies(IReadOnlyCollection<TAssemblySymbol>? dependencies)
Copy link
Copy Markdown
Member

@333fred 333fred Jan 2, 2020

Choose a reason for hiding this comment

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

Consider unifying this and the one above it with an AddDependencies(IEnumerable<TAssemblySymbol>? dependencies) #Closed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, I suppose you can't because you need to know how many elements are in it. It's a shame that ICollection doesn't implement IReadonlyCollection.


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


public void MergeDependencies(ref TAssemblySymbol? primaryDependency, ref ImmutableHashSet<TAssemblySymbol>? secondaryDependencies)
{
secondaryDependencies = (secondaryDependencies ?? ImmutableHashSet<TAssemblySymbol>.Empty).Union(SecondaryDependencies ?? ImmutableHashSet<TAssemblySymbol>.Empty);
Copy link
Copy Markdown
Member

@333fred 333fred Jan 2, 2020

Choose a reason for hiding this comment

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

Is this the cause of the added Linq using above? #Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If so, this could cause enumerator allocations as it won't use the struct-based enumerator on ImmutableHashSet


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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this the cause of the added Linq using above?

No, this Union method is defined on ImmutableHashSet. I assume it should be very efficient when both sides are ImmutableHashSets


In reply to: 362669358 [](ancestors = 362669358,362669134)


if (!object.Equals(primaryDependency, PrimaryDependency) && PrimaryDependency is object)
{
secondaryDependencies = secondaryDependencies.Add(PrimaryDependency);
Copy link
Copy Markdown
Member

@333fred 333fred Jan 2, 2020

Choose a reason for hiding this comment

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

The docs indicate this will be empty if DiagnosticInfo is an error. Should we be conditioning that here? #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The docs indicate this will be empty if DiagnosticInfo is an error. Should we be conditioning that here?

I do not think this needs an explicit check because PrimaryDependency would be null in that case.


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

else
{
Debug.Assert(info.DiagnosticInfo == null || addDependencies); // It would be strange to drop diagnostics, but record dependencies
Debug.Assert(info.DiagnosticInfo == null); // It would be strange to drop diagnostics, but record dependencies
Copy link
Copy Markdown
Member

@333fred 333fred Jan 2, 2020

Choose a reason for hiding this comment

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

// It would be strange to drop diagnostics, but record dependencies [](start = 59, length = 67)

Is this comment relevant anymore? #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this comment relevant anymore?

Yes.


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


Namespace Microsoft.CodeAnalysis.VisualBasic

' PROTOTYPE(UsedAssemblyReferences) Consider if it makes sense to move this type into its own file
Copy link
Copy Markdown
Member

@333fred 333fred Jan 3, 2020

Choose a reason for hiding this comment

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

Leaving off review (commit 1). Will pick back up tomorrow. #Closed

Copy link
Copy Markdown
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1)

@AlekseyTs AlekseyTs merged commit d6a5d04 into dotnet:features/UsedAssemblyReferences Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants