Skip to content

Commit

Permalink
Repeat autoformat to get simpler new syntax with explicit type
Browse files Browse the repository at this point in the history
  • Loading branch information
TiKevin83 committed Sep 1, 2023
1 parent 8b23976 commit e6ecb63
Show file tree
Hide file tree
Showing 473 changed files with 1,635 additions and 1,672 deletions.
2 changes: 1 addition & 1 deletion src/BizHawk.BizInvoke/BizExvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class BizExvoker

static BizExvoker()
{
AssemblyName aname = new AssemblyName("BizExvokeProxyAssembly");
AssemblyName aname = new("BizExvokeProxyAssembly");
ImplAssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(aname, AssemblyBuilderAccess.Run);
ImplModuleBuilder = ImplAssemblyBuilder.DefineDynamicModule("BizExvokerModule");
}
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.BizInvoke/BizInvokeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static TypeBuilder CreateDelegateType(MethodInfo method, CallingConventio
delegateInvoke.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);

// add the [UnmanagedFunctionPointer] to the delegate so interop will know how to call it
CustomAttributeBuilder attr = new CustomAttributeBuilder(
CustomAttributeBuilder attr = new(
typeof(UnmanagedFunctionPointerAttribute).GetConstructor(new[] { typeof(CallingConvention) })!,
new object[] { nativeCall });
delegateType.SetCustomAttribute(attr);
Expand Down
6 changes: 3 additions & 3 deletions src/BizHawk.BizInvoke/BizInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public object Create(IImportResolver dll, IMonitor? monitor, ICallingConventionA

static BizInvoker()
{
AssemblyName aname = new AssemblyName("BizInvokeProxyAssembly");
AssemblyName aname = new("BizInvokeProxyAssembly");
ImplAssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(aname, AssemblyBuilderAccess.Run);
ImplModuleBuilder = ImplAssemblyBuilder.DefineDynamicModule("BizInvokerModule");
ClassFieldOffset = BizInvokerUtilities.ComputeClassFirstFieldOffset();
Expand Down Expand Up @@ -174,7 +174,7 @@ private static InvokerImpl CreateProxy(Type baseType, bool monitor, bool nonTriv
}

// hooks that will be run on the created proxy object
List<Action<object, IImportResolver, ICallingConventionAdapter>> postCreateHooks = new List<Action<object, IImportResolver, ICallingConventionAdapter>>();
List<Action<object, IImportResolver, ICallingConventionAdapter>> postCreateHooks = new();

var type = ImplModuleBuilder.DefineType($"Bizhawk.BizInvokeProxy{baseType.Name}", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed, baseType);

Expand Down Expand Up @@ -331,7 +331,7 @@ private static Action<object, IImportResolver, ICallingConventionAdapter> Implem
{
var paramInfos = baseMethod.GetParameters();
var paramTypes = paramInfos.Select(p => p.ParameterType).ToArray();
List<ParameterLoadInfo> paramLoadInfos = new List<ParameterLoadInfo>();
List<ParameterLoadInfo> paramLoadInfos = new();
var returnType = baseMethod.ReturnType;
if (returnType != typeof(void) && !returnType.IsPrimitive && !returnType.IsPointer && !returnType.IsEnum)
{
Expand Down
6 changes: 3 additions & 3 deletions src/BizHawk.BizInvoke/BizInvokerUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private class CF
/// <returns></returns>
public static int ComputeStringOffset()
{
string s = new string(Array.Empty<char>());
string s = new(Array.Empty<char>());
int ret;
fixed(char* fx = s)
{
Expand Down Expand Up @@ -92,7 +92,7 @@ public static int ComputeValueArrayElementOffset()
public static int ComputeObjectArrayElementOffset()
{
object[] obj = new object[4];
DynamicMethod method = new DynamicMethod("ComputeObjectArrayElementOffsetHelper", typeof(int), new[] { typeof(object[]) }, typeof(string).Module, true);
DynamicMethod method = new("ComputeObjectArrayElementOffsetHelper", typeof(int), new[] { typeof(object[]) }, typeof(string).Module, true);
var il = method.GetILGenerator();
var local = il.DeclareLocal(typeof(object[]), true);
il.Emit(OpCodes.Ldarg_0);
Expand Down Expand Up @@ -122,7 +122,7 @@ public static int ComputeFieldOffset(FieldInfo fi)
}

object obj = FormatterServices.GetUninitializedObject(fi.DeclaringType);
DynamicMethod method = new DynamicMethod("ComputeFieldOffsetHelper", typeof(int), new[] { typeof(object) }, typeof(string).Module, true);
DynamicMethod method = new("ComputeFieldOffsetHelper", typeof(int), new[] { typeof(object) }, typeof(string).Module, true);
var il = method.GetILGenerator();
var local = il.DeclareLocal(fi.DeclaringType, true);
il.Emit(OpCodes.Ldarg_0);
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.BizInvoke/CallingConventionAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private void WriteThunk(IntPtr thunkFunctionAddress, IntPtr calleeAddress, int i
{
_memory.Protect(_memory.Start, _memory.Size, MemoryBlock.Protection.RW);
var ss = _memory.GetStream(_memory.Start + (ulong)index * BlockSize, BlockSize, true);
BinaryWriter bw = new BinaryWriter(ss);
BinaryWriter bw = new(ss);

// The thunks all take the expected parameters in the expected places, but additionally take the parameter
// of the function to call as a hidden extra parameter in rax.
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.BizInvoke/FPCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static FPCtrl()
_memory = new(4096);
_memory.Protect(_memory.Start, _memory.Size, MemoryBlock.Protection.RW);
var ss = _memory.GetStream(_memory.Start, 64, true);
BinaryWriter bw = new BinaryWriter(ss);
BinaryWriter bw = new(ss);

// FYI: The push/pop is only needed on Windows, but doesn't do any harm on Linux

Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Bizware.Audio/DirectSoundSoundOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void StartPlaying()
blockAlign: _sound.BlockAlign,
bitsPerSample: _sound.BytesPerSample * 8);

SoundBufferDescription desc = new SoundBufferDescription
SoundBufferDescription desc = new()
{
Format = format,
Flags =
Expand Down
6 changes: 3 additions & 3 deletions src/BizHawk.Bizware.Audio/XAudio2SoundOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static string GetDeviceId(string deviceName)
return null;
}

using IMMDeviceEnumerator enumerator = new IMMDeviceEnumerator();
using IMMDeviceEnumerator enumerator = new();
var devices = enumerator.EnumAudioEndpoints(DataFlow.Render);
var device = devices.FirstOrDefault(capDevice => capDevice.FriendlyName == deviceName);
if (device is null)
Expand Down Expand Up @@ -62,7 +62,7 @@ public void Dispose()

public static IEnumerable<string> GetDeviceNames()
{
using IMMDeviceEnumerator enumerator = new IMMDeviceEnumerator();
using IMMDeviceEnumerator enumerator = new();
var devices = enumerator.EnumAudioEndpoints(DataFlow.Render);
return devices.Select(capDevice => capDevice.FriendlyName);
}
Expand All @@ -78,7 +78,7 @@ public void StartSound()
BufferSizeSamples = _sound.MillisecondsToSamples(_sound.ConfigBufferSizeMs);
MaxSamplesDeficit = BufferSizeSamples;

WaveFormat format = new WaveFormat(_sound.SampleRate, _sound.BytesPerSample * 8, _sound.ChannelCount);
WaveFormat format = new(_sound.SampleRate, _sound.BytesPerSample * 8, _sound.ChannelCount);
_sourceVoice = _device.CreateSourceVoice(format);

_bufferPool = new();
Expand Down
10 changes: 5 additions & 5 deletions src/BizHawk.Bizware.BizwareGL/ArtManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public void Open()
/// </summary>
public Art LoadArt(string path)
{
using FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
using FileStream fs = new(path, FileMode.Open, FileAccess.Read, FileShare.Read);
return LoadArtInternal(new BitmapBuffer(path, new BitmapLoadOptions()));
}

private Art LoadArtInternal(BitmapBuffer tex)
{
AssertIsOpen(true);

Art a = new Art(this);
Art a = new(this);
ArtLooseTextureAssociation.Add((a, tex));
ManagedArts.Add(a);

Expand Down Expand Up @@ -91,7 +91,7 @@ public void Close(bool forever = true)
throw new InvalidOperationException("Art files too big for atlas");

// prepare the output buffer
BitmapBuffer bmpResult = new BitmapBuffer(results[0].Size);
BitmapBuffer bmpResult = new(results[0].Size);

//for each item, copy it into the output buffer and set the tex parameters on them
for (int i = 0; i < atlasItems.Count; i++)
Expand All @@ -111,8 +111,8 @@ public void Close(bool forever = true)
}
}

float myDestWidth = (float)bmpResult.Width;
float myDestHeight = (float)bmpResult.Height;
float myDestWidth = bmpResult.Width;
float myDestHeight = bmpResult.Height;

art.u0 = dx / myDestWidth;
art.v0 = dy / myDestHeight;
Expand Down
6 changes: 3 additions & 3 deletions src/BizHawk.Bizware.BizwareGL/BitmapBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public BitmapBuffer Trim(out int xofs, out int yofs)

int w = maxx - minx + 1;
int h = maxy - miny + 1;
BitmapBuffer bbRet = new BitmapBuffer(w, h);
BitmapBuffer bbRet = new(w, h);
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
Expand Down Expand Up @@ -249,7 +249,7 @@ public void Pad()
/// </summary>
public BitmapBuffer(string fname, BitmapLoadOptions options)
{
using FileStream fs = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read);
using FileStream fs = new(fname, FileMode.Open, FileAccess.Read, FileShare.Read);
LoadInternal(fs, null, options);
}

Expand Down Expand Up @@ -534,7 +534,7 @@ public Bitmap ToSysdrawingBitmap()
}

var pf = HasAlpha ? PixelFormat.Format32bppArgb : PixelFormat.Format24bppRgb;
Bitmap bmp = new Bitmap(Width, Height, pf);
Bitmap bmp = new(Width, Height, pf);
ToSysdrawingBitmap(bmp);
return bmp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/BizHawk.Bizware.BizwareGL/StringRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void RenderString(IGuiRenderer renderer, float x, float y, string str)
var tex = TexturePages[bfc.TexturePage];
float w = tex.Width;
float h = tex.Height;
Rectangle bounds = new Rectangle(bfc.X, bfc.Y, bfc.Width, bfc.Height);
Rectangle bounds = new(bfc.X, bfc.Y, bfc.Width, bfc.Height);
float u0 = bounds.Left / w;
float v0 = bounds.Top / h;
float u1 = bounds.Right / w;
Expand Down
6 changes: 3 additions & 3 deletions src/BizHawk.Bizware.BizwareGL/TexAtlas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ static void AddAtlas(ICollection<(Size, List<RectItem>)> atlases, IEnumerable<Re
// this is where the texture size range is determined.
// we run this every time we make an atlas, in case we want to variably control the maximum texture output size.
// ALSO - we accumulate data in there, so we need to refresh it each time. ... lame.
List<TryFitParam> todoSizes = new List<TryFitParam>();
List<TryFitParam> todoSizes = new();
for (int i = 3; i <= MaxSizeBits; i++)
{
for (int j = 3; j <= MaxSizeBits; j++)
{
int w = 1 << i;
int h = 1 << j;
TryFitParam tfp = new TryFitParam(w, h);
TryFitParam tfp = new(w, h);
todoSizes.Add(tfp);
}
}

//run the packing algorithm on each potential size
Parallel.ForEach(todoSizes, (param) =>
{
RectangleBinPack rbp = new RectangleBinPack();
RectangleBinPack rbp = new();
rbp.Init(16384, 16384);
param.rbp.Init(param.w, param.h);
Expand Down
46 changes: 23 additions & 23 deletions src/BizHawk.Bizware.Graphics/D3D9/IGL_D3D9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public IGL_D3D9()
}

// get the native window handle
SDL_SysWMinfo wminfo = default(SDL_SysWMinfo);
SDL_SysWMinfo wminfo = default;
SDL_GetVersion(out wminfo.version);
SDL_GetWindowWMInfo(_offscreenSdl2Window, ref wminfo);
if (wminfo.subsystem != SDL_SYSWM_TYPE.SDL_SYSWM_WINDOWS)
Expand Down Expand Up @@ -93,7 +93,7 @@ public void AlternateVsyncPass(int pass)
private void CreateDevice()
{
// this object is only used for creating a device, it's not needed afterwards
using Direct3D d3d9 = new Direct3D();
using Direct3D d3d9 = new();

var pp = MakePresentParameters();

Expand Down Expand Up @@ -230,7 +230,7 @@ public Shader CreateFragmentShader(string source, string entry, bool required)
{
try
{
ShaderWrapper sw = new ShaderWrapper();
ShaderWrapper sw = new();

// ShaderFlags.EnableBackwardsCompatibility - used this once upon a time (please leave a note about why)
var result = ShaderBytecode.Compile(
Expand All @@ -242,7 +242,7 @@ public Shader CreateFragmentShader(string source, string entry, bool required)
sw.PS = new(_device, result);
sw.Bytecode = result;

Shader s = new Shader(this, sw, true);
Shader s = new(this, sw, true);
sw.IGLShader = s;

return s;
Expand All @@ -263,7 +263,7 @@ public Shader CreateVertexShader(string source, string entry, bool required)
{
try
{
ShaderWrapper sw = new ShaderWrapper();
ShaderWrapper sw = new();

var result = ShaderBytecode.Compile(
shaderSource: source,
Expand All @@ -274,7 +274,7 @@ public Shader CreateVertexShader(string source, string entry, bool required)
sw.VS = new(_device, result);
sw.Bytecode = result;

Shader s = new Shader(this, sw, true);
Shader s = new(this, sw, true);
sw.IGLShader = s;

return s;
Expand Down Expand Up @@ -375,7 +375,7 @@ public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, S
// must be placed at the end
ves[vertexLayout.Items.Count] = VertexElement.VertexDeclarationEnd;

PipelineWrapper pw = new PipelineWrapper
PipelineWrapper pw = new()
{
VertexDeclaration = new(_device, ves),
VertexShader = (ShaderWrapper)vertexShader.Opaque,
Expand All @@ -384,12 +384,12 @@ public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, S
};

// scan uniforms from reflection
List<UniformInfo> uniforms = new List<UniformInfo>();
List<UniformInfo> uniforms = new();
var vsct = pw.VertexShader.Bytecode.ConstantTable;
var psct = pw.FragmentShader.Bytecode.ConstantTable;
foreach (var ct in new[] { vsct, psct })
{
Queue<(string, EffectHandle)> todo = new Queue<(string, EffectHandle)>();
Queue<(string, EffectHandle)> todo = new();
int n = ct.Description.Constants;
for (int i = 0; i < n; i++)
{
Expand All @@ -416,8 +416,8 @@ public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, S
continue;
}

UniformInfo ui = new UniformInfo();
UniformWrapper uw = new UniformWrapper();
UniformInfo ui = new();
UniformWrapper uw = new();

ui.Opaque = uw;
string name = prefix + descr.Name;
Expand Down Expand Up @@ -606,21 +606,21 @@ public void SetMagFilter(Texture2d texture, TextureMagFilter magFilter)

public Texture2d LoadTexture(Bitmap bitmap)
{
using BitmapBuffer bmp = new BitmapBuffer(bitmap, new());
using BitmapBuffer bmp = new(bitmap, new());
return LoadTexture(bmp);
}

public Texture2d LoadTexture(Stream stream)
{
using BitmapBuffer bmp = new BitmapBuffer(stream, new());
using BitmapBuffer bmp = new(stream, new());
return LoadTexture(bmp);
}

public Texture2d CreateTexture(int width, int height)
{
Texture tex = new Texture(_device, width, height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
TextureWrapper tw = new TextureWrapper { Texture = tex };
Texture2d ret = new Texture2d(this, tw, width, height);
Texture tex = new(_device, width, height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
TextureWrapper tw = new() { Texture = tex };
Texture2d ret = new(this, tw, width, height);
return ret;
}

Expand All @@ -644,8 +644,8 @@ public unsafe void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
throw new InvalidOperationException();
}

ReadOnlySpan<byte> srcSpan = new ReadOnlySpan<byte>(bmpData.Scan0.ToPointer(), bmpData.Stride * bmp.Height);
Span<byte> dstSpan = new Span<byte>(dr.DataPointer.ToPointer(), dr.Pitch * bmp.Height);
ReadOnlySpan<byte> srcSpan = new(bmpData.Scan0.ToPointer(), bmpData.Stride * bmp.Height);
Span<byte> dstSpan = new(dr.DataPointer.ToPointer(), dr.Pitch * bmp.Height);
srcSpan.CopyTo(dstSpan);
}
finally
Expand All @@ -666,7 +666,7 @@ public Texture2d LoadTexture(BitmapBuffer bmp)
public BitmapBuffer ResolveTexture2d(Texture2d tex)
{
// TODO - lazy create and cache resolving target in RT
using Texture target = new Texture(_device, tex.IntWidth, tex.IntHeight, 1, Usage.None, Format.A8R8G8B8, Pool.SystemMemory);
using Texture target = new(_device, tex.IntWidth, tex.IntHeight, 1, Usage.None, Format.A8R8G8B8, Pool.SystemMemory);
TextureWrapper tw = (TextureWrapper)tex.Opaque;

_device.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0));
Expand All @@ -692,7 +692,7 @@ public BitmapBuffer ResolveTexture2d(Texture2d tex)

public Texture2d LoadTexture(string path)
{
using FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
using FileStream fs = new(path, FileMode.Open, FileAccess.Read, FileShare.Read);
return LoadTexture(fs);
}

Expand Down Expand Up @@ -739,9 +739,9 @@ public void FreeRenderTarget(RenderTarget rt)

public RenderTarget CreateRenderTarget(int w, int h)
{
TextureWrapper tw = new TextureWrapper { Texture = CreateRenderTargetTexture(w, h) };
Texture2d tex = new Texture2d(this, tw, w, h);
RenderTarget rt = new RenderTarget(this, tw, tex);
TextureWrapper tw = new() { Texture = CreateRenderTargetTexture(w, h) };
Texture2d tex = new(this, tw, w, h);
RenderTarget rt = new(this, tw, tex);
_renderTargets.Add(rt);
return rt;
}
Expand Down
Loading

0 comments on commit e6ecb63

Please sign in to comment.