Skip to content

C#: Extract different trivia types#4976

Closed
tamasvajk wants to merge 27 commits into
github:mainfrom
tamasvajk:feature/trivias
Closed

C#: Extract different trivia types#4976
tamasvajk wants to merge 27 commits into
github:mainfrom
tamasvajk:feature/trivias

Conversation

@tamasvajk
Copy link
Copy Markdown
Contributor

@tamasvajk tamasvajk commented Jan 19, 2021

This PR extracts preprocessor directives from Roslyn trivias.

Missing

  • stats
  • db upgrade folder
  • diff job
  • change notes

@github-actions github-actions Bot added the C# label Jan 19, 2021
@tamasvajk tamasvajk force-pushed the feature/trivias branch 3 times, most recently from 48de5e4 to 3684b3c Compare January 20, 2021 07:32
@tamasvajk tamasvajk requested a review from hvitved January 20, 2021 15:53
@tamasvajk

This comment has been minimized.

@tamasvajk tamasvajk force-pushed the feature/trivias branch 3 times, most recently from c2546ed to 8dc04c0 Compare January 21, 2021 12:40
@tamasvajk tamasvajk marked this pull request as ready for review January 22, 2021 09:22
@tamasvajk tamasvajk requested a review from a team as a code owner January 22, 2021 09:22
Copy link
Copy Markdown
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.

Great work, Tamas. And thanks for splitting it up into separately reviewable commits.

if (!cx.Extractor.Standalone)
{
var assembly = Assembly.CreateOutputAssembly(cx);
trapFile.preprocessor_directive_assembly(this, assembly);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be better to map to the compilation instead? I realize that the output assembly will, in most cases, determine the compilation, but we might have two compilations that output the same assembly.

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.

We could do that, but I think we would need to change the Compilation to be a cached entity then. Should I do it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or perhaps just store it in a field on the Context?

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.

I thought this would work, but adding the compilation entity to the context is also not straightforward for two reasons:

  • syntax tree extraction and compilation extraction have different context instances,
  • extraction happens on multiple threads, so we can't be sure that compilation is extracted before directives.

Comment thread csharp/ql/src/semmle/code/csharp/Preprocessor.qll Outdated
Comment thread csharp/ql/src/semmle/code/csharp/Preprocessor.qll Outdated
Comment thread csharp/ql/src/semmle/code/csharp/Preprocessor.qll Outdated
Comment thread csharp/ql/src/semmle/code/csharp/Preprocessor.qll Outdated
Comment thread csharp/ql/src/semmle/code/csharp/Preprocessor.qll Outdated
Comment thread csharp/ql/src/semmle/code/csharp/Preprocessor.qll Outdated
or
e instanceof TupleType
or
e instanceof ConditionalDirective
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not include all preprocessor directives?

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.

We can do that, but only ConditionalDirectives have expressions underneath them.

Comment thread csharp/ql/src/semmle/code/csharp/Preprocessor.qll Outdated
Comment thread csharp/ql/src/semmlecode.csharp.dbscheme Outdated
Comment thread csharp/ql/src/semmlecode.csharp.dbscheme Outdated
@tamasvajk tamasvajk force-pushed the feature/trivias branch 2 times, most recently from ed204e9 to 5e114db Compare January 28, 2021 09:17
@tamasvajk
Copy link
Copy Markdown
Contributor Author

Closing this in favour of #5005

@tamasvajk tamasvajk closed this Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants