Skip to content

Conversation

medhatiwari
Copy link
Contributor

@medhatiwari medhatiwari commented Oct 12, 2025

Summary

Fixes the remaining 2 failing StackTraceHelper tests from #63927 by making tests runtime-agnostic instead of expecting exact string matches for runtime internals.

Problem

Tests were failing on Mono due to strict string matching against runtime-specific formatting:

  • Lambda methods: Expected "lambda_method34" but Mono shows "object.lambda_method34"
  • Async state machines: Expected resolved method names but Mono shows state machine internals

Solution

Updated tests to verify essential functionality while accepting different valid runtime behaviors:

  • Lambda test: Changed from Assert.StartsWith("lambda_method") to Assert.Contains("lambda_method")
  • Async test: Added flexible checks that accept both resolved method names and state machine forms

cc: @giritrivedi

@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Oct 12, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 12, 2025
@ilonatommy ilonatommy added area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Oct 17, 2025
var methodNames = stackFrames.Select(stackFrame => stackFrame.MethodDisplayInfo.ToString()).ToList();

// Assert - Runtime-agnostic checks for essential stack trace components
// Instead of exact string matching, verify key components are present
Copy link
Member

Choose a reason for hiding this comment

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

While you are still verifying that key components are present, it does mean that we are a bit less strict in CoreCLR which could be a potential for regressions. Would it make sense to instead of relaxing some of these matches, to instead first do a Runtime check to see if running under CoreCLR or Mono, and then if CoreCLR we keep the stricter checks but for Mono we just validate key components? This way you are not losing any regression coverage, but you are making the tests pass on more runtimes.

Copy link
Contributor Author

@medhatiwari medhatiwari Oct 21, 2025

Choose a reason for hiding this comment

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

@joperezr Good point! I've updated it with runtime-specific assertions as you suggested

@joperezr
Copy link
Member

Thank you so much for your contribution @medhatiwari! Left a small comment that would be good if you could address, but otherwise this is looking really good 😃

@medhatiwari
Copy link
Contributor Author

Thank you so much for your contribution @medhatiwari! Left a small comment that would be good if you could address, but otherwise this is looking really good 😃

Thanks for reviewing the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants