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

Include file name in Contract failures #73092

Merged
merged 1 commit into from
Apr 19, 2024
Merged

Include file name in Contract failures #73092

merged 1 commit into from
Apr 19, 2024

Conversation

jaredpar
Copy link
Member

This adds the file names to the messages generated by contract failures. This information would've made it significantly easier to debug a recent DDRIT failure.

This adds the file names to the messages generated by contract failures.
This information would've made it _significantly_ easier to debug a
recent DDRIT failure.
@jaredpar jaredpar requested a review from a team as a code owner April 18, 2024 23:24
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 18, 2024
@jaredpar
Copy link
Member Author

@CyrusNajmabadi want to make sure you saw this PR as you added the [CallerLineInfo] in #53916. Wanted to make sure there wasn't a specific reason you excluded the file name when you did this.

@@ -48,11 +49,11 @@ internal static partial class Contract
/// all builds
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ThrowIfNull<T>([NotNull] T value, string message, [CallerLineNumber] int lineNumber = 0)
public static void ThrowIfNull<T>([NotNull] T value, string message, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string? filePath = null)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: the filePath is last specifically to avoid ambiguities with Contract methods that take an explicit string message like this one.

@CyrusNajmabadi
Copy link
Member

Sounds great!

@jaredpar jaredpar enabled auto-merge (squash) April 19, 2024 00:18
@CyrusNajmabadi
Copy link
Member

What was the error btw?

@jaredpar
Copy link
Member Author

Test failure is a known flaky issue.

@jaredpar jaredpar merged commit b543bdf into dotnet:main Apr 19, 2024
22 of 25 checks passed
@jaredpar jaredpar deleted the name branch April 19, 2024 18:20
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 19, 2024
@dibarbet dibarbet modified the milestones: Next, 17.11 P1 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants