misc: chore: Fix object creation in Common project

This commit is contained in:
Evan Husted 2025-01-26 15:21:47 -06:00
parent ae92fbf539
commit 7f5a356c3d
5 changed files with 12 additions and 12 deletions

View file

@ -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))
{

View file

@ -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();
}

View file

@ -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));
}
}

View file

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

View file

@ -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