@@ -77,10 +77,10 @@ private static IEnumerable FindAllYarnProjects()
77
77
private const int PROJECT_UPDATE_TIMEOUT = 80 ; // ms
78
78
79
79
private static ConcurrentDictionary < string , DateTime > _projectPathToLastUpdateTime =
80
- new ConcurrentDictionary < string , DateTime > ( ) ;
80
+ new ( ) ;
81
81
82
- private static Dictionary < string , Task > _projectPathToUpdateTask = new Dictionary < string , Task > ( ) ;
83
- private static object _lastUpdateLock = new object ( ) ;
82
+ private static Dictionary < string , Task > _projectPathToUpdateTask = new ( ) ;
83
+ private static object _lastUpdateLock = new ( ) ;
84
84
85
85
/// <summary>
86
86
/// Queue up a re-compile of scripts in a yarn project, add all associated data to the project,
@@ -412,7 +412,7 @@ public static void CompileAllScripts(YarnProject project)
412
412
{
413
413
lock ( project )
414
414
{
415
- List < FunctionInfo > newFunctionList = new List < FunctionInfo > ( ) ;
415
+ List < FunctionInfo > newFunctionList = new ( ) ;
416
416
var assetPath = project . ResourcePath ;
417
417
GD . Print ( $ "Compiling all scripts in { assetPath } ") ;
418
418
@@ -447,7 +447,7 @@ public static void CompileAllScripts(YarnProject project)
447
447
errors = compilationResult . Value . Diagnostics . Where ( d =>
448
448
d . Severity == Diagnostic . DiagnosticSeverity . Error ) ;
449
449
450
- if ( errors . Count ( ) > 0 )
450
+ if ( errors . Any ( ) )
451
451
{
452
452
var errorGroups = errors . GroupBy ( e => e . FileName ) ;
453
453
foreach ( var errorGroup in errorGroups )
@@ -489,7 +489,7 @@ public static void CompileAllScripts(YarnProject project)
489
489
var newDeclarations = new List < Declaration > ( ) //localDeclarations
490
490
. Concat ( compilationResult . Value . Declarations )
491
491
. Where ( decl => ! decl . Name . StartsWith ( "$Yarn.Internal." ) )
492
- . Where ( decl => ! ( decl . Type is FunctionType ) )
492
+ . Where ( decl => decl . Type is not FunctionType )
493
493
. Select ( decl =>
494
494
{
495
495
SerializedDeclaration existingDeclaration = null ;
@@ -514,15 +514,13 @@ public static void CompileAllScripts(YarnProject project)
514
514
515
515
CreateYarnInternalLocalizationAssets ( project , compilationResult . Value ) ;
516
516
517
- using ( var memoryStream = new MemoryStream ( ) )
518
- using ( var outputStream = new CodedOutputStream ( memoryStream ) )
519
- {
520
- // Serialize the compiled program to memory
521
- compilationResult . Value . Program . WriteTo ( outputStream ) ;
522
- outputStream . Flush ( ) ;
517
+ using var memoryStream = new MemoryStream ( ) ;
518
+ using var outputStream = new CodedOutputStream ( memoryStream ) ;
519
+ // Serialize the compiled program to memory
520
+ compilationResult . Value . Program . WriteTo ( outputStream ) ;
521
+ outputStream . Flush ( ) ;
523
522
524
- compiledBytes = memoryStream . ToArray ( ) ;
525
- }
523
+ compiledBytes = memoryStream . ToArray ( ) ;
526
524
}
527
525
528
526
project . ListOfFunctions = newFunctionList . ToArray ( ) ;
@@ -614,7 +612,6 @@ public static FunctionInfo CreateFunctionInfoFromMethodGroup(MethodInfo method)
614
612
/// <seealso cref="assembliesToSearch"/>
615
613
public static bool searchAllAssembliesForActions = true ;
616
614
617
-
618
615
private static void CreateYarnInternalLocalizationAssets ( YarnProject project ,
619
616
CompilationResult compilationResult )
620
617
{
@@ -678,7 +675,7 @@ public static IEnumerable<StringTableEntry> GenerateStringsTable(YarnProject pro
678
675
var errors =
679
676
compilationResult . Value . Diagnostics . Where ( d => d . Severity == Diagnostic . DiagnosticSeverity . Error ) ;
680
677
681
- if ( errors . Count ( ) > 0 )
678
+ if ( errors . Any ( ) )
682
679
{
683
680
GD . PrintErr ( "Can't generate a strings table from a Yarn Project that contains compile errors" , null ) ;
684
681
return null ;
@@ -755,15 +752,14 @@ private static string GenerateCommentWithLineMetadata(string[] metadata)
755
752
{
756
753
var cleanedMetadata = RemoveLineIDFromMetadata ( metadata ) ;
757
754
758
- if ( cleanedMetadata . Count ( ) == 0 )
755
+ if ( ! cleanedMetadata . Any ( ) )
759
756
{
760
757
return string . Empty ;
761
758
}
762
759
763
760
return $ "Line metadata: { string . Join ( " " , cleanedMetadata ) } ";
764
761
}
765
762
766
-
767
763
/// <summary>
768
764
/// Removes any line ID entry from an array of line metadata.
769
765
/// Line metadata will always contain a line ID entry if it's set. For
@@ -823,9 +819,7 @@ public static void AddLineTagsToFilesInYarnProject(YarnProject project)
823
819
if ( containsErrors )
824
820
{
825
821
GD . PrintErr ( $ "Can't check for existing line tags in { path } because it contains errors.") ;
826
- return new string [ ]
827
- {
828
- } ;
822
+ return Array . Empty < string > ( ) ;
829
823
}
830
824
831
825
return result . StringTable . Where ( i => i . Value . isImplicitTag == false ) . Select ( i => i . Key ) ;
0 commit comments