Skip to content

Fix for #1568 when RaiseAsync with a void Delegate returns null results in System.NullReferenceException - #1571

Open
Keugon wants to merge 123 commits into
devlooped:mainfrom
Keugon:main
Open

Fix for #1568 when RaiseAsync with a void Delegate returns null results in System.NullReferenceException#1571
Keugon wants to merge 123 commits into
devlooped:mainfrom
Keugon:main

Conversation

@Keugon

@Keugon Keugon commented Jul 3, 2025

Copy link
Copy Markdown

Hi this is my best guess on improving information on issue when try to use the RaiseAsync() with a void Delegate with a more informativ Exception.

this is my first ever pullrequest and iam pretty sure i done many mistakes
#1568

Help Wanted here

@CLAassistant

CLAassistant commented Jul 3, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Keugon

Keugon commented Jul 28, 2025

Copy link
Copy Markdown
Author

is there more that i need to do so this can be considered?

@kzu

kzu commented Apr 8, 2026

Copy link
Copy Markdown
Member

void-returning async methods are a huge red flag in .NET. They lead to unobserved exceptions that can tear down a process. not sure we want to encourage that sort of design... 🤔

@kzu

kzu commented Apr 8, 2026

Copy link
Copy Markdown
Member

I'll still merge it because it's not introducing a breaking change from something that previously worked (nobody would set up this previously), so it's new behavior. Although there is a slight chance that someone was relying on the previous (unrelated) exception to catch this scenario (think: a pseudo-verification by side-effect), that would have been quite unlikely, I'd say.

@kzu
kzu enabled auto-merge (rebase) April 8, 2026 04:04
@Keugon

Keugon commented Apr 9, 2026

Copy link
Copy Markdown
Author

@kzu do i need to do anything here, iam still not very familiar with github and opensource repos, i just work with a local gitlab on company repos.

If i need to take action here please tell me

devlooped-bot and others added 19 commits April 15, 2026 00:25
# devlooped/oss

- Enhance documentation instructions for project work devlooped/oss@e616d89
- Use GH_TOKEN if available for PR devlooped/oss@77e83f2
- Switch to dotnet-env for .NET SDK setup devlooped/oss@56c2b85
- Update Directory.Build.props with support for underscores in branch name devlooped/oss@81d972f
- Add Company MSBuild property by default devlooped/oss@c509be4
- Switch to dnx retest shorthand devlooped/oss@fddfd89
- Disable warnings for non-packable test projects devlooped/oss@95b338b
- Update versioning scheme in Directory.Build.props devlooped/oss@f2400ef
- Enable package pruning in Directory.Build.props devlooped/oss@0ff8b7b
- Ensure quiet confirmation of tool download/install devlooped/oss@e11b002
- Ensure dnx run succeeds even on Windows devlooped/oss@7f5f9ee
- Enhance include workflow with OSMF EULA support devlooped/oss@f2050db
- Trim whitespace in file content replacement devlooped/oss@e53557f
- Fix path pattern for markdown files in workflow devlooped/oss@6a6de05
- Fix error message quotes in includes.yml devlooped/oss@26e8cb7
- Change label from 'docs' to 'dependencies' devlooped/oss@2d1fb4e
- Avoid failure on PR creation if osmfeula.txt doesn't exist in repo devlooped/oss@8ff5178
- Update create-pull-request action to version 8 devlooped/oss@0662872
- If the OSMF eula is present, switch to its license file devlooped/oss@4b84c54
- Ignore sponsorlink sources in formatting devlooped/oss@f571a42
- Change file type from None to Content for osmfeula.txt devlooped/oss@fd03672
- Add Pack attribute to OSMFEULA content item devlooped/oss@dd13ed3
- SponsorLink code should be checked as regular code devlooped/oss@e81ab75
- Ignore .env files recursively devlooped/oss@3776526
- Ignore *.local recursively devlooped/oss@a225b7a
- Improve default Product metadata, remove .git from user-facing URLs devlooped/oss@4339749
- Consider either None or Content for OSMF license patching devlooped/oss@083a37b
- Set severity of IDE1100 to none devlooped/oss@1ed9afe
- Set explicit tab size and eol for code files devlooped/oss@5dba0d0
- Revert EOL change in editorconfig for C# files devlooped/oss@2d0e5a5
- Revert indent size for project files devlooped/oss@a62c459
- Group MEAI packages together devlooped/oss@e733294
- Cap rate limit wait at 5 minutes, abort if longer devlooped/oss@61a602f
- Update branches for push event in build.yml devlooped/oss@5da103c
⬆️ Bump files with dotnet-file sync
Bumps Microsoft.Extensions.Logging.Abstractions from 8.0.1 to 10.0.9

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Logging.Abstractions
  dependency-version: 10.0.9
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: extensions
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps Microsoft.NET.Test.Sdk from 17.14.0 to 18.6.0
Bumps xunit.runner.visualstudio from 3.1.0 to 3.1.5

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.6.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: tests
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.6.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: tests
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.6.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: tests
- dependency-name: xunit.runner.visualstudio
  dependency-version: 3.1.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: tests
- dependency-name: xunit.runner.visualstudio
  dependency-version: 3.1.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: tests
- dependency-name: xunit.runner.visualstudio
  dependency-version: 3.1.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: tests
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps System.ValueTuple from 4.6.1 to 4.6.2

---
updated-dependencies:
- dependency-name: System.ValueTuple
  dependency-version: 4.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: system
- dependency-name: System.ValueTuple
  dependency-version: 4.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: system
...

Signed-off-by: dependabot[bot] <support@github.com>
# devlooped/oss

- Refactor GitHub Actions workflows to use unified PR_TOKEN for authentication and add skip PR creation warning devlooped/oss@7c1c6e6
- Add 'agent-tools' to .gitignore devlooped/oss@ff61659
- Fix empty default path for NuGet SDK targets devlooped/oss@c679525
- Fix PackageId default from Pack SDK devlooped/oss@6e24389
- Add OpenTelemetry patterns to dependabot config devlooped/oss@387f061
kzu and others added 16 commits June 24, 2026 19:38
…ent FileLoadException on .NET Framework

- Only register Task/Task<> eagerly in AwaitableFactory static init
- Use FullName string checks + reflection/Activator for ValueTask provider creation
- Update Mock.RaiseEvent to use runtime FullName checks for ValueTask too
- Add regression test Issue1648 exercising TryGet(Task) + runtime VT simulation
- Update changelog

Tests and ildasm confirm cctor no longer contains ValueTask tokens.
…for cold-load isolation proof

- Remove brittle AppDomain loader that failed on assembly identity.
- Rely on ColdLoadVerifier.exe (separate exe, no VT tokens) + main TryGet asserts for verif plan step 4 proof.
- Still exercises real shipped AwaitableFactory.TryGet directly.
- Fresh successful COLD-LOAD-SUCCESS transcript captured in scratch.
…nsions on .NET FW

- #if split: LegacyAwaitableFactory (net462/netstandard2.0) eagerly
  registers only Task/Task<>; ValueTask via FullName + deferred
  Activator (no typeof(ValueTask) in cctor or cold paths).
- Modern (netstandard2.1+) AwaitableFactory is direct with no
  static cctor, isolated VT handling.
- Committed standalone harness exe (Moq.Tests.Issue1648Harness)
  preloads 4.5.4, hooks resolve (throws real FileLoad on hit),
  does cold LoadFrom of Moq net462 + TryGet(Task) only.
- Thin xunit test launches prebuilt harness under conflict and
  asserts on shipped TryGet; plus runtime IL guard for cctor.
- Verification script for mechanical clean logs in mandated scratch.
- Hard require for real older mismatch version; no fallbacks.

Fixes devlooped#1648
…the devlooped#1648 regression

- Ensures 'Harness exe not found' no longer happens on net472 test runs.
- Test updated to strictly require the harness-dir ext (no arbitrary fallback).
…back compile of committed driver)

- Reference the harness project so net472 test builds produce the exe.
- Fallback in Find uses CodeDom on the committed Program.cs when prebuilt layout not discoverable.
- Strict require for ext from harness dir; version check.
- Test still drives shipped code via the (prebuilt or temp compiled) driver exe.
Bumps Microsoft.NET.Test.Sdk from 18.6.0 to 18.7.0

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: tests
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: tests
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: tests
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [concurrent-ruby](https://github.com/ruby-concurrency/concurrent-ruby) from 1.1.9 to 1.3.7.
- [Release notes](https://github.com/ruby-concurrency/concurrent-ruby/releases)
- [Changelog](https://github.com/ruby-concurrency/concurrent-ruby/blob/master/CHANGELOG.md)
- [Commits](ruby-concurrency/concurrent-ruby@v1.1.9...v1.3.7)

---
updated-dependencies:
- dependency-name: concurrent-ruby
  dependency-version: 1.3.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
@kzu

kzu commented Jul 1, 2026

Copy link
Copy Markdown
Member

@copilot rebase on main and fix conflicts

dependabot Bot and others added 3 commits July 1, 2026 20:23
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.5 to 3.3.9.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](ruby/rexml@v3.2.5...v3.3.9)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
# devlooped/oss

- fix: support robust NuGetize pack delegation for PackFolder=build projects (devlooped#39) devlooped/oss@dcd5f0a
Bumps [addressable](https://github.com/sporkmonger/addressable) from 2.8.0 to 2.9.0.
- [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md)
- [Commits](sporkmonger/addressable@addressable-2.8.0...addressable-2.9.0)

---
updated-dependencies:
- dependency-name: addressable
  dependency-version: 2.9.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
@kzu

kzu commented Jul 2, 2026

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

1 similar comment
@kzu

kzu commented Aug 21, 2026

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

@kzu

kzu commented Aug 21, 2026

Copy link
Copy Markdown
Member

@Keugon seems like copilot doesn't know how to resolve a conflict. if you still care about this getting merged, plz rebase on top of main and force-push to your fork branch so this PR updates and can be merged cleanly. Thanks

@Keugon

Keugon commented Aug 21, 2026

Copy link
Copy Markdown
Author

@Keugon seems like copilot doesn't know how to resolve a conflict. if you still care about this getting merged, plz rebase on top of main and force-push to your fork branch so this PR updates and can be merged cleanly. Thanks

Will do that on monday!

auto-merge was automatically disabled August 30, 2026 08:33

Head branch was pushed to by a user without write access

@Keugon

Keugon commented Aug 30, 2026

Copy link
Copy Markdown
Author

i rebased the fix but have issues on 2 tests
Can_raise_parameterized_async_event_using_RaiseAsync
Can_raise_async_event_using_RaiseAsync
as they are void but archive to not result in return null in internal static object? RaiseEvent(Mock mock, LambdaExpression expression, Stack<MethodExpectation> parts, object?[] arguments)

i need some help here to either adjust my raised exception on all void delegates or its fine to remove those tests as i cant decide if those are still valid scenarios? @kzu

@kzu

kzu commented Aug 31, 2026

Copy link
Copy Markdown
Member

deleting tests that ensure existing behavior remains valid is rarely a good idea :)

I'd put a good AI to spend high-reasoning tokens to figure it out if possible.

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.

6 participants