Skip to content

fix(weaver): cross assembly NetworkBehaviour fixes - #1229

Merged
James-Frowen merged 4 commits into
mainfrom
weaver-cross-assembly-fixes
Nov 12, 2026
Merged

James-Frowen merged 4 commits into
mainfrom
weaver-cross-assembly-fixes

Conversation

@James-Frowen

Copy link
Copy Markdown
Member

No description provided.

…assemblies

Weaver weaves base types from referenced assemblies in memory because ILPP references are not post processed. Those modules used cecil's default reflection importer, so generated methods had types scoped to System.Private.CoreLib, which leaked into the weaved assembly when it called the base methods. Unity then refuses to load that assembly after an editor restart.
…stead of the base type's module

MakeHostInstanceGeneric and MatchGenericParameters imported into the base type's module. When the base type is in another assembly, type args from the weaved assembly get scoped to an assembly reference there, so re-importing them gives the weaved assembly a reference to itself, which Unity refuses to load after an editor restart.

MakeHostInstanceGeneric, GetMethodInBaseType and MatchGenericParameters now take the module that uses the reference.

Adds cross-assembly generic NetworkBehaviour tests, including a generic middle class.
…lared in another assembly

The non-generic field to property replacement used the base type's generated methods (and field type for ldflda/initobj) directly, which fails to write with 'declared in another module and needs to be imported'.

Adds tests setting SyncVar fields declared in another assembly. They only check server side values, syncing to clients is not supported for cross assembly SyncVar fields yet.
…ot compiled against

A bad import (eg the weaver's own System.Private.CoreLib, or an assembly referencing itself) writes fine and works until the editor restarts, then Unity refuses to load the assembly. Checking references before write turns that into a weaver error naming the reference.

Allowed references are the assembly's original references plus compiledAssembly.References, because the weaver can legitimately add references the compiler did not need.
@James-Frowen James-Frowen changed the title Weaver cross assembly fixes fix(weaver): cross assembly NetworkBehaviour fixes Nov 12, 2026
@James-Frowen
James-Frowen merged commit 88b6206 into main Nov 12, 2026
6 of 7 checks passed
@James-Frowen
James-Frowen deleted the weaver-cross-assembly-fixes branch November 12, 2026 20:17
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 159.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant