@@ -50,20 +50,20 @@ However, unfortunately, [there are no plans to backport to Unity 2020.1 or earli
50
50
51
51
<br >
52
52
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!
55
55
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 )
58
58
59
59
### Features
60
60
61
61
* Easy to use.
62
62
* This package is out of the box!
63
63
* Change the C# compiler (csc) used on your Unity project.
64
64
* 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)
67
67
* Resolve the [ issue #2 ] ( https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/issues/2 )
68
68
* [ OpenSesame.Net.Compilers] [ ] : Allows access to internals/privates in other assemblies (run on Unity built-in mono)
69
69
* [ 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!
75
75
* 3.6.0: C# 8.0 Supported.
76
76
* 3.7.0: C# 8.0 Supported.
77
77
* 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.
78
82
* For other versions, see the nuget package page above.
79
83
* Change the C# language version.
80
84
* 7.0
81
85
* 7.1
82
86
* 7.2
83
87
* 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)
86
91
* 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 ` ...
88
93
* Change the C# compiler settings for each ` *.asmdef ` file.
89
94
* Portability: The assembly works even in the projects that do not have this package installed.
90
95
* The best option when distributing as a package.
@@ -94,7 +99,7 @@ Let's enjoy C# 8.0 features with your Unity project!
94
99
* The symbols starting with ` '!' ` will be removed.
95
100
* e.g. ` SYMBOL_TO_ADD;!SYMBOL_TO_REMOVE;... `
96
101
* Modify ` langversion ` property in * .csproj file.
97
- * If ` dotnet ` is required, install it automatically.
102
+ * If ` dotnet ` is required, it will be installed automatically.
98
103
* ` CompilerType.BuiltIn ` compiler option to disable this plugin.
99
104
* ` Enable Logging ` option to display compilation log.
100
105
* ` 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!
106
111
* Variables of a reference type, string for example, are non-nullable. All nullability warnings are disabled.
107
112
* ` disable ` : The nullable annotation context is disabled. The nullable warning context is disabled.
108
113
* 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.
110
115
111
116
[ OpenSesame.Net.Compilers ] : https://www.nuget.org/packages/OpenSesame.Net.Compilers
112
117
[ 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!
115
120
116
121
### Feature plans
117
122
118
- * Add a dropdown menu to select version.
119
- * Verify the selected pakcage name and version.
120
123
* Show package description.
121
124
122
125
### NOTE: Please do so at your own risk!
@@ -179,19 +182,6 @@ The selected nuget package will be used for compilation.
179
182
180
183
The project setting asset for C# Compiler will be saved in ` ProjectSettings/CSharpCompilerSettings.asset ` .
181
184
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
-
195
185
<br ><br >
196
186
197
187
### Configure C# compiler settings for ` *.asmodef ` file
@@ -235,23 +225,80 @@ Some features required external library.
235
225
236
226
<br ><br >
237
227
238
- ### For C# 9.0 features (preview)
228
+ ### For C# 9.0 features
239
229
240
230
[ C# 9.0 features] ( https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9 )
241
231
[ samples] ( https://github.com/mob-sakai/CSharpCompilerSettingsForUnity/tree/sandbox/Assets/C%23%209.0%20Features )
242
232
243
233
If you want to use the C# 9.0 features, set it up as follows:
244
234
245
235
* 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 `
248
238
249
239
** NOTE:** Some features is not available. It requires ` .Net 5 ` .
250
240
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
+
251
256
<br ><br ><br ><br >
252
257
253
258
## Development Notes
254
259
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
+
255
302
### How to include the asmdef in ` Packages ` directory
256
303
257
304
By default, asmdefs under ` Packages ` and ` Assets/Standard Assets/ ` are ** NOT** compiled with the custom compiler package.
0 commit comments