Skip to content

Conversation

@calumgrant
Copy link
Contributor

@calumgrant calumgrant commented Apr 24, 2020

Improves database consistency and fixes unstable results.

Summary of changes:

In trap files, the identifiers for types are prefixed by their declaring assembly, in order to handle the same type name being used in different assemblies. This is because there can be several versions of the same type, or if the same type name is accidentally used in different assemblies, then it is useful to be able to distinguish them. This also prevents database errors if different versions of the same type name are incompatible.

However with .NET Core, the same type can be defined in different assemblies, for example mscorlib, System.Private.CoreLib, netstandard and System.Runtime. This causes database instability if an assembly is extracted against netstandard in one build thread, and System.Runtime in another build thread. Depending upon which extraction happened first, the identifiers in the trap file will reference either System.Runtime or netstandard.

The fix is to remove the assembly-id qualified from the trap file, so that the build order does not matter.

@calumgrant
Copy link
Contributor Author

@calumgrant calumgrant force-pushed the cs/unqualify-trap-ids2 branch from 230a6d6 to a7a9d84 Compare May 6, 2020 11:27
@calumgrant
Copy link
Contributor Author

@calumgrant calumgrant marked this pull request as ready for review May 6, 2020 17:11
@calumgrant calumgrant requested a review from a team as a code owner May 6, 2020 17:11
@hvitved
Copy link
Contributor

hvitved commented May 11, 2020

@calumgrant calumgrant force-pushed the cs/unqualify-trap-ids2 branch from 71521a0 to 813ed78 Compare May 11, 2020 08:47
@calumgrant
Copy link
Contributor Author

@@ -999,5 +999,63 @@ class TypeMention extends @type_mention {
@type_or_ref getTypeRef(@type type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably cache this predicate now that it relies on some non-trivial calculations.

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

A few comments and questions.


string toString() { result = getName() }

Type getAType() { typeref_type(this, result) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Refreshing my memory here: This is a one-to-many relation, right? I.e. count(TypeRef r | typeref_type(r, t)) <= 1 for all types t?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. As you observe, not all types have typerefs - only named types do.

@calumgrant calumgrant force-pushed the cs/unqualify-trap-ids2 branch from 42c623c to 2c6ee5e Compare May 18, 2020 20:32
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Changes LGTM. Lets just wait for a final CSharp-Changes job to finish before merging (I have started on here: https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/174/console).

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Blocking this, as performance is worsened significantly (see https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/174/).

@calumgrant calumgrant force-pushed the cs/unqualify-trap-ids2 branch from 2c6ee5e to 7438254 Compare June 19, 2020 15:31
@calumgrant
Copy link
Contributor Author

@calumgrant calumgrant force-pushed the cs/unqualify-trap-ids2 branch from 7438254 to b4bc96a Compare June 30, 2020 14:52
@calumgrant
Copy link
Contributor Author

calumgrant commented Jun 30, 2020

@hvitved
Copy link
Contributor

hvitved commented Jul 2, 2020

Started differences job https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/260/

g/dotnet/efcore | 2299 | 4713 | 2.05002

:-(

@calumgrant calumgrant force-pushed the cs/unqualify-trap-ids2 branch from a46cb79 to e03971f Compare July 30, 2020 15:38
@adityasharad adityasharad changed the base branch from master to main August 14, 2020 18:34
@calumgrant calumgrant closed this Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants