Skip to content

DaZombieKiller/UnityRoslynUpdater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Roslyn Updater

A tool to update the Roslyn compiler and C# language versions for a Unity installation.

Installation

NOTE: This will modify your Unity installation folder, administrative privileges are required!

Interactive Mode

Launch the tool directly to interactively select a Unity editor version to patch.

Command Line (Advanced) Mode

Pass the Unity editor path to UnityRoslynUpdater.exe:

UnityRoslynUpdater.exe <path to Unity Editor folder>

For example: UnityRoslynUpdater.exe "C:\Program Files\Unity\Hub\Editor\2022.3.8f1\Editor"

Usage

After updating the Roslyn compiler, newer C# language versions are available but not enabled by default. To enable them, you must explicitly opt in for each assembly definition in your project.

Create a csc.rsp file in the same directory as your assembly definition (.asmdef) file with the following content (replace 14 with your desired language version):

-langversion:14

NOTE: Version 2.0.24 or later of the com.unity.ide.visualstudio package is required for the language version specified in csc.rsp to be reflected in the generated .csproj files.

Language Support

  • Working
    • Feature works exactly as expected.
  • PolySharp
    • Feature works when using PolySharp and/or manually implementing missing APIs.
  • Not Supported
    • Requires runtime features or BCL changes that Unity does not have. Attempting to use the feature may result in compiler errors.
  • Crash
    • Requires runtime features that Unity does not have. Attempting to use the feature may compile, but will result in crashes.

C# 14

Feature Status
Extension members Working
Null-conditional assignment Working
nameof supports unbound generic types Working
More implicit conversions for Span<T> and ReadOnlySpan<T> Working
Modifiers on simple lambda parameters Working
field backed properties Working
partial events and constructors Working

C# 13

Feature Status
params collections Working
New lock type and semantics Not Supported
New escape sequence - \e Working
Method group natural type improvements Working
Implicit indexer access in object initializers Working
Enable ref locals and unsafe contexts in iterators and async methods Working
Enable ref struct types to implement interfaces Not Supported
Allow ref struct types as arguments for type parameters in generics Not Supported
Partial properties and indexers Working
Overload resolution priority PolySharp
field backed properties Working

C# 12

Feature Status
Primary constructors Working
Optional parameters in lambda expressions Working
Alias any type Working
Inline arrays Not Supported
Collection expressions Working
Interceptors Not Supported

C# 11

Feature Status
Raw string literals Working
static abstract/static virtual members in interfaces Not Supported
Checked user defined operators Working
Relaxed shift operators Working
Unsigned right-shift operator Working
Generic attributes Crash
UTF-8 string literals Working
Newlines in string interpolations Working
List patterns Working
File-local types Working
Required members PolySharp
Auto-default structs Working
Pattern match Span<char> or ReadOnlySpan<char> on a constant string Working
Extended nameof scope Working
Numeric IntPtr and UIntPtr Working
ref fields Not Supported
ref scoped variables PolySharp
Improved method group conversion to delegate Working

C# 10

Feature Status
Record structs Working
Improvements of structure types Working
Interpolated string handler PolySharp
Global using directives Working
File-scoped namespace declaration Working1
Extended property patterns Working
Lambda expression improvements Working
Constant interpolated strings Working
Record types can seal ToString Working
Assignment and declaration in same deconstruction Working
Improved definite assignment Working
Allow AsyncMethodBuilder attribute on methods Not Supported2
CallerArgumentExpression attribute PolySharp
Enhanced #line pragma Working
  1. Unity 2021 and earlier require UnityNamespacePatch to be installed.
  2. AsyncMethodBuilderAttribute requires changes to its [AttributeUsage] attribute for this to work.

About

A tool to update the Roslyn compiler and C# language versions for a Unity installation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •