@@ -50,20 +50,20 @@ However, unfortunately, [there are no plans to backport to Unity 2020.1 or earli
5050
5151<br >
5252
53- This package changes the C# compiler (csc) used on your Unity project, to support C# 8.0.
54- Let's enjoy C# 8.0 features with your Unity project!
53+ This package changes the C# compiler (csc) used on your Unity project, to support C# 8.0, C# 9.0 and more .
54+ Let's enjoy new C# features with your Unity project!
5555
56- ![ ] ( https://user-images.githubusercontent.com/12690315/97001486-62ec2e80-1573-11eb-9003-d40eb8ed8904 .png )
57- ![ ] ( https://user-images.githubusercontent.com/12690315/97001169-e3f6f600-1572-11eb-8504-c528130c2234 .png )
56+ ![ ] ( https://user-images.githubusercontent.com/12690315/147154292-934d64f3-7cb4-43d5-8f43-3b9eab4431c6 .png )
57+ ![ ] ( https://user-images.githubusercontent.com/12690315/147154296-bf04b026-8270-4b8f-91ce-0b546fc764c3 .png )
5858
5959### Features
6060
6161* Easy to use.
6262 * This package is out of the box!
6363* Change the C# compiler (csc) used on your Unity project.
6464 * Change the nuget package name.
65- * ** [ Microsoft.Net.Compilers] [ ] : Official compiler (default, run on Unity built-in mono)**
66- * [ Microsoft.Net.Compilers.Toolset] [ ] : Official compiler (run on dotnet)
65+ * ** [ Microsoft.Net.Compilers] [ ] : Official compiler (default in legacy Unity , run on Unity built-in mono)**
66+ * [ Microsoft.Net.Compilers.Toolset] [ ] : Official compiler (default in modern Uniity, run on dotnet)
6767 * Resolve the [ issue #2 ] ( https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/issues/2 )
6868 * [ OpenSesame.Net.Compilers] [ ] : Allows access to internals/privates in other assemblies (run on Unity built-in mono)
6969 * [ OpenSesame.Net.Compilers.Toolset] [ ] : Allows access to internals/privates in other assemblies (run on dotnet)
@@ -75,16 +75,21 @@ Let's enjoy C# 8.0 features with your Unity project!
7575 * 3.6.0: C# 8.0 Supported.
7676 * 3.7.0: C# 8.0 Supported.
7777 * 3.8.0 (preview): C# 9.0 Supported.
78+ * ** 3.9.0: C# 9.0 Supported. (default in Unity 2021.2.0)**
79+ * 3.10.0: C# 9.0 Supported.
80+ * 3.11.0: C# 9.0 Supported.
81+ * 4.0.1: C# 10.0 Supported.
7882 * For other versions, see the nuget package page above.
7983 * Change the C# language version.
8084 * 7.0
8185 * 7.1
8286 * 7.2
8387 * 7.3
84- * ** 8.0 (latest, default in Unity 2020.2.0)**
85- * 9.0 (preview)
88+ * ** 8.0 (default in Unity 2020.2.0)**
89+ * ** 9.0 (default in Unity 2021.2.0)**
90+ * 10.0 (latest)
8691* Add the scripting define symbols based on language version on compiling.
87- * e.g. ` CSHARP_7_3_OR_LATER ` , ` CSHARP_8_OR_LATER ` , ` CSHARP_9_OR_LATER `
92+ * e.g. ` CSHARP_7_3_OR_LATER ` , ` CSHARP_8_OR_LATER ` , ` CSHARP_9_OR_LATER ` ...
8893* Change the C# compiler settings for each ` *.asmdef ` file.
8994 * Portability: The assembly works even in the projects that do not have this package installed.
9095 * The best option when distributing as a package.
@@ -94,7 +99,7 @@ Let's enjoy C# 8.0 features with your Unity project!
9499 * The symbols starting with ` '!' ` will be removed.
95100 * e.g. ` SYMBOL_TO_ADD;!SYMBOL_TO_REMOVE;... `
96101* Modify ` langversion ` property in * .csproj file.
97- * If ` dotnet ` is required, install it automatically.
102+ * If ` dotnet ` is required, it will be installed automatically.
98103* ` CompilerType.BuiltIn ` compiler option to disable this plugin.
99104* ` Enable Logging ` option to display compilation log.
100105* ` Nullable ` option to enable [ Nullable reference types (C# 8.0)] ( https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types ) .
@@ -106,7 +111,7 @@ Let's enjoy C# 8.0 features with your Unity project!
106111 * Variables of a reference type, string for example, are non-nullable. All nullability warnings are disabled.
107112 * ` disable ` : The nullable annotation context is disabled. The nullable warning context is disabled.
108113 * Variables of a reference type are oblivious, just like earlier versions of C#. All nullability warnings are disabled.
109- * ` Analyzer ` option to analyze your code on compile.
114+ * ` Analyzer/Source Generator Packages ` option to analyze/generate your code on compile.
110115
111116[ OpenSesame.Net.Compilers ] : https://www.nuget.org/packages/OpenSesame.Net.Compilers
112117[ OpenSesame.Net.Compilers.Toolset ] : https://www.nuget.org/packages/OpenSesame.Net.Compilers.Toolset
@@ -115,8 +120,6 @@ Let's enjoy C# 8.0 features with your Unity project!
115120
116121### Feature plans
117122
118- * Add a dropdown menu to select version.
119- * Verify the selected pakcage name and version.
120123* Show package description.
121124
122125### NOTE: Please do so at your own risk!
@@ -179,19 +182,6 @@ The selected nuget package will be used for compilation.
179182
180183The project setting asset for C# Compiler will be saved in ` ProjectSettings/CSharpCompilerSettings.asset ` .
181184
182- ``` json
183- {
184- "m_UseDefaultCompiler" : false ,
185- "m_Version" : 110 ,
186- "m_CompilerType" : 1 ,
187- "m_PackageName" : " Microsoft.Net.Compilers.Toolset" ,
188- "m_PackageVersion" : " 3.8.0-3.final" ,
189- "m_LanguageVersion" : 2147483646 ,
190- "m_EnableLogging" : true ,
191- "m_ModifySymbols" : " "
192- }
193- ```
194-
195185<br ><br >
196186
197187### Configure C# compiler settings for ` *.asmodef ` file
@@ -235,23 +225,80 @@ Some features required external library.
235225
236226<br ><br >
237227
238- ### For C# 9.0 features (preview)
228+ ### For C# 9.0 features
239229
240230[ C# 9.0 features] ( https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9 )
241231[ samples] ( https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/sandbox/Assets/C%23%209.0%20Features )
242232
243233If you want to use the C# 9.0 features, set it up as follows:
244234
245235* Package Name: ** Microsoft.Net.Compilers**
246- * Package Version: ** 3.8.0-2.final ** or later
247- * Language Version: ** preview **
236+ * Package Version: ** 3.9.0 ** or later
237+ * Language Version: ** latest ** or ` CSharp_9 `
248238
249239** NOTE:** Some features is not available. It requires ` .Net 5 ` .
250240
241+ <br ><br >
242+
243+ ### For C# 10.0 features
244+
245+ [ C# 10.0 features] ( https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10 )
246+ [ samples] ( https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/sandbox/Assets/C%23%2010.0%20Features )
247+
248+ If you want to use the C# 10.0 features, set it up as follows:
249+
250+ * Package Name: ** Microsoft.Net.Compilers.Toolset**
251+ * Package Version: ** 4.0.1** or later
252+ * Language Version: ** latest** or ` CSharp_10 `
253+
254+ ** NOTE:** Some features is not available. It requires ` .Net 6 ` .
255+
251256<br ><br ><br ><br >
252257
253258## Development Notes
254259
260+ ### How to update CSharpCompilerSettings
261+
262+ - See [ installation] ( #installation ) section to update package
263+ - Click ` Project Settings > C# Compoler > Reload ` to reload all ` CSharpCompilerSettings_*.dll ` assemblies
264+
265+
266+ <br ><br >
267+
268+ ### For Unity 2021.1 or later
269+
270+ In Unity 2021.1 or later, the compile flow has changed significantly. (#11 )
271+ The source code must pass both the built-in compiler and the custom compiler.
272+ Please use the ` CUSTOM_COMPILE ` directive as follows:
273+
274+ ``` csharp
275+ using System ;
276+ using NUnit .Framework ;
277+
278+ namespace IgnoreAccessibility
279+ {
280+ public class IgnoreAccessibilityContent
281+ {
282+ private int privateNumber = 999 ;
283+ }
284+
285+ public class IgnoreAccessibilityTest
286+ {
287+ [Test ]
288+ public void GetPrivateField ()
289+ {
290+ #if CUSTOM_COMPILE
291+ Assert .AreEqual (new IgnoreAccessibilityContent ().privateNumber , 999 );
292+ #else
293+ throw new NotImplementedException ();
294+ #endif
295+ }
296+ }
297+ }
298+ ```
299+
300+ <br ><br >
301+
255302### How to include the asmdef in ` Packages ` directory
256303
257304By default, asmdefs under ` Packages ` and ` Assets/Standard Assets/ ` are ** NOT** compiled with the custom compiler package.
0 commit comments