Essentials + extra crap

Loadings
Startups
Movement
Camera
This commit is contained in:
ThomasCharester committed 2026-01-12 18:43:51 +03:00
1 parent 662f4a1d05
commit 5f5ace1b52
734 files changed
+107323 -1713

No files matched your search

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a849b8376c6cae04b8dd2b8743cf2fb1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,708 @@
# Fast/Live Script Reload
Tool will allow you to iterate quicker on your code. You simply go into play mode, make a change to any file and it'll be compiled on the fly and hot-reloaded in your running play-mode session.
## Getting started
1) Import
2) Welcome screen will open - it contains all needed info to get started as well as support links and configuration.
`You can always get back to this screen via 'Window -> Fast/Live Script Reload -> Start Screen'`
3) Go to Launch Demo -> Basic Example window
4) Follow instructions listed there
> During startup asset will check if Unity Auto Refresh is enabled and offer to adjust it in order to work properly. Depending on your workflow you want it in 'EnabledOutsidePlaymode' or 'Disabled' - this is to ensure Unity will not trigger script compilation on changes and will let Fast Script Reload to work.
> Sometimes Unity can be quite stubborn and try to auto-reload scripts even with Auto-Reload turned off, if you can still see standard 'Reloading script assemblies' progress bar on change please go to:
> 'Window -> Fast Script Reload -> Start Screen -> Reload -> Force prevent assembly reload during playmode'.
> This way tool will lock reload in code when you enter playmode.
```
Example scene 'Point' material should automatically detect URP or surface shader
If it shows pink, please adjust by picking shader manually:
1) URP: 'Shader Graphs/Point URP'
2) Surface: 'Graph/Point Surface'
```
## On-Device Hot-Reload - Live Script reload
There's an addon to this tool - Live Script Reload - that'll allow you to use same functionality over the network in device build, eg:
- android (including VR headsets like Quest 2)
- standalone windows
[Find more details here](https://immersivevrtools.com/redirect/fast-script-reload/live-script-reload-extension)
**Live Script Reload is using Fast Script Reload as a base asset - documentation is combined, if you don't use Live Script Reload you can skip any sections in this document prefixed with [Live-Reload]**
## How Unity Hot Reload functionality is made? Technical Approach Breakdown
If you'd like to know how tool works from technical point of view - have a look at blog series which gets deeper into the subject:
[1) How to build Hot Reload For Unity](https://immersivevrtools.com/Blog/how-to-build-hot-reload-functionality-for-unity)
[2) Hot Reload - on device, (eg Android / Windows Exe)](https://immersivevrtools.com/Blog/how-to-build-unity-hot-reload-on-device)
## Reporting Compilation Errors
I've put lots of effort to test various code patterns in various codebases. Still - it's possible you'll find some instances where code would not compile, it's easiest to:
1) Look at compiler error and compare with generated source code, usually it'll be very obvious why issue is occuring
2) Refactor problematic part (look at limitations section as they'll explain how)
3) Let me know via support email and I'll get it fixed
## Executing custom code on hot reload
Custom code can be executed on hot reload by adding a method to changed script.
**You can see example by adjusting code in 'Graph.cs' file.**
```
void OnScriptHotReload()
{
//do whatever you want to do with access to instance via 'this'
}
```
```
static void OnScriptHotReloadNoInstance()
{
//do whatever you want to do without instance
//useful if you've added brand new type
// or want to simply execute some code without |any instance created.
//Like reload scene, call test function etc
}
```
## EXPERIMENTAL Adding New Fields
Asset has an experimental support for adding new fields at runtime which will also render in Editor and allow you to tweak values - same as with normal fields.
To enable, please:
`Window -> Fast Script Reload -> Start Window -> New Fields -> Enable experimental added field support`.
> As this is an experimental feature please expect it to break more often! It'd be great help if you could report any issues via Discord / email.
### New Fields - specific limitations
- outside classes can not call new fields added at runtime
- new fields will only show in editor if they were already used at least once
- eg if you've added a variable into a method, on first call that variable will be initialized and will start showing in editor
### New Fields - performance
For new fields to work your code will be adjusted. Instead of calling fields directly your code will call into a method that retrieves value from dynamic dictionary.
Due to that there'll be some overhead with:
- looking up proper object and new-field value in dictionary
- initializing values
- use of dynamic type, which will introduce some additional casts
> All that shouldn't really add too much overhead on dev-machine - you may lose few FPS though.
## EXPERIMENTAL In-editor Hot Reload (outside of playmode)
Asset has an experimental support for hot reload outside of playmode. However with limitations as they are now - it
is intended for some specific use cases (like iterating on editor scripts).
> **Feature is not intended as a replacement for Unity compile / reload mechanism**
To enable, please:
`Window -> Fast Script Reload -> Start Window -> Editor Hot-Reload -> Enable Hot-Reload outside of play mode`.
> As this is an experimental feature please expect it to break more often! It'd be great help if you could report any issues via Discord / email.
## Debugging
Debugging is fully supported although breakpoints in your original file won't be hit.
Once change is compiled, you'll get an option to open generated file [via clickable link in console window] in which you can set breakpoints.
Tool can also auto-open generated files for you on change for simpler access, you can find option via 'Window -> Fast Script Reload -> Start Screen -> Debugging -> Auto open generated source file for debugging'
> Debugging with Rider for Unity 2019 and 2020 is having some issues, you can only open debuggable files with auto-open feature. Clicking a file in console causes subtle static-variables reload (not full domain reload) that'll break your play-session.
### Adding Function Breakpoint
If for whatever reason debugger breakpoint is not hit you can try setting Function Breakpoint in your IDE.
For type name you want to include `<OriginalTypeName>__Patched_`, the `__Patched_` postfix is auto-added by asset to prevent name clash.
Function name remains unchanged.
## Production Build
For Fast Script Reload asset code will be excluded from any builds.
For Live Script Reload you should exclude it from final production build, do that via:
- 'Window -> Fast Script Reload -> Welcome Screen -> Build -> Enable Hot Reload For Build' - untick
**When building via File -> Build Settings - you'll also see Live Script Reload status under 'Build' button. You can click 'Adjust' button which will take you to build page for asset.**
```This is designed to make sure you don't accidentally build tool into release althoguh best approach would be to ensure your release process takes care of that.```
## User Defined Script Overrides
For asset to hot reload your changes it needs to make some adjustments to code. This could cause some issues as described in limitations section.
I continuously work on mitigating limitations. When they happen you can help yourself quickly by creating user defined script override.
Those are simply overrides on a per-file / method basis - when specified their contents will be used for final source code. Allowing you to simply fix any issues.
This is especially helpful with larger files.
### Replacing methods
You can replace existing methods by specifying their full signature in correct type - contents will be then replaced.
> If no match for the method signature is found it'll be ignored
For example, let's look at limitation with assigning Singleton to Instance using 'this' keyword
> That limitation is already solved although it'll serve as a clean example illustrating the feature
Following code:
```
public class MySingleton: MonoBehaviour {
public static MySingleton Instance;
void Start() {
Instance = this;
}
void SomeOtherMethod() {
//some other logic
}
}
```
Would be rewritten to:
```
public class MySingleton__Patched_: MonoBehaviour { //FSR: name change to include __Patched_ postfix to prevent name clashes
public static MySingleton Instance;
void Start() {
//assigning 'this' (now of type MySingleton__Patched_) to
//'Instance' of type MySingleton will now show compilation error due to type mismach
Instance = this;
}
void SomeOtherMethod() {
//some other logic
}
}
```
In that case you can create a user script rewrite override, to do so:
1) In Unity project panel right-click on 'MySingleton.cs'
2) Select `Fast Script Reload -> Add \ Open User Script Rewrite Override`
3) Asset will create override file for you with some template already in (there's also description in top comment how to use)
Override:
```
public class MySingleton__Patched_: MonoBehaviour {
void Start() { //override will target class specified above and only defined methods, in that case Start()
Instance = (MySingleton)(object)this; //contents will be changed as they are visible here, casting to object and then to expected type will correct the issue
}
}
```
### Adding types
When your code is recompiled it lands in new assembly. This can cause some issues, for example if your class is using `internal`
interface - after recompile it won't be able to access that interface.
Following code will fail to compile when changing MyClass as it won't be able to access IInterface which is `internal`:
```
//Defined in file MyClass.cs
public class MyClass: IInterface {
}
//Defined in other file, IInterface.cs
interface IInterface { //no access modifier for interfaces will infer 'internal' - only available to assembly it's defined in.
}
```
In that case you can create a user script rewrite override, to do so:
1) In Unity project panel right-click on 'MyClass.cs'
2) Select `Fast Script Reload -> Add \ Open User Script Rewrite Override`
3) Asset will create override file for you with some template already in (there's also description in top comment how to use)
And put following in the override file
```
interface IInterface {
// add any definitions as needed
}
```
This will then be simply added to newly compiled file and interface will be accessible.
```
//now both in same assembly/file when hot reloaded
public class MyClass: IInterface {
}
interface IInterface {
}
```
### Managing existing User Script Rewrite Overrides
You can see all your overrides by:
1) Right clicking on file in Unity project panel
2) Clicking `Fast Script Reload -> Show User Script Rewrite Overrides`
This will take you to tool settings window. You can also access it via:
1) Clicking `Window -> Fast Script Reload -> Start Screen`
2) Selecting `User Script Rewrite Overrides` side tab
## Options
You can access Welcome Screen / Options via 'Window -> Fast/Live Script Reload -> Start Screen' - it contains useful information as well as options.
```
Context menus will be prefixed with used version, either 'Fast Script Reload' or 'Live Script Reload'
```
### Auto Hot-Reload
By default tool will pick changes made to any file in playmode. You can add exclusions to that behaviour, more on that later.
You can also manually manage reload, to do so:
1) Un-tick 'Enable auto Hot-Reload for changed files' in Options -> Reload page
2) Click Window -> Fast Script Reload -> Force Reload to trigger
3) or call `FastScriptReloadManager.TriggerReloadForChangedFiles()` method from code
> You can also use Editor -> Hotkeys to bind Force Reload to specific key.
### Watch only specific files or folders
By default FSR watches all files (as specified in global file watcher) - if you want to limit that behaviour to specific files
please tick 'Specify watched folders/files manually' in 'Reload tab'.
Then you can right click on folder/file in project window and select 'Fast Script Reload -> Watch File / Folder'.
> Technically this adds another File Watcher behind the scenes, you can always adjust those on File Watchers tab.
### Custom file watcher implementation
In some cases standard file default watcher API can cause issues. You can choose different file watcher implementations via 'Window -> Fast Script Reload -> Start Screen -> File Watchers -> File Watcher implementation'
> DefaultUnity - on some editor versions it could be slow or not trigger at all
>
> DirectWindowsApi - (experimental) uses Windows API directly, faster (symlinks not supported)
>
> CustomPolling - (experimental) watches files by manual polling for changes, slowest. Make sure to narrow down watchers scope to script folders
### [Live-Reload] Hot-Reload over Network
With on-device build, your code changes will be distributed over the network in real-time.
By default running application will send a broadcast and try to discover editor running the tool.
Broadcast is initiated from device where build is running on (not from editor) - this means device running editor needs to allow the connection.
### [Live-Reload] Troubleshooting network issues
If for whatever reason reload over network doesn't work, please:
1) go to 'Window -> Live Script Reload -> Options/Network'
2) make sure port used is not already used by any other application
3) make sure your Firewall allows connections on that port
4) If you think broadcast doesn't work in your network it's best to specify IP Address explicitly (tick 'Force specific UP address for clients to receive Hot-Reload updates' and add IP)
- this will allow client (build on device) connect directly to specified address
### [Live-Reload] Connected Client
In playmode, message will be logged when clients connects. Also Options/Network will display connected client, eg Android phone could be identified as:
`SM-100232 connected from 192.189.168.68:12548`
**Only 1 client can be connected at any time.**
### [Live-Reload] Testing with Editor
By default, editor will reflect any changes you made without using network. If you want to force editor to behave as networked client:
1) Press play
2) Find DontDestroyOnLoadObject 'NetworkedAssemblyChangesLoader' -
3) tick 'IsDebug'
4) tick 'Editor Acts as Remote Client'
5) enable NetworkedAssemblyChangesLoader component
### Managing file exclusions
Files can be excluded from auto-compilation.
#### via 'Project' context menu
1) Right click on any *.cs file
2) Click Fast Script Reload
3) Add Hot-Reload Exclusion
*You can remove exclusion from same menu*
#### via Exclusions page
To view all exclusions:
1) Right click on any *.cs file
2) Click Fast Script Reload
3) Click Show Exclusions
#### via class attribute
You can also add `[PreventHotReload]` attribute to a class to prevent hot reload for that class.
### Batch script changes and reload every N seconds
Script will batch all your playmode changes and Hot-Reload them in bulk every 3 seconds - you can change duration from 'Reload' options page.
### Disable added/removed fields check
By default if you add / remove fields, tool will not redirect method calls for recompiled class.
This is to ensure there are no issues as that is generally not supported.
Some assets however will use IL weaving to adjust your classes (eg Mirror) as a post compile step. In that case it's quite likely hot-reload will still work.
### Managing reference exclusions
Asset will reference all .dll files that original code is referencing. In some cases that causes compilation error (eg 'Type XYZ is defined in both assembly a.dll and b.dll).
You can use those options to exclude specific references from being added.
> 'Start Screen -> Exclude References (Advanced) -> adjust as needed'.
## Performance
Your app performance won't be affected in any meaningful way.
Biggest bit is additional memory used for your re-compiled code.
Won't be visible unless you make 100s of changes in same play-session.
### File Watchers Performance Overhead
In some cases watching for file changes is causing significant performance overhead. This is down to the Unity FileWatcher which I'm unable to change or provide suitable replacement for. If you're experiencing this issue please go to `Window -> Fast Script Reload -> File Watcher (Advanced Setup)` and narrow down watchers to specific path where you're working in. You can watch multiple folders in this manner.
## LIMITATIONS -please make sure to read those
There are some limitation due to the approach taken to Hot-Reload your scripts. I've tried to minimise the impact to standard dev-workflow as much as possible.
In some cases however you may need to use workarounds as described below.
> In most cases you'll be able to use [User Defined Script Overrides](#user-defined-script-overrides) to overcome limitations and make hot reload code compilable.
### Generic methods and classes won't be Hot-Reloaded
Unfortunately generics will not be Hot-Reloaded, to workaround you'd need to move code to non-generic class / method.
Tool will try to change non-generic methods in those files and will simply skip generic ones.
*Note - you can still Hot-Reload for class implementations that derive from generic base class but are not generic themselves, eg.*
```
class SingletonImplementation: SingletonBase<SomeConcreteType> {
public void SomeSpecificFunctionality() {
//you can change code here and it'll be Hot-Reloaded as type itself is not generic
}
public void GenericMethod<T>(T arg) {
//changes here won't be Hot-Reloaded as method is generic
}
}
class SingletonBase<T> where T: new() {
public T Instance;
public void Init() {
Instance = new T(); //if you change this code it won't be Hot-Reloaded as it's in generic type
}
}
```
### Adding new fields
Experimental support with 1.3, minor limitations remaining:
- outside classes can not call new fields added at runtime
- new fields will only show in editor if they were already used at least once
> You need to opt in via start screen -> 'Window -> Fast Script Reload -> Start Screen -> New Fields -> enable'!
### Passing `this` reference to method that expect concrete class implementation
`**By default experimental setting 'Enable method calls with 'this' as argument fix' is turned on in options, and should fix 'this' calls/assignment issue.
If you see issues with that please turn setting off and get in touch via support email.**
Unless experimental setting is on - it'll throw compilation error `The best overloaded method match for xxx has some invalid arguments` - this is due to the fact that changed code is technically different type.
The code will need to be adjusted to depend on some abstraction instead (before hot-reload).
This code would cause the above error.
```
public class EnemyController: MonoBehaviour {
EnemyManager m_EnemyManager;
void Start()
{
//calling 'this' causes issues as after hot-reload the type of EnemyController will change to 'EnemyController__Patched_'
m_EnemyManager.RegisterEnemy(this);
}
}
public class EnemyManager : MonoBehaviour {
public void RegisterEnemy(EnemyController enemy) { //RegisterEnemy method expects parameter of concrete type (EnemyController)
//impementation
}
}
```
It could be changed to support Hot-Reload in following way:
1) Don't depend on concrete implementations, instead use interfaces/abstraction
```
public class EnemyController: MonoBehaviour, IRegistrableEnemy {
EnemyManager m_EnemyManager;
void Start()
{
//calling this causes issues as after hot-reload the type of EnemyController will change
m_EnemyManager.RegisterEnemy(this);
}
}
public class EnemyManager : MonoBehaviour {
public void RegisterEnemy(IRegistrableEnemy enemy) { //Using interface will go around error
//impementation
}
}
public interface IRegistrableEnemy
{
//implementation
}
```
2) Adjust method param to have common base class
```
public class EnemyManager : MonoBehaviour {
public void RegisterEnemy(MonoBehaviour enemy) { //Using common MonoBehaviour will go around error
//impementation
}
}
```
### Assigning `this` to a field references
Similar as above, this could cause some trouble although 'Enable method calls with 'this' as argument fix' setting will fix most of the issues.
Especially visible with singletons.
eg.
```
public class MySingleton: MonoBehaviour {
public static MySingleton Instance;
void Start() {
Instance = this;
}
}
```
### Calling internal class members from changed code
> You can use [User Defined Script Overrides](#user-defined-script-overrides) to overcome this limitation
> fixed in unreleased 1.5 - please get in touch if you need a copy before release
Technically, once your changed code is compiled it'll be in a separate assembly. As a result this changed code won't be able to access internal classes from assembly it originated from.
### Extensive use of nested classed / structs
> You can use [User Defined Script Overrides](#user-defined-script-overrides) to overcome this limitation
If your code-base contains lots of nested classes - you may see more compilation errors.
Easy workaround is to move those nested classes away so they are top-level.
### Creating new public methods
Hot-reload for new methods will only work with private methods (only called by changed code).
### Adding new references
When you're trying to reference new code in play-mode session that'll fail if assembly is not yet referencing that (most often happens when using AsmDefs that are not yet referencing each other)
### Changing class that uses extension and passes itself as a reference
> You can use [User Defined Script Overrides](#user-defined-script-overrides) to overcome this limitation
Changing class that uses extension method and passes itself as a reference will create compiler error.
Generally that shouldn't be an issue, extension methods are primarily used as a syntatic sugar to extend a class that you do not have access to.
You shouldn't need to create extension methods for types you own (instead those are generally instance methods or base class methods).
Given example:
```
public class ExtensionMethodTest
{
public string Name;
void Update()
{
this.PrintName();
}
}
//separate extension file
public static ExtensionMethodTestExtensions
{
public static void PrintName(this ExtensionMethodTest obj)
{
Debug.Log(obj.Name);
}
}
```
When changing `ExtensionMethodTest` you'll get compile error. Workaround would be to include method call in your type, eg:
```
public class ExtensionMethodTest {
public string Name;
void Update() {
this.PrintName();
}
private void PrintName() {
Debug.Log(Name);
}
}
```
*Arguably that's what should be done in the first place.*
Adjusting classes that use extension methods without passing itself as a reference - will work correctly. eg:
```
public class ObjectFromExternalAssembly()
{
//included just to illustrate example, that'd be in compiled assembly
//that you can't change and use extension method approach
public string Name;
}
public class ExtensionMethodTester
{
void Update()
{
var t = new ExtensionMethodTest();
t.PrintName()
}
}
//separate extension file
public static ObjectFromExternalAssemblyExtensions
{
public static void PrintName(this ObjectFromExternalAssembly obj)
{
Debug.Log(obj.Name);
}
}
```
### Changing class that implements internal interface can trigger compilation error
> You can use [User Defined Script Overrides](#user-defined-script-overrides) to overcome this limitation
> fixed in unreleased 1.5 - please get in touch if you need a copy before release
If class is implementing interface that's defined in different file as internal (default for no access modifier) - then changes to that class will fail to compile.
eg.
```
//file IInterface.cs
interface IInterface { //default interface access-modifier is 'internal'
//declaration
}
//file ClassImplementingIInterface.cs
class ClassImplementingIInterface: IInterface {
//changing this class will cause CS0122 'IInterface' is inaccessible due to it's protection level
}
```
> Quick workaround is to declare that interface as public
>
### Changing class that accesses `private protected` members
> You can use [User Defined Script Overrides](#user-defined-script-overrides) to overcome this limitation
> fixed in unreleased 1.5 - please get in touch if you need a copy before release
With C# 7.2 `private protected` access modifier was introduced. It works as `protected` access modifier in a sense that inherited classes can access it but.
Addition of `private` also limits it to same assembly. Your changes are technically compiled into separate assembly and at the moment trying to access `private protected` in changed code will produce compiler error.
> Easiest workaround for now is to declare those `private protected` members as `protected`.
### Limited debugger support for Rider when using Unity 2019 and 2020
Once breakpoint has been hit it'll stop asset from hot-reloading in that play-session. Newer Unity versions are supporting debugging.
### No IL2CPP support
Asset runs based on specific .NET functionality, IL2CPP builds will not be supported. Although as this is development workflow aid you can build your APK with Mono backend (android) and change later.
### Partial classes
Experimental support (on by default). Potentially could have some performance implications as it's file-read heavy in current state. Can be disabled in options if needed.
Your partial class file needs to share name with actual class. eg
`public class PartialClass`
Needs to be in files
**PartialClass**XYZ
eg.
- PartialClass.1.cs
- PartialClass.2.cs
## FAQ
### How is this asset different than Live Script Reload?
Fast Script Reload
- hot reload in editor
Live Script Reload
- same hot reload in editor as FSR (includes FSR)
+ **AND hot reload directly in builds / on-device**
+ you don't have to download them both separately, LSR is also 1 package import
+ standalone extension priced at $35, or if you've already bought Fast Script Reload it's $5 upgrade
### Editor makes full reload on any change in playmode
Unity Editor has an option to auto recompile changes. **For tool to work properly you want to have that either disabled or enabled only outside of playmode.**
You can adjusted auto-reload at any time via `Edit -> Preferences -> Asset Pipeline -> Auto Refresh`.
*Tool will also offer to disable auto-refresh on startup.*
It's possible to set auto-refresh to enabled but only outside of playmode. Depending on editor version used this can be found in:
- `Edit -> Preferences -> General -> Script Changes While Playing -> Recompile After Finished Playing`
- or `Edit -> Preferences -> Asset Pipeline -> Auto Refresh -> Enabled Outside Playmode`
### VS Code shows console shows errors
VS Code proj file (csproj) generate with NetFramework version 4.7.1. One of the plugin DLLs is targeting version 4.8.
Even though VS Code does not compile that code (Unity does) - it'll still show error as it didn't load the library for code-completion.
It's not a plugin issue as such, other dlls will have same troubles.
Best solution I've found is to force csproj files to be generated with 4.8 version instead.
This can be achieved with following editor script
```
using System.IO;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
public class VisualStudioProjectGenerationPostProcess : AssetPostprocessor
{
private static void OnGeneratedCSProjectFiles()
{
Debug.Log("OnGeneratedCSProjectFiles");
var dir = Directory.GetCurrentDirectory();
var files = Directory.GetFiles(dir, "*.csproj");
foreach (var file in files)
ChangeTargetFrameworkInfProjectFiles(file);
}
static void ChangeTargetFrameworkInfProjectFiles(string file)
{
var text = File.ReadAllText(file);
var find = "TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion";
var replace = "TargetFrameworkVersion>v4.8</TargetFrameworkVersion";
if (text.IndexOf(find) != -1)
{
text = Regex.Replace(text, find, replace);
File.WriteAllText(file, text);
}
}
}
```
> As a one-off you may also need to go to Edit -> Preferences -> External Tools -> click 'Regenerate project files' buttons
### When importing I'm getting error: 'Unable to update following assemblies: (...)/ImmersiveVRTools.Common.Runtime.dll'
This happens occasionally, especially on upgrade between versions. It's harmless error that'll go away on play mode.
### When upgrading between versions, eg 1.1 to 1.2 example scene cubes are pink
This is down to reimporting 'Point' prefab. Right now plugin will make sure it's using correct shader eg. URP / Built-in but only on initial import.
To fix please go to `FastScripReload\Examples\Point\Point.prefab` and search for 'Point' shader.
### On Mac hot reload does not trigger when changing files
It'd seem for some code editors on Mac file changes are not picked up. This seems to be down to editors not updating LastWrite property on save and file watcher can't pick up the change.
Unfortunately right now only workaround is to use editor that does update it, eg VSCode.
### I removed FSR but my scripts are still not reloading
FSR initially asks if you want to disable Unity auto-reload. If you select yes, then it'll let you know you should now trigger full reload with CTRL + R.
That's a Unity setting and it does not change back when removing asset.
> To change go to 'Edit -> Preferences -> Asset Pipeline -> Auto Refresh -> Enabled'
## Roadmap
- add Mac silicon support
- ~~add Mac/Linux support~~ (added with 1.1)
- ~~add debugger support for hot-reloaded scripts~~ (added with 1.2)
- ~~allow to add new fields (adjustable in Editor)~~ (added with 1.3)
- better compiler support to work around limitations
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: b15135889062bcf428b025b2fb045da8
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Documentation/documentation.md
uploadId: 710802
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: e4d31e46efd843644b0ca6010aa753e4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Documentation/documentation.pdf
uploadId: 710802
@@ -0,0 +1,70 @@
1.8
- Added Unity 6 support
- Improved extension methods rewriting
- Partial classes support (contributed by Jlabarca)
- Unity 2019 / 2020 no longer officially supported
1.7
- Optional file watching can be done via direct WindowsAPI (contributed by SamPruden)
- Extended UI to allow for easy choice of file watcher implementation
1.6
- Added more Unit Tests to ensure various code patterns can be rewritten correctly
- Added Watch Only Specific Files and Folders mode (contributed by GhatSmith)
- Added better Odin support for dynamically added fields (contributed by GhatSmith)
- Updated Roslyn lib version to 4.6.0 for better code parsing (contributed by SamPruden)
- Improved error handling for code parsing (contributed by SamPruden)
- Added Custom-File-Watcher implementation (for cases where standard FileWatcher API is causing issues) (contributed by D0rkKnight)
1.5
- you can now import FSR as a package from github page
- hot-reloading internal interfaces / classes would no longer cause compilation error
- OnScriptHotReload method can be added at runtime
- builder functions will be correctly rewritten
- hot reload status (red / green) will be visible in project panel next to changed script
- compilation error reporting will be much improved, project panel will allow to click error next to actual file for more details and workarounds
- all type declarations that were appended with __Patched_ postfix to avoid name collisions will also have all corresponding identifiers changed
- OnScriptHotReload methods will also be called in editor-workflow
1.4
- added experimental editor-mode hot-reload, you'll need to opt in via Start Screen -> Editor Hot-Reload (please read the notes on that page, playmode workflow is still far superior)
- you can now define User Script Rewrite Overrides - which will allow you to overcome most of existing limitations that cause compilation errors (on a one by one basis)
- big optimization in how long hot-reload part will take, first call will be unaffected when type cache is build but subsequent calls will be significantly quicker
- added 'Exclude References' options - this allows to remove specific dll references from dynamically compiled code (as in some cases you may get 'type defined in both assembly x.dll and y.dll'
- destructors will no longer cause compilation error
- (options opt-in) script rewriting can optionally emit comment - why change was made to help with troubleshooting issues
- Unity assembly reload can be forced off via LockAssemblyReload if specified in options - sometimes even though Auto-Refresh is turned off Editor still tries to recompile changes in playmode which prevents FSR from working
- new fields support (experimental) will be enabled by default
1.3.1
- open source release on github
1.3 - (Experimental) - New fields added in playmode
- New fields can be added and used in code
- New fields can be adjusted in editor (same as standard fields)
- New fields will be initialized to whatever value is specified in code or default value
- Experimental feature - at this stage expect some issues
- Opt-in - disabled by default to enable go to 'Window -> Fast Script Reload -> Start Screen -> New Fields -> enable'
1.2 - Debugger support
- Added debugger support (see documentation)
1.1 - Mac support / bug fixes
- Added Mac support (only INTEL editor version, SILICON still not supported)
- Added Linux support
- fixed namespace clash with Unity.Collections package
- common code lib will not be included in builds
- added check for auto-refresh in Editor - will proide guidance and option to adjust as otherwise full editor reload is triggered for changes
- added workaround for Unity file-watcher returning wrong file path on some editor versions
- added option to allow disabling DidFieldCountCheck - allowing to detour methods in those cases (eg for Mirror where it'll adjust IL and cause mismatch)
- added option to configure FileWatcher paths/filters as in some cases watching root directory was causing performance issues
- added minor initial-load optimisations - using session-state for items that do not need to be resolved on every reload
1.0 - First release, included features:
Fast script reload in editor / play-mode (compiles only changed files and hot-reloads them into current play session)
Hot-reload on device (in build)
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cd8daa3bb60e4b30b6520184de1abcda
timeCreated: 1672842170
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Documentation/release-notes.md
uploadId: 710802
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6dd277cf0199f5d4cb3ff594111df8ff
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f67a020a9ad31334ea8792cf175b5d6b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Andreas Pardeike
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 22053913c34700a4a9c13b853eea3317
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Harmony/HarmonyLicense.txt
uploadId: 710802
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1c409188546e50f4a963ad9ae5deda06
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: 494e757c92cba704db1d95279f80a30f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_EDITOR || LiveScriptReload_IncludeInBuild_Enabled
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 0
Exclude Linux64: 0
Exclude OSXUniversal: 0
Exclude Win: 0
Exclude Win64: 0
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Harmony/net48/0Harmony.dll
uploadId: 710802
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 59922c0cd2ffd71478db2dea7fb3fb7a
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Harmony/net48/0Harmony.xml
uploadId: 710802
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fec618116c7eb7f42a3cf42dd1e125ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,83 @@
fileFormatVersion: 2
guid: 1f20b53a7360a6f40957117be6217b96
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/ImmersiveVrToolsCommon/ImmersiveVRTools.Common.Editor.dll
uploadId: 710802
@@ -0,0 +1,85 @@
fileFormatVersion: 2
guid: 42c3f40ad0520e442aa80842ab9748a9
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder:
ImmersiveVRTools.Runtime.Common.Debug.RuntimeDebugDraw: 9990
defineConstraints:
- UNITY_EDITOR || LiveScriptReload_IncludeInBuild_Enabled
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 0
Exclude Linux64: 0
Exclude OSXUniversal: 0
Exclude Win: 0
Exclude Win64: 0
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 1
settings:
CPU: x86_64
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/ImmersiveVrToolsCommon/ImmersiveVRTools.Common.Runtime.dll
uploadId: 710802
@@ -0,0 +1,3 @@
This code is part of the product and can be used with same licence as the one you got it with.
Left in Plugins folder solely for convenience.
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 656785d4ce824de4ac3c58af77fec60d
timeCreated: 1670158565
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/ImmersiveVrToolsCommon/ImmersiveVRToolsCommonLicense.txt
uploadId: 710802
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 99309b63b6416e44f8c19d3f300ee1c1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9bfedaf58be6fc243a48a4cc7e808d73
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: aa900f3e8ecf37343bb158cd68e5718d
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2019 || UNITY_2020
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2019+/Microsoft.CodeAnalysis.CSharp.dll
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: b6ebf747d582ac34fa013efea6bda29d
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2019 || UNITY_2020
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2019+/Microsoft.CodeAnalysis.dll
uploadId: 710802
@@ -0,0 +1,23 @@
The MIT License (MIT)
Copyright (c) .NET Foundation and Contributors
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 20fdb23994f768f4e89f8a9779e20213
timeCreated: 1670158681
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2019+/RoslynLicense.txt
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: ef253369b6dd9f4438722b050ca92f39
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2019 || UNITY_2020
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2019+/System.Collections.Immutable.dll
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: f3873ad25446a8b469c55b876e3b4577
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2019 || UNITY_2020
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2019+/System.Reflection.Metadata.dll
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: c90f5e7176b3a054684c79065480027d
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2019 || UNITY_2020
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2019+/System.Threading.Tasks.Extensions.dll
uploadId: 710802
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 70d195e83e3a18d429e11445ca3df423
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: 139b14934c1c2ce4dac3f527ac5e78e9
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2021_1_OR_NEWER
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/Microsoft.CodeAnalysis.CSharp.dll
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: aab00a18aeb22e84882f5e659c0314da
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2021_1_OR_NEWER
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/Microsoft.CodeAnalysis.dll
uploadId: 710802
@@ -0,0 +1,23 @@
The MIT License (MIT)
Copyright (c) .NET Foundation and Contributors
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: d7099df6462159544838be814444129f
timeCreated: 1670158681
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/RoslynLicense.txt
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: 9136761bcf6d7f54d94a6763da626ceb
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2021_1_OR_NEWER
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/System.Collections.Immutable.FSR.dll
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: 8fe61eaaa3c4e714c8b9c78ce0303b3a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2021_1_OR_NEWER
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/System.Collections.Immutable.dll
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: 65b841640a4bf8d40b71eaa00a711049
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2021_1_OR_NEWER
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/System.Reflection.Metadata.dll
uploadId: 710802
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 2995ab795c7c4854d991cb7b672c14aa
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/System.Reflection.Metadata.xml
uploadId: 710802
@@ -0,0 +1,50 @@
fileFormatVersion: 2
guid: 8e60dc682ecdf2a4c8d1f481f807496b
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2021_1_OR_NEWER
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/System.Runtime.CompilerServices.Unsafe.dll
uploadId: 710802
@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly>
<name>System.Runtime.CompilerServices.Unsafe</name>
</assembly>
<members>
<member name="T:System.Runtime.CompilerServices.Unsafe">
<summary>Contains generic, low-level functionality for manipulating pointers.</summary>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(``0@,System.Int32)">
<summary>Adds an element offset to the given reference.</summary>
<param name="source">The reference to add the offset to.</param>
<param name="elementOffset">The offset to add.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the addition of offset to pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(``0@,System.IntPtr)">
<summary>Adds an element offset to the given reference.</summary>
<param name="source">The reference to add the offset to.</param>
<param name="elementOffset">The offset to add.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the addition of offset to pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(``0@,System.UIntPtr)">
<summary>Adds an element offset to the given reference.</summary>
<param name="source">The reference to add the offset to.</param>
<param name="elementOffset">The offset to add.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the addition of offset to pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(System.Void*,System.Int32)">
<summary>Adds an element offset to the given void pointer.</summary>
<param name="source">The void pointer to add the offset to.</param>
<param name="elementOffset">The offset to add.</param>
<typeparam name="T">The type of void pointer.</typeparam>
<returns>A new void pointer that reflects the addition of offset to the specified pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.AddByteOffset``1(``0@,System.IntPtr)">
<summary>Adds a byte offset to the given reference.</summary>
<param name="source">The reference to add the offset to.</param>
<param name="byteOffset">The offset to add.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the addition of byte offset to pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.AddByteOffset``1(``0@,System.UIntPtr)">
<summary>Adds a byte offset to the given reference.</summary>
<param name="source">The reference to add the offset to.</param>
<param name="byteOffset">The offset to add.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the addition of byte offset to pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.AreSame``1(``0@,``0@)">
<summary>Determines whether the specified references point to the same location.</summary>
<param name="left">The first reference to compare.</param>
<param name="right">The second reference to compare.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>
<see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> point to the same location; otherwise, <see langword="false" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.As``1(System.Object)">
<summary>Casts the given object to the specified type.</summary>
<param name="o">The object to cast.</param>
<typeparam name="T">The type which the object will be cast to.</typeparam>
<returns>The original object, casted to the given type.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.As``2(``0@)">
<summary>Reinterprets the given reference as a reference to a value of type <typeparamref name="TTo" />.</summary>
<param name="source">The reference to reinterpret.</param>
<typeparam name="TFrom">The type of reference to reinterpret.</typeparam>
<typeparam name="TTo">The desired type of the reference.</typeparam>
<returns>A reference to a value of type <typeparamref name="TTo" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.AsPointer``1(``0@)">
<summary>Returns a pointer to the given by-ref parameter.</summary>
<param name="value">The object whose pointer is obtained.</param>
<typeparam name="T">The type of object.</typeparam>
<returns>A pointer to the given value.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.AsRef``1(``0@)">
<summary>Reinterprets the given read-only reference as a reference.</summary>
<param name="source">The read-only reference to reinterpret.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A reference to a value of type <typeparamref name="T" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.AsRef``1(System.Void*)">
<summary>Reinterprets the given location as a reference to a value of type <typeparamref name="T" />.</summary>
<param name="source">The location of the value to reference.</param>
<typeparam name="T">The type of the interpreted location.</typeparam>
<returns>A reference to a value of type <typeparamref name="T" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.ByteOffset``1(``0@,``0@)">
<summary>Determines the byte offset from origin to target from the given references.</summary>
<param name="origin">The reference to origin.</param>
<param name="target">The reference to target.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>Byte offset from origin to target i.e. <paramref name="target" /> - <paramref name="origin" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Copy``1(``0@,System.Void*)">
<summary>Copies a value of type <typeparamref name="T" /> to the given location.</summary>
<param name="destination">The location to copy to.</param>
<param name="source">A pointer to the value to copy.</param>
<typeparam name="T">The type of value to copy.</typeparam>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Copy``1(System.Void*,``0@)">
<summary>Copies a value of type <typeparamref name="T" /> to the given location.</summary>
<param name="destination">The location to copy to.</param>
<param name="source">A reference to the value to copy.</param>
<typeparam name="T">The type of value to copy.</typeparam>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Byte@,System.Byte@,System.UInt32)">
<summary>Copies bytes from the source address to the destination address.</summary>
<param name="destination">The destination address to copy to.</param>
<param name="source">The source address to copy from.</param>
<param name="byteCount">The number of bytes to copy.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Void*,System.Void*,System.UInt32)">
<summary>Copies bytes from the source address to the destination address.</summary>
<param name="destination">The destination address to copy to.</param>
<param name="source">The source address to copy from.</param>
<param name="byteCount">The number of bytes to copy.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Byte@,System.Byte@,System.UInt32)">
<summary>Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.</summary>
<param name="destination">The destination address to copy to.</param>
<param name="source">The source address to copy from.</param>
<param name="byteCount">The number of bytes to copy.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Void*,System.Void*,System.UInt32)">
<summary>Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.</summary>
<param name="destination">The destination address to copy to.</param>
<param name="source">The source address to copy from.</param>
<param name="byteCount">The number of bytes to copy.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Byte@,System.Byte,System.UInt32)">
<summary>Initializes a block of memory at the given location with a given initial value.</summary>
<param name="startAddress">The address of the start of the memory block to initialize.</param>
<param name="value">The value to initialize the block to.</param>
<param name="byteCount">The number of bytes to initialize.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Void*,System.Byte,System.UInt32)">
<summary>Initializes a block of memory at the given location with a given initial value.</summary>
<param name="startAddress">The address of the start of the memory block to initialize.</param>
<param name="value">The value to initialize the block to.</param>
<param name="byteCount">The number of bytes to initialize.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Byte@,System.Byte,System.UInt32)">
<summary>Initializes a block of memory at the given location with a given initial value without assuming architecture dependent alignment of the address.</summary>
<param name="startAddress">The address of the start of the memory block to initialize.</param>
<param name="value">The value to initialize the block to.</param>
<param name="byteCount">The number of bytes to initialize.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Void*,System.Byte,System.UInt32)">
<summary>Initializes a block of memory at the given location with a given initial value without assuming architecture dependent alignment of the address.</summary>
<param name="startAddress">The address of the start of the memory block to initialize.</param>
<param name="value">The value to initialize the block to.</param>
<param name="byteCount">The number of bytes to initialize.</param>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.IsAddressGreaterThan``1(``0@,``0@)">
<summary>Returns a value that indicates whether a specified reference is greater than another specified reference.</summary>
<param name="left">The first value to compare.</param>
<param name="right">The second value to compare.</param>
<typeparam name="T">The type of the reference.</typeparam>
<returns>
<see langword="true" /> if <paramref name="left" /> is greater than <paramref name="right" />; otherwise, <see langword="false" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.IsAddressLessThan``1(``0@,``0@)">
<summary>Returns a value that indicates whether a specified reference is less than another specified reference.</summary>
<param name="left">The first value to compare.</param>
<param name="right">The second value to compare.</param>
<typeparam name="T">The type of the reference.</typeparam>
<returns>
<see langword="true" /> if <paramref name="left" /> is less than <paramref name="right" />; otherwise, <see langword="false" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.IsNullRef``1(``0@)">
<summary>Determines if a given reference to a value of type <typeparamref name="T" /> is a null reference.</summary>
<param name="source">The reference to check.</param>
<typeparam name="T">The type of the reference.</typeparam>
<returns>
<see langword="true" /> if <paramref name="source" /> is a null reference; otherwise, <see langword="false" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.NullRef``1">
<summary>Returns a reference to a value of type <typeparamref name="T" /> that is a null reference.</summary>
<typeparam name="T">The type of the reference.</typeparam>
<returns>A reference to a value of type <typeparamref name="T" /> that is a null reference.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Read``1(System.Void*)">
<summary>Reads a value of type <typeparamref name="T" /> from the given location.</summary>
<param name="source">The location to read from.</param>
<typeparam name="T">The type to read.</typeparam>
<returns>An object of type <typeparamref name="T" /> read from the given location.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.ReadUnaligned``1(System.Byte@)">
<summary>Reads a value of type <typeparamref name="T" /> from the given location without assuming architecture dependent alignment of the addresses.</summary>
<param name="source">The location to read from.</param>
<typeparam name="T">The type to read.</typeparam>
<returns>An object of type <typeparamref name="T" /> read from the given location.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.ReadUnaligned``1(System.Void*)">
<summary>Reads a value of type <typeparamref name="T" /> from the given location without assuming architecture dependent alignment of the addresses.</summary>
<param name="source">The location to read from.</param>
<typeparam name="T">The type to read.</typeparam>
<returns>An object of type <typeparamref name="T" /> read from the given location.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.SizeOf``1">
<summary>Returns the size of an object of the given type parameter.</summary>
<typeparam name="T">The type of object whose size is retrieved.</typeparam>
<returns>The size of an object of type <typeparamref name="T" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.SkipInit``1(``0@)">
<summary>Bypasses definite assignment rules for a given value.</summary>
<param name="value">The uninitialized object.</param>
<typeparam name="T">The type of the uninitialized object.</typeparam>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(``0@,System.Int32)">
<summary>Subtracts an element offset from the given reference.</summary>
<param name="source">The reference to subtract the offset from.</param>
<param name="elementOffset">The offset to subtract.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the subtraction of offset from pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(``0@,System.IntPtr)">
<summary>Subtracts an element offset from the given reference.</summary>
<param name="source">The reference to subtract the offset from.</param>
<param name="elementOffset">The offset to subtract.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the subtraction of offset from pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(``0@,System.UIntPtr)">
<summary>Subtracts an element offset from the given reference.</summary>
<param name="source">The reference to subtract the offset from.</param>
<param name="elementOffset">The offset to subtract.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the subraction of offset from pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(System.Void*,System.Int32)">
<summary>Subtracts an element offset from the given void pointer.</summary>
<param name="source">The void pointer to subtract the offset from.</param>
<param name="elementOffset">The offset to subtract.</param>
<typeparam name="T">The type of the void pointer.</typeparam>
<returns>A new void pointer that reflects the subtraction of offset from the specified pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.SubtractByteOffset``1(``0@,System.IntPtr)">
<summary>Subtracts a byte offset from the given reference.</summary>
<param name="source">The reference to subtract the offset from.</param>
<param name="byteOffset">The offset to subtract.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the subtraction of byte offset from pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.SubtractByteOffset``1(``0@,System.UIntPtr)">
<summary>Subtracts a byte offset from the given reference.</summary>
<param name="source">The reference to subtract the offset from.</param>
<param name="byteOffset">The offset to subtract.</param>
<typeparam name="T">The type of reference.</typeparam>
<returns>A new reference that reflects the subraction of byte offset from pointer.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Unbox``1(System.Object)">
<summary>Returns a <see langword="mutable ref" /> to a boxed value.</summary>
<param name="box">The value to unbox.</param>
<typeparam name="T">The type to be unboxed.</typeparam>
<exception cref="T:System.NullReferenceException">
<paramref name="box" /> is <see langword="null" />, and <typeparamref name="T" /> is a non-nullable value type.</exception>
<exception cref="T:System.InvalidCastException">
<paramref name="box" /> is not a boxed value type.
-or-
<paramref name="box" /> is not a boxed <typeparamref name="T" />.</exception>
<exception cref="T:System.TypeLoadException">
<typeparamref name="T" /> cannot be found.</exception>
<returns>A <see langword="mutable ref" /> to the boxed value <paramref name="box" />.</returns>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.Write``1(System.Void*,``0)">
<summary>Writes a value of type <typeparamref name="T" /> to the given location.</summary>
<param name="destination">The location to write to.</param>
<param name="value">The value to write.</param>
<typeparam name="T">The type of value to write.</typeparam>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.WriteUnaligned``1(System.Byte@,``0)">
<summary>Writes a value of type <typeparamref name="T" /> to the given location without assuming architecture dependent alignment of the addresses.</summary>
<param name="destination">The location to write to.</param>
<param name="value">The value to write.</param>
<typeparam name="T">The type of value to write.</typeparam>
</member>
<member name="M:System.Runtime.CompilerServices.Unsafe.WriteUnaligned``1(System.Void*,``0)">
<summary>Writes a value of type <typeparamref name="T" /> to the given location without assuming architecture dependent alignment of the addresses.</summary>
<param name="destination">The location to write to.</param>
<param name="value">The value to write.</param>
<typeparam name="T">The type of value to write.</typeparam>
</member>
</members>
</doc>
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 37aa3a1626690b44da6b8799b8f26450
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/System.Runtime.CompilerServices.Unsafe.xml
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: 337544ddb4628f340bd86d16c5d58caa
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2021_1_OR_NEWER
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/2021+/System.Threading.Tasks.Extensions.dll
uploadId: 710802
@@ -0,0 +1 @@
library is excluded from any compilation by default. It's only purpose is to serve as a reference for dynamic keyword when targetting NET Standard 2.1 - as this is required by ThisRewriters to function properly
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 26f2f034c23688d46b7284ad72c08f91
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/Microsoft.CSharp.dll.IMPORTANT.txt.txt
uploadId: 710802
@@ -0,0 +1,84 @@
fileFormatVersion: 2
guid: 8f60cb703cea2fe4ebc2f2cf1a68714b
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints:
- UNITY_2019 || UNITY_2020
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 1
validateReferences: 0
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Plugins/Roslyn/Microsoft.CSharp.dll
uploadId: 710802
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3e2456f51a2408f43a5b76ab3daef351
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 018258c906e44916b88d291450c30b69
timeCreated: 1668616782
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 15c1071797bb4a818f85a6f8187f4289
timeCreated: 1678785269
@@ -0,0 +1,46 @@
using System.IO;
using System.Reflection;
using Mono.Cecil;
using UnityEditor;
using UnityEngine;
namespace FastScriptReload.Editor.AssemblyPostProcess
{
[InitializeOnLoad]
public static class AddInternalsVisibleToForAllUserAssembliesPostProcess
{
public static readonly DirectoryInfo AdjustedAssemblyRoot;
static AddInternalsVisibleToForAllUserAssembliesPostProcess()
{
AdjustedAssemblyRoot = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "Temp", "Fast Script Reload", "AdjustedDlls"));
}
public static string CreateAssemblyWithInternalsContentsVisibleTo(Assembly changedAssembly, string visibleToAssemblyName)
{
if(!AdjustedAssemblyRoot.Exists)
AdjustedAssemblyRoot.Create();
using (var assembly = AssemblyDefinition.ReadAssembly(changedAssembly.Location, new ReaderParameters { ReadWrite = false }))
{
var mainModule = assembly.MainModule;
var attributeCtor = mainModule.ImportReference(
typeof(System.Runtime.CompilerServices.InternalsVisibleToAttribute).GetConstructor(new[] { typeof(string) })
);
var attribute = new CustomAttribute(attributeCtor);
attribute.ConstructorArguments.Add(
new CustomAttributeArgument(mainModule.TypeSystem.String, visibleToAssemblyName)
);
assembly.CustomAttributes.Add(attribute);
var newAssemblyPath = new FileInfo(Path.Combine(AdjustedAssemblyRoot.FullName, assembly.Name.Name) + ".dll").FullName;
assembly.Write(newAssemblyPath);
return newAssemblyPath;
}
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b2f64e1d1e2642f9ab712970582c0b45
timeCreated: 1678785285
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/AssemblyPostProcess/AddInternalsVisibleToForAllUserAssembliesPostProcess.cs
uploadId: 710802
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5d518c1ca9c2d974a886d5856abadb4d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bdecd2714d8a463fa3bdae705d942796
timeCreated: 1672992950
@@ -0,0 +1,36 @@
using System.Linq;
using ImmersiveVrToolsCommon.Runtime.Logging;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class BuilderPatternFunctionsRewriter : FastScriptReloadCodeRewriterBase
{
public BuilderPatternFunctionsRewriter(bool writeRewriteReasonAsComment, bool visitIntoStructuredTrivia = false)
: base(writeRewriteReasonAsComment, visitIntoStructuredTrivia)
{
}
public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node)
{
var ancestorName = node.Ancestors().OfType<TypeDeclarationSyntax>().FirstOrDefault()?.Identifier.ValueText;
if (string.IsNullOrEmpty(ancestorName)) //TODO: that happens too often for some methods, odd. Why? At very least don't spam user
{
LoggerScoped.LogWarning($"Unable to find ancestor for node '{node.ToFullString()}'");
}
else
{
var ancestorNameWithoutPatchedPostfix = ancestorName.Replace(FastScriptReload.Runtime.AssemblyChangesLoader.ClassnamePatchedPostfix, "");
if (node.ReturnType is IdentifierNameSyntax name && name.Identifier.ValueText == ancestorNameWithoutPatchedPostfix)
{
return node.WithReturnType(SyntaxFactory.IdentifierName(ancestorName + " "));
}
}
return base.VisitMethodDeclaration(node);
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ad3d5960a86c431cbea11b8962fa361e
timeCreated: 1678960928
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/BuilderPatternFunctionsRewriter.cs
uploadId: 710802
@@ -0,0 +1,84 @@
using System.Linq;
using FastScriptReload.Runtime;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class ConstructorRewriter : FastScriptReloadCodeRewriterBase
{
private readonly bool _adjustCtorOnlyForNonNestedTypes;
public ConstructorRewriter(bool adjustCtorOnlyForNonNestedTypes, bool writeRewriteReasonAsComment)
: base(writeRewriteReasonAsComment)
{
_adjustCtorOnlyForNonNestedTypes = adjustCtorOnlyForNonNestedTypes;
}
public override SyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
{
if (_adjustCtorOnlyForNonNestedTypes)
{
var typeNestedLevel = node.Ancestors().Count(a => a is TypeDeclarationSyntax);
if (typeNestedLevel == 1)
{
return AdjustCtorOrDestructorNameForTypeAdjustment(node, node.Identifier);
}
}
else
{
return AdjustCtorOrDestructorNameForTypeAdjustment(node, node.Identifier);
}
return base.VisitConstructorDeclaration(node);
}
public override SyntaxNode VisitDestructorDeclaration(DestructorDeclarationSyntax node)
{
if (_adjustCtorOnlyForNonNestedTypes)
{
var typeNestedLevel = node.Ancestors().Count(a => a is TypeDeclarationSyntax);
if (typeNestedLevel == 1)
{
return AdjustCtorOrDestructorNameForTypeAdjustment(node, node.Identifier);
}
}
else
{
return AdjustCtorOrDestructorNameForTypeAdjustment(node, node.Identifier);
}
return base.VisitDestructorDeclaration(node);
}
private SyntaxNode AdjustCtorOrDestructorNameForTypeAdjustment(BaseMethodDeclarationSyntax node, SyntaxToken nodeIdentifier)
{
var typeName = (node.Ancestors().First(n => n is TypeDeclarationSyntax) as TypeDeclarationSyntax).Identifier.ToString();
if (!nodeIdentifier.ToFullString().Contains(typeName))
{
//Used Roslyn version bug, some static methods are also interpreted as ctors, eg
// public static void Method()
// {
// Bar(); //treated as Ctor declaration...
// }
//
// private static void Bar()
// {
//
// }
return node;
}
if (!typeName.EndsWith(AssemblyChangesLoader.ClassnamePatchedPostfix))
{
typeName += AssemblyChangesLoader.ClassnamePatchedPostfix;
}
return AddRewriteCommentIfNeeded(
node.ReplaceToken(nodeIdentifier, SyntaxFactory.Identifier(typeName)),
$"{nameof(ConstructorRewriter)}:{nameof(AdjustCtorOrDestructorNameForTypeAdjustment)}"
);
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1d2a76467ecd40529f59bc68be8d7289
timeCreated: 1672992987
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/ConstructorRewriter.cs
uploadId: 710802
@@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using ImmersiveVrToolsCommon.Runtime.Logging;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class CreateNewFieldInitMethodRewriter: FastScriptReloadCodeRewriterBase {
private readonly Dictionary<string, List<string>> _typeToNewFieldDeclarations;
private static readonly string NewFieldsToCreateValueFnDictionaryFieldName = "__Patched_NewFieldNameToInitialValueFn";
private static readonly string NewFieldsToGetTypeFnDictionaryFieldName = "__Patched_NewFieldsToGetTypeFnDictionaryFieldName";
private static readonly string DictionaryFullNamespaceTypeName = "global::System.Collections.Generic.Dictionary";
public static Dictionary<string, Func<object>> ResolveNewFieldsToCreateValueFn(Type forType)
{
return (Dictionary<string, Func<object>>) forType.GetField(NewFieldsToCreateValueFnDictionaryFieldName, BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
}
public static Dictionary<string, Func<object>> ResolveNewFieldsToTypeFn(Type forType)
{
return (Dictionary<string, Func<object>>) forType.GetField(NewFieldsToGetTypeFnDictionaryFieldName, BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
}
public CreateNewFieldInitMethodRewriter(Dictionary<string, List<string>> typeToNewFieldDeclarations, bool writeRewriteReasonAsComment)
:base(writeRewriteReasonAsComment)
{
_typeToNewFieldDeclarations = typeToNewFieldDeclarations;
}
public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
{
var fullClassName = RoslynUtils.GetMemberFQDN(node, node.Identifier.ToString());
if (!_typeToNewFieldDeclarations.TryGetValue(fullClassName, out var newClassFields))
{
LoggerScoped.LogWarning($"Unable to find new-fields for type: {fullClassName}, this is not an issue if there are no new fields for that type.");
}
Func<FieldDeclarationSyntax, ExpressionSyntax> getObjectFnSyntax = fieldDeclarationNode => fieldDeclarationNode.Declaration.Variables[0].Initializer?.Value //value captured from initializer
?? SyntaxFactory.DefaultExpression(SyntaxFactory.IdentifierName(fieldDeclarationNode.Declaration.Type.ToString()));
var withDictionaryFieldNameToInitFieldValue = CreateNewFieldNameToGetObjectFnDictionary(node, newClassFields, getObjectFnSyntax, NewFieldsToCreateValueFnDictionaryFieldName);
//TODO: slightly odd scenario 'When explicit #nullable enable is used, reference types should be rewritten to typeof(type) for initialization and value types should remain typeof(type?)'
// Func<FieldDeclarationSyntax, ExpressionSyntax> getObjectTypeFnSyntax = fieldDeclarationNode => SyntaxFactory.TypeOfExpression(
// SyntaxFactory.ParseTypeName(fieldDeclarationNode.Declaration.Type.ToFullString().Replace("?", ""))
// );
Func<FieldDeclarationSyntax, ExpressionSyntax> getObjectTypeFnSyntax = fieldDeclarationNode => SyntaxFactory.TypeOfExpression(fieldDeclarationNode.Declaration.Type);
return CreateNewFieldNameToGetObjectFnDictionary(withDictionaryFieldNameToInitFieldValue, newClassFields, getObjectTypeFnSyntax, NewFieldsToGetTypeFnDictionaryFieldName);
}
private ClassDeclarationSyntax CreateNewFieldNameToGetObjectFnDictionary(ClassDeclarationSyntax node,
List<string> newClassFields, Func<FieldDeclarationSyntax, ExpressionSyntax> getObjectFnSyntax, string dictionaryFieldName)
{
var dictionaryKeyToInitValueNodes = newClassFields.SelectMany(fieldName =>
{
var fieldDeclarationNode = node.ChildNodes().OfType<FieldDeclarationSyntax>()
.Single(f => f.Declaration.Variables.First().Identifier.ToString() == fieldName);
return new[]
{
(SyntaxNodeOrToken)SyntaxFactory.AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
SyntaxFactory.ImplicitElementAccess()
.WithArgumentList(
SyntaxFactory.BracketedArgumentList(
SyntaxFactory.SingletonSeparatedList<ArgumentSyntax>(
SyntaxFactory.Argument(
SyntaxFactory.LiteralExpression(
SyntaxKind.StringLiteralExpression,
SyntaxFactory.Literal(fieldDeclarationNode.Declaration.Variables.First()
.Identifier.ToString())))))), //variable name
SyntaxFactory.ParenthesizedLambdaExpression(getObjectFnSyntax(fieldDeclarationNode))),
SyntaxFactory.Token(SyntaxKind.CommaToken) //comma, add for all
};
}).ToArray();
var dictionaryInitializer =
SyntaxFactory.InitializerExpression(
SyntaxKind.ObjectInitializerExpression,
SyntaxFactory.SeparatedList<ExpressionSyntax>(
dictionaryKeyToInitValueNodes.ToArray()
));
var withDictionaryFieldNameToInitFieldValue = node.AddMembers(
SyntaxFactory.FieldDeclaration(
SyntaxFactory.VariableDeclaration(
SyntaxFactory.GenericName(
SyntaxFactory.Identifier(DictionaryFullNamespaceTypeName))
.WithTypeArgumentList(
SyntaxFactory.TypeArgumentList(
SyntaxFactory.SeparatedList<TypeSyntax>(
new SyntaxNodeOrToken[]
{
SyntaxFactory.PredefinedType(
SyntaxFactory.Token(SyntaxKind.StringKeyword)),
SyntaxFactory.Token(SyntaxKind.CommaToken),
SyntaxFactory.GenericName(
SyntaxFactory.Identifier("global::System.Func"))
.WithTypeArgumentList(
SyntaxFactory.TypeArgumentList(
SyntaxFactory.SingletonSeparatedList<TypeSyntax>(
SyntaxFactory.PredefinedType(
SyntaxFactory.Token(SyntaxKind.ObjectKeyword)))))
}))))
.WithVariables(
SyntaxFactory.SingletonSeparatedList<VariableDeclaratorSyntax>(
SyntaxFactory.VariableDeclarator(
SyntaxFactory.Identifier(dictionaryFieldName))
.WithInitializer(
SyntaxFactory.EqualsValueClause(
SyntaxFactory.ObjectCreationExpression(
SyntaxFactory.GenericName(
SyntaxFactory.Identifier(DictionaryFullNamespaceTypeName))
.WithTypeArgumentList(
SyntaxFactory.TypeArgumentList(
SyntaxFactory.SeparatedList<TypeSyntax>(
new SyntaxNodeOrToken[]
{
SyntaxFactory.PredefinedType(
SyntaxFactory.Token(SyntaxKind.StringKeyword)),
SyntaxFactory.Token(SyntaxKind.CommaToken),
SyntaxFactory.QualifiedName(
SyntaxFactory.IdentifierName("global::System"),
SyntaxFactory.GenericName(
SyntaxFactory.Identifier("Func"))
.WithTypeArgumentList(
SyntaxFactory.TypeArgumentList(
SyntaxFactory
.SingletonSeparatedList<
TypeSyntax>(
SyntaxFactory
.PredefinedType(
SyntaxFactory.Token(
SyntaxKind
.ObjectKeyword))))))
}))))
.WithInitializer(dictionaryInitializer))))))
.WithModifiers(
SyntaxFactory.TokenList(
SyntaxFactory.Token(SyntaxKind.PrivateKeyword),
SyntaxFactory.Token(SyntaxKind.StaticKeyword)))
.NormalizeWhitespace()
.WithLeadingTrivia(SyntaxFactory.TriviaList(SyntaxFactory.ElasticCarriageReturnLineFeed))
.WithTrailingTrivia(SyntaxFactory.TriviaList(SyntaxFactory.ElasticCarriageReturnLineFeed, SyntaxFactory.ElasticCarriageReturnLineFeed))
);
return AddRewriteCommentIfNeeded(withDictionaryFieldNameToInitFieldValue, $"{nameof(CreateNewFieldInitMethodRewriter)}", true);
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6bbeaafe1bf54bda9b46e237bec3ccc0
timeCreated: 1674215064
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/CreateNewFieldInitMethodRewriter.cs
uploadId: 710802
@@ -0,0 +1,74 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
// When calling other extension methods from same file compilation would fail with 'The call is ambiguous between the following methods or properties'
class ExtensionMethodsCallingOtherExtensionMethodsInSameFileRewriter : FastScriptReloadCodeRewriterBase
{
private Dictionary<string, Dictionary<string, string>> _typeNameToDeclaredMethodNameToThisArgName = new Dictionary<string, Dictionary<string, string>>();
public ExtensionMethodsCallingOtherExtensionMethodsInSameFileRewriter(bool writeRewriteReasonAsComment)
: base(writeRewriteReasonAsComment)
{
}
public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
{
var classDeclaredMethodNameToThisArgName = new Dictionary<string, string>();
_typeNameToDeclaredMethodNameToThisArgName[node.Identifier.Text] = classDeclaredMethodNameToThisArgName;
foreach (var methodDeclaration in node.Members
.Where(n => n.Kind() == SyntaxKind.MethodDeclaration)
.Select(n => (MethodDeclarationSyntax)n))
{
var parameters = methodDeclaration.ParameterList.Parameters;
if (parameters.Count > 0 && parameters[0].Modifiers.Any(SyntaxKind.ThisKeyword))
{
var thisArgumentName = parameters[0].Identifier.Text;
classDeclaredMethodNameToThisArgName.TryAdd(methodDeclaration.Identifier.Text, thisArgumentName);
}
}
return base.VisitClassDeclaration(node);
}
public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax node)
{
// Check if the invocation is an instance method with a member access (e.g., selfName.CallingOtherTest())
if (node.Expression is MemberAccessExpressionSyntax memberAccess)
{
var methodName = memberAccess.Name.Identifier.Text;
var instanceArgName = memberAccess.Expression;
var className = node.Ancestors().OfType<ClassDeclarationSyntax>().First().Identifier.Text;
if (_typeNameToDeclaredMethodNameToThisArgName.TryGetValue(className, out var declaredMethodNameToThisArgName)
&& declaredMethodNameToThisArgName.TryGetValue(methodName, out var definedInstanceArgName))
{
if (instanceArgName.ToString() == definedInstanceArgName)
{
// Rewrite the invocation to a static method call
var newInvocation = SyntaxFactory.InvocationExpression(SyntaxFactory.IdentifierName(methodName))
.WithArgumentList(
SyntaxFactory.ArgumentList(
SyntaxFactory.SeparatedList(
node.ArgumentList.Arguments.Insert(0, SyntaxFactory.Argument(instanceArgName)) // Add instance as first argument
)
)
).NormalizeWhitespace();
return AddRewriteCommentIfNeeded(
newInvocation,
$"{nameof(ExtensionMethodsCallingOtherExtensionMethodsInSameFileRewriter)}:Replaced extension method call with static call"
);
}
}
}
return base.VisitInvocationExpression(node);
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9f739c197f9040efabf7f64461882d7b
timeCreated: 1727194643
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/ExtensionMethodsCallingOtherExtensionMethodsInSameFileRewriter.cs
uploadId: 710802
@@ -0,0 +1,64 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
public abstract class FastScriptReloadCodeRewriterBase : CSharpSyntaxRewriter
{
protected readonly bool _writeRewriteReasonAsComment;
protected FastScriptReloadCodeRewriterBase(bool writeRewriteReasonAsComment, bool visitIntoStructuredTrivia = false) : base(visitIntoStructuredTrivia)
{
_writeRewriteReasonAsComment = writeRewriteReasonAsComment;
}
protected SyntaxToken AddRewriteCommentIfNeeded(SyntaxToken syntaxToken, string commentText, bool append = false)
{
return AddRewriteCommentIfNeeded(syntaxToken, commentText, _writeRewriteReasonAsComment, append);
}
public static SyntaxToken AddRewriteCommentIfNeeded(SyntaxToken syntaxToken, string commentText, bool writeRewriteReasonAsComment, bool append)
{
if (writeRewriteReasonAsComment)
{
if (append)
{
return syntaxToken.WithLeadingTrivia(
syntaxToken.LeadingTrivia.Add(SyntaxFactory.Comment($"/*FSR:{commentText}*/")));
}
else
{
return syntaxToken.WithTrailingTrivia(
syntaxToken.TrailingTrivia.Add(SyntaxFactory.Comment($"/*FSR:{commentText}*/")));
}
}
return syntaxToken;
}
protected T AddRewriteCommentIfNeeded<T>(T syntaxNode, string commentText, bool append = false)
where T : SyntaxNode
{
return AddRewriteCommentIfNeeded(syntaxNode, commentText, _writeRewriteReasonAsComment, append);
}
public static T AddRewriteCommentIfNeeded<T>(T syntaxNode, string commentText, bool writeRewriteReasonAsComment, bool append) where T : SyntaxNode
{
if (writeRewriteReasonAsComment)
{
if (append)
{
return syntaxNode.WithLeadingTrivia(syntaxNode.GetLeadingTrivia()
.Add(SyntaxFactory.Comment($"/*FSR:{commentText}*/")));
}
else
{
return syntaxNode.WithTrailingTrivia(syntaxNode.GetTrailingTrivia()
.Add(SyntaxFactory.Comment($"/*FSR:{commentText}*/")));
}
}
return syntaxNode;
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: bcc848f0140d41cdbf1003b0f594694e
timeCreated: 1677233811
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/FastScriptReloadCodeRewriterBase.cs
uploadId: 710802
@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class FieldsWalker : CSharpSyntaxWalker {
private readonly Dictionary<string, List<NewFieldDeclaration>> _typeNameToFieldDeclarations = new Dictionary<string, List<NewFieldDeclaration>>();
public override void VisitClassDeclaration(ClassDeclarationSyntax node)
{
var className = node.Identifier;
var fullClassName = RoslynUtils.GetMemberFQDN(node, className.ToString());
if(!_typeNameToFieldDeclarations.ContainsKey(fullClassName)) {
_typeNameToFieldDeclarations[fullClassName] = new List<NewFieldDeclaration>();
}
base.VisitClassDeclaration(node);
}
public override void VisitFieldDeclaration(FieldDeclarationSyntax node)
{
var fieldName = node.Declaration.Variables.First().Identifier.ToString();
var fullClassName = RoslynUtils.GetMemberFQDNWithoutMemberName(node);
if(!_typeNameToFieldDeclarations.ContainsKey(fullClassName)) {
_typeNameToFieldDeclarations[fullClassName] = new List<NewFieldDeclaration>();
}
_typeNameToFieldDeclarations[fullClassName].Add(new NewFieldDeclaration(fieldName, node.Declaration.Type.ToString(), node));
base.VisitFieldDeclaration(node);
}
public Dictionary<string, List<NewFieldDeclaration>> GetTypeToFieldDeclarations() {
return _typeNameToFieldDeclarations;
}
public List<string> GetTypeNames() {
return _typeNameToFieldDeclarations.Select(kv => kv.Key).ToList();
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e4a18d5133af410bab07d9c1a973fe7a
timeCreated: 1672993042
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/FieldsWalker.cs
uploadId: 710802
@@ -0,0 +1,71 @@
using System.Collections.Generic;
using FastScriptReload.Runtime;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class HotReloadCompliantRewriter : FastScriptReloadCodeRewriterBase
{
public List<string> StrippedUsingDirectives = new List<string>();
public List<string> OriginalIdentifiersRenamedToContainPatchedPostfix = new List<string>();
public HotReloadCompliantRewriter(bool writeRewriteReasonAsComment, bool visitIntoStructuredTrivia = false)
: base(writeRewriteReasonAsComment, visitIntoStructuredTrivia)
{
}
public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
{
return AddPatchedPostfixToTopLevelDeclarations(node, node.Identifier);
//if subclasses need to be adjusted, it's done via recursion.
// foreach (var childNode in node.ChildNodes().OfType<ClassDeclarationSyntax>())
// {
// var changed = Visit(childNode);
// node = node.ReplaceNode(childNode, changed);
// }
}
public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
{
return AddPatchedPostfixToTopLevelDeclarations(node, node.Identifier);
}
public override SyntaxNode VisitEnumDeclaration(EnumDeclarationSyntax node)
{
return AddPatchedPostfixToTopLevelDeclarations(node, node.Identifier);
}
public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
return AddPatchedPostfixToTopLevelDeclarations(node, node.Identifier);
}
public override SyntaxNode VisitInterfaceDeclaration(InterfaceDeclarationSyntax node)
{
return AddPatchedPostfixToTopLevelDeclarations(node, node.Identifier);
}
public override SyntaxNode VisitUsingDirective(UsingDirectiveSyntax node)
{
if (node.Parent is CompilationUnitSyntax)
{
StrippedUsingDirectives.Add(node.ToFullString());
return null;
}
return base.VisitUsingDirective(node);
}
private SyntaxNode AddPatchedPostfixToTopLevelDeclarations(CSharpSyntaxNode node, SyntaxToken identifier)
{
OriginalIdentifiersRenamedToContainPatchedPostfix.Add(identifier.ValueText);
var newIdentifier = SyntaxFactory.Identifier(identifier + AssemblyChangesLoader.ClassnamePatchedPostfix);
newIdentifier = AddRewriteCommentIfNeeded(newIdentifier, $"{nameof(HotReloadCompliantRewriter)}:{nameof(AddPatchedPostfixToTopLevelDeclarations)}");
node = node.ReplaceToken(identifier, newIdentifier);
return node;
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f75e3e02acfa4397a558a923f7fa4f8e
timeCreated: 1672993042
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/HotReloadCompliantRewriter.cs
uploadId: 710802
@@ -0,0 +1,127 @@
using System;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
public class ManualUserDefinedScriptOverridesRewriter : FastScriptReloadCodeRewriterBase
{
private readonly SyntaxNode _userDefinedOverridesRoot;
public ManualUserDefinedScriptOverridesRewriter(SyntaxNode userDefinedOverridesRoot, bool writeRewriteReasonAsComment, bool visitIntoStructuredTrivia = false)
: base(writeRewriteReasonAsComment, visitIntoStructuredTrivia)
{
_userDefinedOverridesRoot = userDefinedOverridesRoot;
}
//TODO: refactor to use OverrideDeclarationWithMatchingUserDefinedIfExists
public override SyntaxNode VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node)
{
var methodFQDN = RoslynUtils.GetMemberFQDN(node, "operator");
var matchingInOverride = _userDefinedOverridesRoot.DescendantNodes()
//implicit conversion operators do not have name, just parameter list
.OfType<BaseMethodDeclarationSyntax>()
.FirstOrDefault(m => m.ParameterList.ToString() == node.ParameterList.ToString() //parameter lists is type / order / names, all good for targetting if there's a proper match
&& methodFQDN == RoslynUtils.GetMemberFQDN(m, "operator") //make sure same FQDN, even though there's no name there could be more implicit operators in file
);
if (matchingInOverride != null)
{
return AddRewriteCommentIfNeeded(matchingInOverride.WithTriviaFrom(node), $"User defined custom conversion override", true);
}
else {
return base.VisitConversionOperatorDeclaration(node);
}
}
//TODO: refactor to use OverrideDeclarationWithMatchingUserDefinedIfExists
public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node)
{
var methodName = node.Identifier.ValueText;
var methodFQDN = RoslynUtils.GetMemberFQDN(node, node.Identifier.ToString());
var matchingInOverride = _userDefinedOverridesRoot.DescendantNodes()
.OfType<MethodDeclarationSyntax>()
.FirstOrDefault(m => m.Identifier.ValueText == methodName
&& m.ParameterList.Parameters.Count == node.ParameterList.Parameters.Count
&& m.ParameterList.ToString() == node.ParameterList.ToString() //parameter lists is type / order / names, all good for targetting if there's a proper match
&& m.TypeParameterList?.ToString() == node.TypeParameterList?.ToString() //typed paratemets are for generics, also check
&& methodFQDN == RoslynUtils.GetMemberFQDN(m, m.Identifier.ToString()) //last check for mathod FQDN (potentially slower than others)
);
if (matchingInOverride != null)
{
return AddRewriteCommentIfNeeded(matchingInOverride.WithTriviaFrom(node), $"User defined custom method override", true);
}
else {
return base.VisitMethodDeclaration(node);
}
}
public override SyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
{
return OverrideDeclarationWithMatchingUserDefinedIfExists(
node,
(d) => d.Identifier.ValueText,
(d) => HasSameParametersPredicate(node.ParameterList)(d.ParameterList),
(d) => base.VisitConstructorDeclaration(d)
);
}
public override SyntaxNode VisitDestructorDeclaration(DestructorDeclarationSyntax node)
{
return OverrideDeclarationWithMatchingUserDefinedIfExists(
node,
(d) => d.Identifier.ValueText,
(d) => HasSameParametersPredicate(node.ParameterList)(d.ParameterList),
(d) => base.VisitDestructorDeclaration(d)
);
}
public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax node)
{
return OverrideDeclarationWithMatchingUserDefinedIfExists(
node,
(d) => d.Identifier.ValueText,
(d) => true,
(d) => base.VisitPropertyDeclaration(d)
);
}
private SyntaxNode OverrideDeclarationWithMatchingUserDefinedIfExists<T>(T node, Func<T, string> getName,
Func<T, bool> customFindMatchInOverridePredicate, Func<T, SyntaxNode> visitDefault)
where T: MemberDeclarationSyntax
{
var name = getName(node);
var fqdn = RoslynUtils.GetMemberFQDN(node, name);
var matchingInOverride = _userDefinedOverridesRoot.DescendantNodes()
.OfType<T>()
.FirstOrDefault(d =>
{
var declarationName = getName(d);
return declarationName == name
&& customFindMatchInOverridePredicate(d)
&& fqdn == RoslynUtils.GetMemberFQDN(d, declarationName); //last check for mathod FQDN (potentially slower than others)
}
);
if (matchingInOverride != null)
{
return AddRewriteCommentIfNeeded(matchingInOverride.WithTriviaFrom(node),
$"User defined custom {typeof(T)} override", true);
}
else
{
return visitDefault(node);
}
}
private Func<ParameterListSyntax, bool> HasSameParametersPredicate(ParameterListSyntax parameters)
{
return (resolvedParams) => resolvedParams.Parameters.Count == parameters.Parameters.Count
&& resolvedParams.ToString() == parameters.ToString();
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7d61f64c891c45b68a7db1ea67854127
timeCreated: 1678101034
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/ManualUserDefinedScriptOverridesRewriter.cs
uploadId: 710802
@@ -0,0 +1,18 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
public class NewFieldDeclaration
{
public string FieldName { get; }
public string TypeName { get; }
public FieldDeclarationSyntax FieldDeclarationSyntax { get; } //TODO: PERF: will that block whole tree from being garbage collected
public NewFieldDeclaration(string fieldName, string typeName, FieldDeclarationSyntax fieldDeclarationSyntax)
{
FieldName = fieldName;
TypeName = typeName;
FieldDeclarationSyntax = fieldDeclarationSyntax;
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ad6e49db99ff4065b14a3fc416af560b
timeCreated: 1673019285
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/NewFieldDeclaration.cs
uploadId: 710802
@@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FastScriptReload.Runtime;
using FastScriptReload.Scripts.Runtime;
using ImmersiveVrToolsCommon.Runtime.Logging;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class NewFieldsRewriter : FastScriptReloadCodeRewriterBase
{
private readonly Dictionary<string, List<string>> _typeToNewFieldDeclarations;
public NewFieldsRewriter(Dictionary<string, List<string>> typeToNewFieldDeclarations, bool writeRewriteReasonAsComment)
:base(writeRewriteReasonAsComment)
{
_typeToNewFieldDeclarations = typeToNewFieldDeclarations;
}
public static List<MemberInfo> GetReplaceableMembers(Type type)
{ //TODO: later other might need to be included? props?
return type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Cast<MemberInfo>().ToList();
}
public override SyntaxNode VisitInvocationExpression(InvocationExpressionSyntax node)
{
if (node.Expression.ToString() == "nameof")
{
var classNode = node.Ancestors().OfType<ClassDeclarationSyntax>().FirstOrDefault();
if (classNode != null)
{
var fullClassName = RoslynUtils.GetMemberFQDN(classNode, classNode.Identifier.ToString());
if (!string.IsNullOrEmpty(fullClassName))
{
var nameofExpressionParts = node.ArgumentList.Arguments.First().ToFullString().Split('.'); //nameof could have multiple . like NewFieldCustomClass.FieldInThatClass
var fieldName = nameofExpressionParts.First(); // should take first part only to determine if new field eg. 'NewFieldCustomClass'
if (_typeToNewFieldDeclarations.TryGetValue(fullClassName, out var allNewFieldNamesForClass))
{
if (allNewFieldNamesForClass.Contains(fieldName))
{
return AddRewriteCommentIfNeeded(
SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(nameofExpressionParts.Last())), // should take last part only to for actual string eg. 'FieldInThatClass'
$"{nameof(NewFieldsRewriter)}:{nameof(VisitInvocationExpression)}");
}
}
}
}
}
return base.VisitInvocationExpression(node);
}
public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
{
var classNode = node.Ancestors().OfType<ClassDeclarationSyntax>().FirstOrDefault();
if (classNode != null)
{
var fullClassName = RoslynUtils.GetMemberFQDN(classNode, classNode.Identifier.ToString());
if (!string.IsNullOrEmpty(fullClassName))
{
var fieldName = node.Identifier.ToString();
if (_typeToNewFieldDeclarations.TryGetValue(fullClassName, out var allNewFieldNamesForClass))
{
if (allNewFieldNamesForClass.Contains(fieldName))
{
if(node.Parent is MemberAccessExpressionSyntax memberAccessExpressionSyntax)
{
//for member access expressions only rewrite if used with .this, eg this.NewField, that prevents rewriting of static class fields with same name
if (!memberAccessExpressionSyntax.ToString().StartsWith("this."))
{
return base.VisitIdentifierName(node);
}
}
var isNameOfExpression = node.Ancestors().OfType<InvocationExpressionSyntax>().Any(e => e.Expression.ToString() == "nameof");
if (!isNameOfExpression) //nameof expression will be rewritten via VisitInvocationExpression
{
return
AddRewriteCommentIfNeeded(
SyntaxFactory.MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
SyntaxFactory.InvocationExpression(
SyntaxFactory.MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
SyntaxFactory.IdentifierName(typeof(TemporaryNewFieldValues).FullName),
SyntaxFactory.GenericName(
SyntaxFactory.Identifier(nameof(TemporaryNewFieldValues.ResolvePatchedObject)))
.WithTypeArgumentList(
SyntaxFactory.TypeArgumentList(
SyntaxFactory.SingletonSeparatedList<TypeSyntax>(
SyntaxFactory.IdentifierName(fullClassName + AssemblyChangesLoader.ClassnamePatchedPostfix))))))
.WithArgumentList(
SyntaxFactory.ArgumentList(
SyntaxFactory.SingletonSeparatedList<ArgumentSyntax>(
SyntaxFactory.Argument(
SyntaxFactory.ThisExpression())))),
SyntaxFactory.IdentifierName(fieldName))
.WithTriviaFrom(node),
$"{nameof(NewFieldsRewriter)}:{nameof(VisitIdentifierName)}"
);
}
}
}
else
{
LoggerScoped.LogWarning($"Unable to find type: {fullClassName}");
}
}
}
return base.VisitIdentifierName(node);
}
public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
{
var fieldName = node.Declaration.Variables.First().Identifier.ToString();
var fullClassName = RoslynUtils.GetMemberFQDNWithoutMemberName(node);
if (_typeToNewFieldDeclarations.TryGetValue(fullClassName, out var newFields))
{
if (newFields.Contains(fieldName))
{
var existingLeading = node.GetLeadingTrivia();
var existingTrailing = node.GetTrailingTrivia();
return AddRewriteCommentIfNeeded(
node
.WithLeadingTrivia(existingLeading.Add(SyntaxFactory.Comment("/* ")))
.WithTrailingTrivia(existingTrailing.Insert(0, SyntaxFactory.Comment(" */ //Auto-excluded to prevent exceptions - see docs"))),
$"{nameof(NewFieldsRewriter)}:{nameof(VisitFieldDeclaration)}"
);
}
}
return base.VisitFieldDeclaration(node);
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0e9e687bdfc0444395deab1e7c68ed3f
timeCreated: 1672993042
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/NewFieldsRewriter.cs
uploadId: 710802
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 919d4ff85d4d4156bddf5c48bcc99da1
timeCreated: 1719699288
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
public static class PartialClassFinder
{
//TODO: optimize lookup, currently this loads all files in directory and checks if they have 'partial' string in them. For directories with many files this will not be sufficient
public static IEnumerable<string> FindPartialClassFilesInDirectory(string filePath, int maxDepth = int.MaxValue)
{
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
return Enumerable.Empty<string>();
string directory = Path.GetDirectoryName(filePath);
string fileContent = File.ReadAllText(filePath);
string partialClassName = ExtractPartialClassName(fileContent);
if (string.IsNullOrEmpty(partialClassName))
{
Debug.LogWarning($"No partial class/struct found in file: {filePath}");
return Enumerable.Empty<string>();
}
return FindPartialClassFilesRecursively(directory, partialClassName, maxDepth, currentDepth: 0);
}
private static IEnumerable<string> FindPartialClassFilesRecursively(string directory, string partialClassName, int maxDepth, int currentDepth)
{
var files = new List<string>();
try
{
// Search in current directory
files.AddRange(Directory.GetFiles(directory, "*.cs")
.Where(file => IsPartialClassFile(file, partialClassName)));
// If we haven't reached max depth, search in subdirectories
if (currentDepth < maxDepth)
{
foreach (var subDir in Directory.GetDirectories(directory))
{
files.AddRange(FindPartialClassFilesRecursively(subDir, partialClassName, maxDepth, currentDepth + 1));
}
}
}
catch (UnauthorizedAccessException ex)
{
Debug.LogWarning($"Access denied to directory: {directory}. Error: {ex.Message}");
}
catch (Exception ex)
{
Debug.LogError($"Error searching directory: {directory}. Error: {ex.Message}");
}
return files;
}
private static bool IsPartialClassFile(string filePath, string className)
{
try
{
string content = File.ReadAllText(filePath);
return content.Contains($"partial class {className}")
|| content.Contains($"partial struct {className}");
}
catch (Exception ex)
{
Debug.LogError($"Error reading file: {filePath}. Error: {ex.Message}");
return false;
}
}
private static string ExtractPartialClassName(string fileContent)
{
// This is a simple implementation and might need to be more robust
// depending on your specific needs
var partialClassDeclaration = fileContent.Split(new[] { "partial class", "partial struct" }, StringSplitOptions.RemoveEmptyEntries)
.Skip(1)
.FirstOrDefault();
if (partialClassDeclaration == null)
return string.Empty;
return partialClassDeclaration.TrimStart().Split(new[] { ' ', '{', ':' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault().Trim();
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6f182f9db524441e80f367f8f99d8a5f
timeCreated: 1719778688
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/Partials/PartialClassFinder.cs
uploadId: 710802
@@ -0,0 +1,92 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
internal static class PartialTreeProcessor
{
/// <summary>
/// Processes a syntax tree containing partial type definitions, merging it with other partial definitions found in the same directory.
/// </summary>
/// <param name="tree">The original syntax tree to process.</param>
/// <param name="definedPreprocessorSymbols">A collection of defined preprocessor symbols.</param>
/// <returns>A new SyntaxTree with merged partial types and added InternalsVisibleTo attribute.</returns>
/// <remarks>
/// This method performs the following steps:
/// 1. Checks if the tree contains partial types.
/// 2. If it does, processes the current tree and other partial files in the same directory.
/// 3. Combines all partial type declarations.
/// 4. Creates a new compilation unit with merged types and using directives.
/// 5. Adds the InternalsVisibleTo attribute to the resulting tree.
/// </remarks>
internal static SyntaxTree ProcessPartialTree(SyntaxTree tree, IEnumerable<string> definedPreprocessorSymbols)
{
if (!HasPartialTypes(tree))
{
return tree;
}
var combinedTypes = new Dictionary<string, List<TypeDeclarationSyntax>>();
var combinedUsingDirectives = new HashSet<UsingDirectiveSyntax>();
var combinedTypesDefined = new HashSet<string>();
ProcessTree(tree, combinedTypes, combinedUsingDirectives, combinedTypesDefined);
const int fileSearchMaxDepth = 5;
var otherPartialFiles = PartialClassFinder.FindPartialClassFilesInDirectory(tree.FilePath, fileSearchMaxDepth)
.Where(file => file != tree.FilePath);
foreach (var file in otherPartialFiles)
{
var partialTree = CSharpSyntaxTree.ParseText(File.ReadAllText(file), path: file);
ProcessTree(partialTree, combinedTypes, combinedUsingDirectives, combinedTypesDefined);
}
var combinedTypeDeclarations = combinedTypes
.Select(kvp => PartialTypeCombiner.CombinePartialType(kvp.Value))
.ToList<MemberDeclarationSyntax>();
var newRoot = SyntaxFactory.CompilationUnit()
.WithUsings(SyntaxFactory.List(combinedUsingDirectives))
.WithMembers(SyntaxFactory.List(combinedTypeDeclarations))
.WithAdditionalAnnotations(new SyntaxAnnotation("PreprocessorSymbols", string.Join(",", definedPreprocessorSymbols)));
return CSharpSyntaxTree.Create(newRoot, null, tree.FilePath)
.AddInternalsVisibleToAttribute();
}
private static bool HasPartialTypes(SyntaxTree tree)
{
var root = tree.GetCompilationUnitRoot();
return root.DescendantNodes().OfType<TypeDeclarationSyntax>().Any(type => type.Modifiers.Any(SyntaxKind.PartialKeyword));
}
private static void ProcessTree(
SyntaxTree tree,
Dictionary<string, List<TypeDeclarationSyntax>> combinedTypes,
HashSet<UsingDirectiveSyntax> combinedUsingDirectives,
HashSet<string> combinedTypesDefined)
{
var root = tree.GetCompilationUnitRoot();
combinedUsingDirectives.UnionWith(root.Usings);
foreach (var typeDecl in root.DescendantNodes().OfType<TypeDeclarationSyntax>())
{
var fullName = NamespaceHelper.GetFullyQualifiedName(typeDecl);
combinedTypesDefined.Add(fullName);
if (!combinedTypes.TryGetValue(fullName, out var declarations))
{
declarations = new List<TypeDeclarationSyntax>();
combinedTypes[fullName] = declarations;
}
declarations.Add(typeDecl);
}
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4aafad9b85b44ebe902ba3cee7bda205
timeCreated: 1719954990
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/Partials/PartialTreeProcessor.cs
uploadId: 710802
@@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
internal static class PartialTypeCombiner
{
internal static TypeDeclarationSyntax CombinePartialType(List<TypeDeclarationSyntax> declarations)
{
if (declarations.Count == 1)
return declarations[0];
var firstDeclaration = declarations[0];
var combinedMembers = declarations.SelectMany(d => d.Members).ToList();
var combinedModifiers = declarations
.SelectMany(d => d.Modifiers)
.Where(m => !m.IsKind(SyntaxKind.PartialKeyword))
.GroupBy(m => m.ValueText)
.Select(g => g.First().WithTrailingTrivia(SyntaxFactory.Space))
.ToList();
if (!combinedModifiers.Any(m => m.IsKind(SyntaxKind.PartialKeyword)))
combinedModifiers.Add(SyntaxFactory.Token(SyntaxKind.PartialKeyword).WithTrailingTrivia(SyntaxFactory.Space));
var combinedBaseList = declarations
.Where(d => d.BaseList != null)
.SelectMany(d => d.BaseList.Types)
.GroupBy(t => t.ToString())
.Select(g => g.First())
.ToList();
return firstDeclaration
.WithMembers(SyntaxFactory.List(combinedMembers))
.WithModifiers(SyntaxFactory.TokenList(combinedModifiers))
.WithKeyword(firstDeclaration.Keyword.WithLeadingTrivia(SyntaxFactory.Space))
.WithBaseList(combinedBaseList.Any()
? SyntaxFactory.BaseList(SyntaxFactory.SeparatedList(combinedBaseList))
: null);
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cc8170320f3a463590d434f7e0570ea0
timeCreated: 1719955225
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/Partials/PartialTypeCombiner.cs
uploadId: 710802
@@ -0,0 +1,52 @@
using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
internal static class NamespaceHelper
{
internal static string GetFullyQualifiedName(TypeDeclarationSyntax typeDeclaration)
{
var namespaces = new List<string>();
var currentNode = typeDeclaration.Parent;
while (currentNode != null)
{
if (currentNode is NamespaceDeclarationSyntax namespaceDeclaration)
{
namespaces.Add(namespaceDeclaration.Name.ToString());
}
currentNode = currentNode.Parent;
}
namespaces.Reverse();
var namespaceName = string.Join(".", namespaces);
return string.IsNullOrEmpty(namespaceName)
? typeDeclaration.Identifier.Text
: $"{namespaceName}.{typeDeclaration.Identifier.Text}";
}
}
internal static class SyntaxTreeExtensions
{
internal static SyntaxTree AddInternalsVisibleToAttribute(this SyntaxTree tree)
{
var root = tree.GetCompilationUnitRoot();
var attributeArgument = SyntaxFactory.AttributeArgument(
SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal("Assembly-CSharp"))
);
var attribute = SyntaxFactory.Attribute(
SyntaxFactory.ParseName("System.Runtime.CompilerServices.InternalsVisibleTo"),
SyntaxFactory.AttributeArgumentList(SyntaxFactory.SeparatedList(new[] { attributeArgument }))
);
var attributeList = SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(attribute))
.WithTarget(SyntaxFactory.AttributeTargetSpecifier(SyntaxFactory.Token(SyntaxKind.AssemblyKeyword)));
var newRoot = root.AddAttributeLists(attributeList);
return tree.WithRootAndOptions(newRoot, tree.Options);
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1c2f0e22f1a24fcda6d0c0516b428420
timeCreated: 1719954970
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/Partials/SyntaxTreeHelpers.cs
uploadId: 710802
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
public static class SyntaxTreeMergePartialsExtensions
{
public static IEnumerable<SyntaxTree> MergePartials(
this IEnumerable<SyntaxTree> trees,
IEnumerable<string> definedPreprocessorSymbols)
{
return trees
.Select(tree => PartialTreeProcessor.ProcessPartialTree(tree, definedPreprocessorSymbols))
.ToList();
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 550c942c025f4fd5a1062891f3623c60
timeCreated: 1719174342
AssetOrigin:
serializedVersion: 1
productId: 239351
packageName: Fast Script Reload
packageVersion: 1.6.1
assetPath: Assets/FastScriptReload/Scripts/Editor/Compilation/CodeRewriting/Partials/SyntaxTreeMergePartialsExtensions.cs
uploadId: 710802
Loaded 100 of 734 files, more files were not shown because too many files have changed in this diff. Show more