Skip to content

Conversation

jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Oct 6, 2025

Fix the dirty-check which ensures that the committed versions of src/Sentry.Bindings.Cocoa/ApiDefinitions.cs and StructsAndDefinitions.cs are up-to-date after Cocoa SDK updates, as they are automatically re-generated by the build system:

<Exec Command="pwsh ../../scripts/generate-cocoa-bindings.ps1" />
<!-- See https://github.com/getsentry/sentry-dotnet/pull/2558 -->
<Exec Condition="'$(GITHUB_ACTIONS)' == 'true'" Command="pwsh ../../scripts/dirty-check.ps1 -PathToCheck $(MSBuildThisFileDirectory)" />

The problem was that sentry-cocoa.properties and generate-cocoa-bindings.ps1 alone were not sufficient inputs for MSBuild to trigger _GenerateSentryCocoaBindings, so the bindings were not re-generated in the CI. Adding framework headers, which are the effective sources for the bindings, helps. With this change, the build / .NET (macos) CI job fails with:

Generating bindings with Objective Sharpie.
[...]
  Done.
  Patching /Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.Bindings.Cocoa/StructsAndEnums.cs
  Patching /Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
  diff --git a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
  index f33b1c6..2c076dd 100644
  --- a/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
  +++ b/src/Sentry.Bindings.Cocoa/ApiDefinitions.cs
  @@ -416,9 +416,9 @@ interface SentryEnvelopeItemHeader : SentrySerializable
       [Export ("initWithType:length:filenname:contentType:")]
       NativeHandle Constructor (string type, nuint length, string filename, string contentType);
   
  -    // -(instancetype _Nonnull)initWithType:(NSString * _Nonnull)type length:(NSUInteger)length contentType:(NSString * _Nonnull)contentType itemCount:(NSNumber * _Nonnull)itemCount;
  +    // -(instancetype _Nonnull)initWithType:(NSString * _Nonnull)type length:(NSUInteger)length contentType:(NSString * _Nullable)contentType itemCount:(NSNumber * _Nonnull)itemCount;
       [Export ("initWithType:length:contentType:itemCount:")]
  -    NativeHandle Constructor (string type, nuint length, string contentType, NSNumber itemCount);
  +    NativeHandle Constructor (string type, nuint length, [NullAllowed] string contentType, NSNumber itemCount);
   
       // @property (readonly, copy, nonatomic) NSString * _Nonnull type;
       [Export ("type")]
  Write-Error: /Users/runner/work/sentry-dotnet/sentry-dotnet/scripts/dirty-check.ps1:14
  Line |
    14 |      Write-Error "$GuidanceOnFailure"
       |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | Dirty files detected.
/Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj(134,5): error MSB3073: The command "pwsh ../../scripts/dirty-check.ps1 -PathToCheck /Users/runner/work/sentry-dotnet/sentry-dotnet/src/Sentry.Bindings.Cocoa/" exited with code 1. [TargetFramework=once]

Came up in:

#skip-changelog

Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.49%. Comparing base (ad849d4) to head (95460b9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4600      +/-   ##
==========================================
+ Coverage   73.45%   73.49%   +0.03%     
==========================================
  Files         482      482              
  Lines       17678    17678              
  Branches     3493     3493              
==========================================
+ Hits        12986    12993       +7     
+ Misses       3801     3797       -4     
+ Partials      891      888       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi jpnurmi changed the title ci: add dirty-check for generated Cocoa bindings ci: fix dirty-check for generated Cocoa bindings Oct 6, 2025
@jpnurmi jpnurmi marked this pull request as ready for review October 6, 2025 19:42
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
<SentryCocoaBindingInputs>../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1</SentryCocoaBindingInputs>
<SentryCocoaBindingInputs>../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1;$(SentryCocoaFrameworkHeaders)**/*.h</SentryCocoaBindingInputs>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Strange that the headers could change without the sentry-cocoa.properties changing (i.e. the version of the Sentry Cocoa SDK changing)... but yeah sure, the headers are ultimately what drives the generated code.

@jamescrosswell jamescrosswell merged commit 3dd2803 into main Oct 6, 2025
34 checks passed
@jamescrosswell jamescrosswell deleted the ci/dirty-check-cocoa-bindings branch October 6, 2025 21:20
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