Comments (4)
Thanks - that looks good, and targetting just VisitRecordDeclaration
makes it quite isolated. It'd be great if you can create a PR and I'll merge that in
from fastscriptreload.
Actually the issue is witch the record keyword itself not specifically on the shortcut syntax of records.
from fastscriptreload.
Also :
- Tried to add a script override, for instance adding suffix
public record LeapAction__Patched_
- FSR still rewrites it
public record LeapAction
- The constructor gets rewritten with the suffix though :
public LeapAction__Patched_()
. - We end up with the compiler throwing on the ctor
error CS1520: Method must have a return type'
as the ctor is recognised as a regular function.
from fastscriptreload.
Alright, I think I got it, I post the workaround here and either I'll do a PR or someone else after further testing, for now it looks okay with the regular and the shotcut syntax.
Add in DynamicCompilationBase just before user Scripts overrides :
root = new RecordeRewriter(DebugWriteRewriteReasonAsComment).Visit(root);
Rewriter :
using FastScriptReload.Runtime;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace FastScriptReload.Editor.Compilation.CodeRewriting
{
class RecordeRewriter : FastScriptReloadCodeRewriterBase
{
public RecordeRewriter(bool writeRewriteReasonAsComment)
: base(writeRewriteReasonAsComment)
{
}
public override SyntaxNode VisitRecordDeclaration(RecordDeclarationSyntax node)
{
return AdjustRecordName(node, node.Identifier);
}
private SyntaxNode AdjustRecordName(RecordDeclarationSyntax node, SyntaxToken nodeIdentifier)
{
var typeName = nodeIdentifier.ToString(); //Not ToFullString() as it may include spaces and break.
if (!typeName.EndsWith(AssemblyChangesLoader.ClassnamePatchedPostfix))
{
typeName += AssemblyChangesLoader.ClassnamePatchedPostfix;
}
return AddRewriteCommentIfNeeded(
node.ReplaceToken(nodeIdentifier, SyntaxFactory.Identifier(typeName)),
$"{nameof(RecordeRewriter)}:{nameof(AdjustRecordName)}"
);
}
}
}
from fastscriptreload.
Related Issues (20)
- Bug: Odin Inspector 3 compatibility error HOT 8
- [Error] An error is caused if the source code contains English characters HOT 1
- Reload Outside PlayMode in 2022.3.81f Not Working! HOT 1
- Why are all these Harmony and VR specify types being referenced? HOT 1
- Does this work at runtime or not? Its very not clear. HOT 1
- Incorrect rewrite for switch assignment (using new language features)
- Added fields not working with Unity editors drawn without IMGUI (ie 2022.3) HOT 1
- Multiple precompiled assemblies with the same name System.Threading.Tasks.Extensions.dll HOT 1
- Static fields in changed code are lost upon reload HOT 1
- Add support to reload modules with Unity's IsExternalInit workaround to C# records HOT 3
- Error for "DrawOdinInspector" HOT 3
- File Watcher allocates 100 KB per frame -> lag spikes on GC HOT 1
- Try to fix rewrite for self file extension method HOT 3
- FileWatcherImplementation does not contain a definition for DirectWindowsApi HOT 3
- Exception when immersive debugging is enabled HOT 1
- Seems haven't supported Unity 2023??? HOT 2
- New Private field issues
- Issue with the Rewired package and FSR 1.6 HOT 2
- Fast Script Reload (via Live Script Reload v.1.7 on Asset Store) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastscriptreload.