Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Update .NET 9 generated models. #18717

Merged
merged 6 commits into from
Feb 11, 2025

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Feb 7, 2025

In this PR we

  • Update the .NET runtime models to be based on .NET 9.
  • Minor change to the dispatch logic involving generated summaries to align with Java (only disregard generated summaries in case there is a static call target). Reasoning for only disregarding when there is a static call target can be found here. This also turned out to solve a minor idempotency issue.
  • A change to the fieldOrPropertyStore logic for when we consider a property to be field like. The database for .NET Runtime contains both a real and a stub implementation af all classes and members. Specifically for properties, it is a common pattern that the real implementation of a property is an auto property and the stub implementation is implemented with dummy bodies. AFAICT from the extracted information there is no good way to identify this, except that we can use the source location to get an indication that we have multiple property declarations. That is, we introduce a new helper predicate and assume that there exist an auto implementation of a property, if it holds for each accessor, that the accessor has more source locations than bodies (auto properties have no bodies extracted). This also fixes an idempotency issue. This enables the model generator to generate many extra models for .NET runtime.

DCA looks good.

  • There are no performance regressions.
  • The two new cs/hardcoded-credentials ASP.NET Core are due to the generated model ["System.IO", "Stream", True, "WriteAsync", "(System.ReadOnlyMemory<System.Byte>,System.Threading.CancellationToken)", "", "Argument[0]", "Argument[this]", "taint", "df-generated"] appears to be sound.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

csharp

Generated file changes for csharp

  • Changes to framework-coverage-csharp.rst:
-    System,"``System.*``, ``System``",47,10864,54,5
+    System,"``System.*``, ``System``",47,12221,54,5
-    Others,"``Amazon.Lambda.APIGatewayEvents``, ``Amazon.Lambda.Core``, ``Dapper``, ``ILCompiler``, ``ILLink.RoslynAnalyzer``, ``ILLink.Shared``, ``ILLink.Tasks``, ``Internal.IL``, ``Internal.Pgo``, ``Internal.TypeSystem``, ``JsonToItemsTaskFactory``, ``Microsoft.Android.Build``, ``Microsoft.Apple.Build``, ``Microsoft.ApplicationBlocks.Data``, ``Microsoft.AspNetCore.Components``, ``Microsoft.AspNetCore.Http``, ``Microsoft.AspNetCore.Mvc``, ``Microsoft.AspNetCore.WebUtilities``, ``Microsoft.CSharp``, ``Microsoft.Diagnostics.Tools.Pgo``, ``Microsoft.DotNet.Build.Tasks``, ``Microsoft.DotNet.PlatformAbstractions``, ``Microsoft.EntityFrameworkCore``, ``Microsoft.Extensions.Caching.Distributed``, ``Microsoft.Extensions.Caching.Memory``, ``Microsoft.Extensions.Configuration``, ``Microsoft.Extensions.DependencyInjection``, ``Microsoft.Extensions.DependencyModel``, ``Microsoft.Extensions.Diagnostics.Metrics``, ``Microsoft.Extensions.FileProviders``, ``Microsoft.Extensions.FileSystemGlobbing``, ``Microsoft.Extensions.Hosting``, ``Microsoft.Extensions.Http``, ``Microsoft.Extensions.Logging``, ``Microsoft.Extensions.Options``, ``Microsoft.Extensions.Primitives``, ``Microsoft.Interop``, ``Microsoft.JSInterop``, ``Microsoft.NET.Build.Tasks``, ``Microsoft.NET.Sdk.WebAssembly``, ``Microsoft.NET.WebAssembly.Webcil``, ``Microsoft.VisualBasic``, ``Microsoft.WebAssembly.Build.Tasks``, ``Microsoft.Win32``, ``Mono.Linker``, ``MySql.Data.MySqlClient``, ``Newtonsoft.Json``, ``SourceGenerators``, ``Windows.Security.Cryptography.Core``",61,2075,152,4
+    Others,"``Amazon.Lambda.APIGatewayEvents``, ``Amazon.Lambda.Core``, ``Dapper``, ``ILCompiler``, ``ILLink.RoslynAnalyzer``, ``ILLink.Shared``, ``ILLink.Tasks``, ``Internal.IL``, ``Internal.Pgo``, ``Internal.TypeSystem``, ``Microsoft.ApplicationBlocks.Data``, ``Microsoft.AspNetCore.Components``, ``Microsoft.AspNetCore.Http``, ``Microsoft.AspNetCore.Mvc``, ``Microsoft.AspNetCore.WebUtilities``, ``Microsoft.CSharp``, ``Microsoft.Diagnostics.Tools.Pgo``, ``Microsoft.DotNet.Build.Tasks``, ``Microsoft.DotNet.PlatformAbstractions``, ``Microsoft.EntityFrameworkCore``, ``Microsoft.Extensions.Caching.Distributed``, ``Microsoft.Extensions.Caching.Memory``, ``Microsoft.Extensions.Configuration``, ``Microsoft.Extensions.DependencyInjection``, ``Microsoft.Extensions.DependencyModel``, ``Microsoft.Extensions.Diagnostics.Metrics``, ``Microsoft.Extensions.FileProviders``, ``Microsoft.Extensions.FileSystemGlobbing``, ``Microsoft.Extensions.Hosting``, ``Microsoft.Extensions.Http``, ``Microsoft.Extensions.Logging``, ``Microsoft.Extensions.Options``, ``Microsoft.Extensions.Primitives``, ``Microsoft.Interop``, ``Microsoft.JSInterop``, ``Microsoft.NET.Build.Tasks``, ``Microsoft.VisualBasic``, ``Microsoft.Win32``, ``Mono.Linker``, ``MySql.Data.MySqlClient``, ``Newtonsoft.Json``, ``SourceGenerators``, ``Windows.Security.Cryptography.Core``",60,2272,152,4
-    Totals,,108,12946,400,9
+    Totals,,107,14500,400,9
  • Changes to framework-coverage-csharp.csv:
- ILCompiler,,,123,,,,,,,,,,,,,,,,,,,79,44
+ ILCompiler,,,121,,,,,,,,,,,,,,,,,,,77,44
- ILLink.RoslynAnalyzer,,,139,,,,,,,,,,,,,,,,,,,50,89
+ ILLink.RoslynAnalyzer,,,107,,,,,,,,,,,,,,,,,,,31,76
- ILLink.Shared,,,31,,,,,,,,,,,,,,,,,,,11,20
+ ILLink.Shared,,,37,,,,,,,,,,,,,,,,,,,11,26
- Internal.TypeSystem,,,329,,,,,,,,,,,,,,,,,,,201,128
+ Internal.TypeSystem,,,345,,,,,,,,,,,,,,,,,,,205,140
- JsonToItemsTaskFactory,,,11,,,,,,,,,,,,,,,,,,,1,10
- Microsoft.Android.Build,,1,14,,,,,,,,,,,,,1,,,,,,12,2
- Microsoft.Apple.Build,,,7,,,,,,,,,,,,,,,,,,,7,
- Microsoft.Diagnostics.Tools.Pgo,,,25,,,,,,,,,,,,,,,,,,,2,23
+ Microsoft.Diagnostics.Tools.Pgo,,,23,,,,,,,,,,,,,,,,,,,,23
- Microsoft.DotNet.Build.Tasks,,,10,,,,,,,,,,,,,,,,,,,8,2
+ Microsoft.DotNet.Build.Tasks,,,11,,,,,,,,,,,,,,,,,,,9,2
- Microsoft.Extensions.Configuration,,3,101,,,,,,,,,,,,,3,,,,,,29,72
+ Microsoft.Extensions.Configuration,,3,123,,,,,,,,,,,,,3,,,,,,40,83
- Microsoft.Extensions.DependencyInjection,,,202,,,,,,,,,,,,,,,,,,,15,187
+ Microsoft.Extensions.DependencyInjection,,,209,,,,,,,,,,,,,,,,,,,15,194
- Microsoft.Extensions.DependencyModel,,1,16,,,,,,,,,,,,,1,,,,,,14,2
+ Microsoft.Extensions.DependencyModel,,1,57,,,,,,,,,,,,,1,,,,,,13,44
- Microsoft.Extensions.FileProviders,,,17,,,,,,,,,,,,,,,,,,,7,10
+ Microsoft.Extensions.FileProviders,,,18,,,,,,,,,,,,,,,,,,,8,10
- Microsoft.Extensions.FileSystemGlobbing,,,21,,,,,,,,,,,,,,,,,,,10,11
+ Microsoft.Extensions.FileSystemGlobbing,,,37,,,,,,,,,,,,,,,,,,,13,24
- Microsoft.Extensions.Hosting,,,58,,,,,,,,,,,,,,,,,,,29,29
+ Microsoft.Extensions.Hosting,,,61,,,,,,,,,,,,,,,,,,,29,32
- Microsoft.Extensions.Logging,,,91,,,,,,,,,,,,,,,,,,,25,66
+ Microsoft.Extensions.Logging,,,107,,,,,,,,,,,,,,,,,,,26,81
- Microsoft.Extensions.Options,,,68,,,,,,,,,,,,,,,,,,,44,24
+ Microsoft.Extensions.Options,,,174,,,,,,,,,,,,,,,,,,,48,126
- Microsoft.Extensions.Primitives,,,73,,,,,,,,,,,,,,,,,,,67,6
+ Microsoft.Extensions.Primitives,,,76,,,,,,,,,,,,,,,,,,,67,9
- Microsoft.Interop,,,159,,,,,,,,,,,,,,,,,,,75,84
+ Microsoft.Interop,,,216,,,,,,,,,,,,,,,,,,,71,145
- Microsoft.NET.Sdk.WebAssembly,,,2,,,,,,,,,,,,,,,,,,,1,1
- Microsoft.NET.WebAssembly.Webcil,,,6,,,,,,,,,,,,,,,,,,,6,
- Microsoft.WebAssembly.Build.Tasks,,,9,,,,,,,,,,,,,,,,,,,8,1
- Mono.Linker,,,293,,,,,,,,,,,,,,,,,,,145,148
+ Mono.Linker,,,280,,,,,,,,,,,,,,,,,,,129,151
- System,54,47,10864,,6,5,5,,,4,1,,33,2,,6,15,17,4,3,,5547,5317
+ System,54,47,12221,,6,5,5,,,4,1,,33,2,,6,15,17,4,3,,5921,6300

@michaelnebel michaelnebel marked this pull request as ready for review February 10, 2025 10:34
@Copilot Copilot bot review requested due to automatic review settings February 10, 2025 10:34
@michaelnebel michaelnebel requested a review from a team as a code owner February 10, 2025 10:34

Choose a reason for hiding this comment

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

PR Overview

This pull request updates the generated .NET runtime models to be based on .NET 9, and also makes minor adjustments to the dispatch logic and property handling in the generated summaries and field-like property determination.

  • Updates the generated models to use .NET 9.
  • Adjusts the dispatch logic to disregard generated summaries when there is a static call target.
  • Modifies the fieldOrPropertyStore logic to better identify auto properties and resolve idempotency issues.

Changes

File Description
csharp/ql/lib/change-notes/2025-02-07-dotnet-models.md Adds change note documentation for .NET 9 models

Copilot reviewed 168 out of 168 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

csharp/ql/lib/change-notes/2025-02-07-dotnet-models.md:5

  • [nitpick] The version label 'C# 13' may be confusing given that this update focuses on .NET 9 models; please clarify if the label is intentional or if it should reference .NET 9 instead.
* C# 13: Add generated models for .NET 9.

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

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.

One small suggestion, otherwise LGTM.

@michaelnebel michaelnebel force-pushed the csharp/updatenetmodels2 branch from d99e10a to 83f8a40 Compare February 11, 2025 12:46
@michaelnebel
Copy link
Contributor Author

DCA still looks good.

@michaelnebel michaelnebel merged commit be0b3ba into github:main Feb 11, 2025
20 checks passed
@michaelnebel michaelnebel deleted the csharp/updatenetmodels2 branch February 12, 2025 08:50
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.

2 participants