Skip to content

fix: resolve CS8170 and CS8347 compiler errors in Unity 6.5#250

Merged
neuecc merged 1 commit intoCysharp:mainfrom
chikacc:main
Apr 8, 2026
Merged

fix: resolve CS8170 and CS8347 compiler errors in Unity 6.5#250
neuecc merged 1 commit intoCysharp:mainfrom
chikacc:main

Conversation

@chikacc
Copy link
Copy Markdown
Contributor

@chikacc chikacc commented Mar 28, 2026

Description

Unity 6.5 introduces stricter C# lifetime checks, resulting in the following compilation errors in NativeArrayExtensions.cs:

  • CS8170: Struct members cannot return 'this' or other instance members by reference.
  • CS8347: Cannot use a result of an implicit operator because it may expose variables referenced by parameter 'source' outside of their declaration scope.

Solution

Added a version-specific fix using #if UNITY_6000_5_OR_NEWER to call .AsReadOnlySpan() explicitly. This bypasses the implicit operator's scope analysis while maintaining backward compatibility for older Unity versions.

Changes

  • File: NativeArrayExtensions.cs
  • Logic: Use explicit conversion for Unity 6000.5 and newer.

@neuecc
Copy link
Copy Markdown
Member

neuecc commented Apr 8, 2026

ok, thanks!

@neuecc neuecc merged commit 2923daf into Cysharp:main Apr 8, 2026
IhateTrains pushed a commit to ParadoxGameConverters/ImperatorToCK3 that referenced this pull request Apr 9, 2026
Updated [ZLinq](https://github.com/Cysharp/ZLinq) from 1.5.5 to 1.5.6.

<details>
<summary>Release notes</summary>

_Sourced from [ZLinq's
releases](https://github.com/Cysharp/ZLinq/releases)._

## 1.5.6

## What's Changed
* chore: Add settings to automatically update README.txt benchmark
reports link by @​filzrev in Cysharp/ZLinq#243
* chore: Update System.Linq compatibility tests to .Net 11 preview.2 by
@​filzrev in Cysharp/ZLinq#248
* fix: resolve CS8170 and CS8347 compiler errors in Unity 6.5 by
@​chikacc in Cysharp/ZLinq#250
* chore(deps): bump actions/upload-artifact from 6.0.0 to 7.0.0 in the
dependencies group by @​dependabot[bot] in
Cysharp/ZLinq#249

## New Contributors
* @​chikacc made their first contribution in
Cysharp/ZLinq#250

**Full Changelog**:
Cysharp/ZLinq@1.5.5...1.5.6

Commits viewable in [compare
view](Cysharp/ZLinq@1.5.5...1.5.6).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ZLinq&package-manager=nuget&previous-version=1.5.5&new-version=1.5.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

2 participants