Skip to content

Commit c7d5852

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [2022.3] [SRPF] Fix an exception when delegate target is empty
.Net 8 and .Net Standard have a different behaviour for RuntimeHelpers.GetHashCode In .Net 8 it's acceptable to pass null. https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.runtimehelpers.gethashcode?view=net-8.0 In Standard it's not. https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.runtimehelpers.gethashcode?view=netstandard-2.1
1 parent df6f5c3 commit c7d5852

File tree

1 file changed

+1
-1
lines changed
  • Packages/com.unity.render-pipelines.core/Runtime/Utilities

1 file changed

+1
-1
lines changed

Packages/com.unity.render-pipelines.core/Runtime/Utilities/HashFNV1A32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void Append(Delegate del)
112112
[MethodImpl(MethodImplOptions.AggressiveInlining)]
113113
internal static int GetFuncHashCode(Delegate del)
114114
{
115-
return del.Method.GetHashCode() ^ RuntimeHelpers.GetHashCode(del.Target);
115+
return del.Method.GetHashCode() ^ (del.Target != null ? RuntimeHelpers.GetHashCode(del.Target) : 0);
116116
}
117117

118118
public int value => (int)m_Hash;

0 commit comments

Comments
 (0)