1- ## Under the hood
1+ # Under the hood
22
33IncrementalCompiler for Unity3D was my fun-project for 2016 new year's holiday.
44At that time I was thinking about slow compilation speed of unity3d-mono and
@@ -55,7 +55,7 @@ public static class CSharp60SupportActivator {
5555 list .Add (new CustomCSharpLanguage ());
5656 }
5757 private static List <SupportedLanguage > GetSupportedLanguages () {
58- var fieldInfo = typeof (ScriptCompilers ).GetField (" _supportedLanguages" , BindingFlags . NonPublic | BindingFlags . Static );
58+ var fieldInfo = typeof (ScriptCompilers ).GetField (" _supportedLanguages" , .. . );
5959 var languages = (List <SupportedLanguage >)fieldInfo .GetValue (null );
6060 return languages ;
6161 }
@@ -79,8 +79,8 @@ compiler can be written without any hard work.
7979// Minimal C# compiler
8080Assembly Build (string [] sourcePaths , string [] referencePaths , string [] defines ) {
8181 var assemblyName = Path .GetRandomFileName ();
82- var syntaxTrees = sourcePaths .Select (file => CSharpSyntaxTree .ParseText (File .ReadAllText (file ), path : file )). ToArray ( );
83- var references = referencePaths .Select (file => MetadataReference .CreateFromFile (file )). ToArray () ;
82+ var syntaxTrees = sourcePaths .Select (file => CSharpSyntaxTree .ParseText (File .ReadAllText (file )) );
83+ var references = referencePaths .Select (file => MetadataReference .CreateFromFile (file ));
8484 var compilation = CSharpCompilation .Create (assemblyName , syntaxTrees , references );
8585 using (var ms = new MemoryStream ())
8686 compilation .Emit (ms );
@@ -175,11 +175,11 @@ MDB file should be constructed and they already provided a tool to convert pdb t
175175jbevain update support output of visual studio 2015 [ pdb2mdb] ( https://gist.github.com/jbevain/ba23149da8369e4a966f )
176176
177177So simple process supporting unity3d is
178- - Emit pdb via roslyn
178+ - Emit pdb via Roslyn
179179 - Convert pdb to mdb with pdb2mdb tool
180180
181- But how about emitting mdb from roslyn directly? it can save time for generating and converting pdb?
182- A guy at Xamarain already tried it but it is not updated now. So I grab his work and update it to work latest roslyn .
181+ But how about emitting mdb from Roslyn directly? it can save time for generating and converting pdb?
182+ A guy at Xamarain already tried it but it is not updated now. So I grab his work and update it to work latest Roslyn .
183183
184184### Renaming symbol for UnityVS debugging
185185
@@ -257,11 +257,12 @@ public static bool IsCSharpGenerator(Value thisValue) {
257257}
258258public override UnityProperty [] VariableProperties () {
259259 return (from f in base .Type .GetInstanceFields ()
260- where ! f .Name .StartsWith (" <>" ) && ! f .Name .StartsWith (" <$" )
261- where f .Name .StartsWith (" <" )
262- where f .Name .Contains (" >__" )
263- select f into field
264- select base .Field (field , field .Name .Substring (1 , field .Name .IndexOf (" >__" , 1 , System .StringComparison .InvariantCulture ) - 1 ))).ToArray <UnityProperty >();
260+ where ! f .Name .StartsWith (" <>" ) && ! f .Name .StartsWith (" <$" )
261+ where f .Name .StartsWith (" <" )
262+ where f .Name .Contains (" >__" )
263+ select f into field
264+ select base .Field (field , field .Name .Substring (1 , field .Name .IndexOf (" >__" , 1 ) - 1 ))
265+ ).ToArray <UnityProperty >();
265266}
266267```
267268
@@ -281,7 +282,7 @@ second one was chosen.
281282
282283Check roslyn source related with this naming .
283284```csharp
284- internal static string MakeHoistedLocalFieldName (SynthesizedLocalKind kind , int slotIndex , string localNameOpt = null ) {
285+ internal static string MakeHoistedLocalFieldName (SynthesizedLocalKind kind , .. . ) {
285286 var result = PooledStringBuilder .GetInstance ();
286287 var builder = result .Builder ;
287288 builder .Append ('<' );
0 commit comments