handzlikchris / handzlikchris/FastScriptReload

New Private field method access issue [Workaround]

オープン
#121 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
workaround
主要言語
C#
スター
2.2k
フォーク
167
PR マージ指標
30日以内にマージされた PR はありません

説明

## Current Workaround

So it seems this is the workaround for now. Any direct access the new field breaks the rewritter.

```c#
_instanceNewField.DoesWhatYouWant(); //<- fails to rewrite
var myLocalNewField = _instanceNewField; // <- this gets correctly rewritten
myLocalNewField.DoesWhatYouWant(); //<- All good
```
Then on your next recompilation round you can clean up the syntax.

## Issue
I'm not sure if it's a regression and what would be its reason, but most of the time nowadays adding private fields fails as they are not rewritten correctly in every places. Example bellow.
Added
`private CameraState _lastCamState;`

One of the correctly rewritten part I believe
`FastScriptReload.Scripts.Runtime.TemporaryNewFieldValues.ResolvePatchedObject(this)._lastCamState = state;`

Some other places not rewritten
` Gizmos.DrawWireSphere(_lastCamState.FinalPosition, BodyRadius);`

It is the NewFieldsRewriter job to perform the rewrite now not sure why it skip some cases.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

NewFieldsRewriterから始め、Unityのホットリロードワークフローで報告されたprivateフィールドへのアクセスケースを再現します。_instanceNewFieldへの直接アクセスとローカル変数を使った回避策を比較し、そのうえで、Gizmos.DrawWireSphere(_lastCamState.FinalPosition, BodyRadius)のような使用箇所が、構文のクリーンアップを必要とせず一貫して書き換えられることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, unity
領域
devtools, game-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。