Просмотр исходного кода

misc: chore: Fix object creation in Common project

Evan Husted 1 год назад
Родитель
Сommit
7f5a356c3d

+ 1 - 1
src/Ryujinx.Common/Extensions/SequenceReaderExtensions.cs

@@ -164,7 +164,7 @@ namespace Ryujinx.Common.Extensions
             // Not enough data in the current segment, try to peek for the data we need.
             T buffer = default;
 
-            Span<byte> tempSpan = new Span<byte>(&buffer, sizeof(T));
+            Span<byte> tempSpan = new(&buffer, sizeof(T));
 
             if (!reader.TryCopyTo(tempSpan))
             {

+ 2 - 2
src/Ryujinx.Common/Utilities/EmbeddedResources.cs

@@ -91,7 +91,7 @@ namespace Ryujinx.Common
                 return null;
             }
 
-            using StreamReader reader = new StreamReader(stream);
+            using StreamReader reader = new(stream);
             return reader.ReadToEnd();
         }
 
@@ -103,7 +103,7 @@ namespace Ryujinx.Common
                 return null;
             }
 
-            using StreamReader reader = new StreamReader(stream);
+            using StreamReader reader = new(stream);
             return await reader.ReadToEndAsync();
         }
 

+ 2 - 2
src/Ryujinx.Common/Utilities/FileSystemUtils.cs

@@ -9,7 +9,7 @@ namespace Ryujinx.Common.Utilities
         public static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
         {
             // Get information about the source directory
-            DirectoryInfo dir = new DirectoryInfo(sourceDir);
+            DirectoryInfo dir = new(sourceDir);
 
             // Check if the source directory exists
             if (!dir.Exists)
@@ -49,7 +49,7 @@ namespace Ryujinx.Common.Utilities
 
         public static string SanitizeFileName(string fileName)
         {
-            HashSet<char> reservedChars = new HashSet<char>(Path.GetInvalidFileNameChars());
+            HashSet<char> reservedChars = new(Path.GetInvalidFileNameChars());
             return string.Concat(fileName.Select(c => reservedChars.Contains(c) ? '_' : c));
         }
     }

+ 1 - 1
src/Ryujinx.Common/Utilities/MessagePackObjectFormatter.cs

@@ -19,7 +19,7 @@ namespace Ryujinx.Common.Utilities
 
         public static string Format(MessagePackObject obj)
         {
-            IndentedStringBuilder builder = new IndentedStringBuilder();
+            IndentedStringBuilder builder = new();
 
             FormatMsgPackObj(obj, builder);
 

+ 6 - 6
src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs

@@ -46,7 +46,7 @@ namespace Ryujinx.Common.Utilities
         {
             if (Path.GetExtension(filename).Equals(".XCI", StringComparison.InvariantCultureIgnoreCase))
             {
-                XCIFileTrimmer trimmer = new XCIFileTrimmer(filename, log);
+                XCIFileTrimmer trimmer = new(filename, log);
                 return trimmer.CanBeTrimmed;
             }
 
@@ -57,7 +57,7 @@ namespace Ryujinx.Common.Utilities
         {
             if (Path.GetExtension(filename).Equals(".XCI", StringComparison.InvariantCultureIgnoreCase))
             {
-                XCIFileTrimmer trimmer = new XCIFileTrimmer(filename, log);
+                XCIFileTrimmer trimmer = new(filename, log);
                 return trimmer.CanBeUntrimmed;
             }
 
@@ -267,7 +267,7 @@ namespace Ryujinx.Common.Utilities
 
             try
             {
-                FileInfo info = new FileInfo(Filename);
+                FileInfo info = new(Filename);
                 if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                 {
                     try
@@ -288,7 +288,7 @@ namespace Ryujinx.Common.Utilities
                     return OperationOutcome.FileSizeChanged;
                 }
 
-                FileStream outfileStream = new FileStream(_filename, FileMode.Open, FileAccess.Write, FileShare.Write);
+                FileStream outfileStream = new(_filename, FileMode.Open, FileAccess.Write, FileShare.Write);
 
                 try
                 {
@@ -327,7 +327,7 @@ namespace Ryujinx.Common.Utilities
             {
                 Log?.Write(LogType.Info, "Untrimming...");
 
-                FileInfo info = new FileInfo(Filename);
+                FileInfo info = new(Filename);
                 if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                 {
                     try
@@ -348,7 +348,7 @@ namespace Ryujinx.Common.Utilities
                     return OperationOutcome.FileSizeChanged;
                 }
 
-                FileStream outfileStream = new FileStream(_filename, FileMode.Append, FileAccess.Write, FileShare.Write);
+                FileStream outfileStream = new(_filename, FileMode.Append, FileAccess.Write, FileShare.Write);
                 long bytesToWriteB = UntrimmedFileSizeB - FileSizeB;
 
                 try