diff --git a/.silktouch/openal-clangsharp.stout b/.silktouch/openal-clangsharp.stout index 994e242e2e..fe7129046a 100644 Binary files a/.silktouch/openal-clangsharp.stout and b/.silktouch/openal-clangsharp.stout differ diff --git a/.silktouch/vulkan-clangsharp.stout b/.silktouch/vulkan-clangsharp.stout index d905b7ace2..e2f1159004 100644 Binary files a/.silktouch/vulkan-clangsharp.stout and b/.silktouch/vulkan-clangsharp.stout differ diff --git a/generator.json b/generator.json index 8bbae05cda..1d08ab7d61 100644 --- a/generator.json +++ b/generator.json @@ -42,10 +42,12 @@ "AddIncludes", "ClangScraper", "MarkNativeNames", + "ExtractHandles", "ExtractNestedTyping", "TransformHandles", "TransformFunctions", "TransformProperties", + "IdentifySharedPrefixes", "PrettifyNames", "TransformEnums", "AddVTables", @@ -59,17 +61,23 @@ "InputTestRoot": "tests/SDL" }, "TransformHandles": { - "AssumeMissingTypesOpaque": true, - "UseDSL": true + "UseDsl": true }, "TransformFunctions": { "BoolTypes": { "SDL_bool": null } }, - "PrettifyNames": { + "IdentifySharedPrefixes": { "GlobalPrefixHints": ["SDL"] }, + "PrettifyNames": { + "Affixes": { + "SharedPrefix": { + "Remove": true + } + } + }, "TransformEnums": { "AddNoneMemberToFlags": true, "RewriteMemberValues": true @@ -95,6 +103,7 @@ "MixKhronosData", "AddOpaqueStructs", "TransformFunctions", + "IdentifySharedPrefixes", "PrettifyNames", "TransformEnums", "AddVTables", @@ -171,14 +180,17 @@ } ] }, - "PrettifyNames": { + "IdentifySharedPrefixes": { "GlobalPrefixHints": ["gl"], "PrefixOverrides": { "SyncObjectMask": "GL_SYNC", "OcclusionQueryParameterNameNV": "GL", "TexStorageAttribs": "GL", - "ContainerType": "GL" - }, + "ContainerType": "GL", + "SeparableTargetEXT": "GL" + } + }, + "PrettifyNames": { "Affixes": { "HandleType": { "Order": 1 @@ -197,6 +209,9 @@ }, "KhronosNonExclusiveVendor": { "Remove": true + }, + "SharedPrefix": { + "Remove": true } } }, @@ -228,10 +243,12 @@ "ChangeNativeClass", "AddApiProfiles", "MixKhronosData", + "ExtractHandles", "ExtractNestedTyping", "TransformHandles", "InterceptNativeFunctions", "TransformFunctions", + "IdentifySharedPrefixes", "PrettifyNames", "TransformEnums", "AddVTables", @@ -294,29 +311,20 @@ } ] }, + "IdentifySharedPrefixes": { + "GlobalPrefixHints": ["alc", "al"] + }, "PrettifyNames": { - "GlobalPrefixHints": ["alc", "al"], "NameOverrides": { "ALContext": "ALContext", "EFXEAXREVERBPROPERTIES": "EfxEaxReverbProperties", - "EFXEAXREVERBPROPERTIES_flReflectionsPan": "EfxEaxReverbPropertiesFlReflectionsPan", - "EFXEAXREVERBPROPERTIES_flLateReverbPan": "EfxEaxReverbPropertiesFlLateReverbPan", "ALCcontextHandle": "ContextHandle", "ALCdeviceHandle": "DeviceHandle", "ALBUFFERCALLBACKTYPESOFT": "BufferCallbackSOFT", - "ALBUFFERCALLBACKTYPESOFTDelegate": "BufferCallbackDelegateSOFT", "ALCEVENTPROCTYPESOFT": "ContextEventProcSOFT", - "ALCEVENTPROCTYPESOFTDelegate": "ContextEventProcDelegateSOFT", "ALEVENTPROCSOFT": "EventProcSOFT", - "ALEVENTPROCSOFTDelegate": "EventProcDelegateSOFT", "ALDEBUGPROCEXT": "DebugProcEXT", - "ALDEBUGPROCEXTDelegate": "DebugProcDelegateEXT", - "LPALFOLDBACKCALLBACK": "FoldbackCallback", - "LPALFOLDBACKCALLBACKDelegate": "FoldbackCallbackDelegate", - "EAXSetDirect": "EAXSetDirect", - "EAXGetDirect": "EAXGetDirect", - "EAXGetBufferModeDirect": "EAXGetBufferModeDirect", - "EAXSetBufferModeDirect": "EAXSetBufferModeDirect" + "LPALFOLDBACKCALLBACK": "FoldbackCallback" }, "Affixes": { "HandleType": { @@ -336,6 +344,9 @@ }, "KhronosNonExclusiveVendor": { "Remove": true + }, + "SharedPrefix": { + "Remove": true } } }, @@ -351,8 +362,7 @@ "BenefitOfTheDoubtArrayTransformation": true }, "TransformHandles": { - "AssumeMissingTypesOpaque": true, - "UseDSL": true + "UseDsl": true }, "StripAttributes": { "Remove": [ @@ -370,6 +380,7 @@ "AddIncludes", "ClangScraper", "MarkNativeNames", + "ExtractHandles", "ExtractNestedTyping", "TransformHandles", "MixKhronosData", @@ -377,6 +388,7 @@ "InterceptNativeFunctions", "TransformFunctions", "TransformProperties", + "IdentifySharedPrefixes", "PrettifyNames", "TransformEnums", "AddVTables", @@ -423,15 +435,16 @@ } }, "TransformHandles": { - "AssumeMissingTypesOpaque": true, - "UseDSL": true + "UseDsl": true }, - "PrettifyNames": { - "GlobalPrefixHints": ["PFN_vk","vk"], + "IdentifySharedPrefixes": { + "GlobalPrefixHints": ["PFN_vk", "vk"], "PrefixOverrides": { "VkPipelineCreateFlags2": "VK_PIPELINE_CREATE_2", "VkMemoryDecompressionMethodFlagsEXT": "VK_MEMORY_DECOMPRESSION_METHOD" - }, + } + }, + "PrettifyNames": { "NameOverrides": { "numAABBs": "NumAabbs" }, @@ -450,6 +463,9 @@ }, "KhronosHandleType": { "Remove": true + }, + "SharedPrefix": { + "Remove": true } } }, diff --git a/sources/OpenAL/OpenAL/al/AL.gen.cs b/sources/OpenAL/OpenAL/al/AL.gen.cs index fae97c609f..c11df0e5f9 100644 --- a/sources/OpenAL/OpenAL/al/AL.gen.cs +++ b/sources/OpenAL/OpenAL/al/AL.gen.cs @@ -8203,7 +8203,7 @@ Ref buffers SupportedApiProfile("al", ["AL_EXT_direct_context"]), SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] - public static extern int EAXGetBufferModeDirect( + public static extern int EaxGetBufferModeDirect( ContextHandle context, uint buffer, int* pReserved @@ -8218,7 +8218,7 @@ public static extern int EAXGetBufferModeDirect( [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXGetBufferModeDirect( + public static int EaxGetBufferModeDirect( ContextHandle context, uint buffer, Ref pReserved @@ -8226,7 +8226,7 @@ Ref pReserved { fixed (int* __dsl_pReserved = pReserved) { - return (int)EAXGetBufferModeDirect(context, buffer, __dsl_pReserved); + return (int)EaxGetBufferModeDirect(context, buffer, __dsl_pReserved); } } @@ -8236,7 +8236,7 @@ Ref pReserved SupportedApiProfile("al", ["AL_EXT_direct_context"]), SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] - public static extern int EAXGetDirect( + public static extern int EaxGetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -8254,7 +8254,7 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXGetDirect( + public static int EaxGetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -8266,7 +8266,7 @@ uint value_size fixed (void* __dsl_value = value) fixed (System.Guid* __dsl_property_set_id = property_set_id) { - return (int)EAXGetDirect( + return (int)EaxGetDirect( context, __dsl_property_set_id, property_id, @@ -8283,7 +8283,7 @@ uint value_size SupportedApiProfile("al", ["AL_EXT_direct_context"]), SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] - public static extern sbyte EAXSetBufferModeDirect( + public static extern sbyte EaxSetBufferModeDirect( ContextHandle context, int n, uint* buffers, @@ -8299,7 +8299,7 @@ int value [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static MaybeBool EAXSetBufferModeDirect( + public static MaybeBool EaxSetBufferModeDirect( ContextHandle context, int n, Ref buffers, @@ -8309,7 +8309,7 @@ int value fixed (uint* __dsl_buffers = buffers) { return (MaybeBool) - (sbyte)EAXSetBufferModeDirect(context, n, __dsl_buffers, value); + (sbyte)EaxSetBufferModeDirect(context, n, __dsl_buffers, value); } } @@ -8319,7 +8319,7 @@ int value SupportedApiProfile("al", ["AL_EXT_direct_context"]), SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] - public static extern int EAXSetDirect( + public static extern int EaxSetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -8337,7 +8337,7 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXSetDirect( + public static int EaxSetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -8349,7 +8349,7 @@ uint value_size fixed (void* __dsl_value = value) fixed (System.Guid* __dsl_property_set_id = property_set_id) { - return (int)EAXSetDirect( + return (int)EaxSetDirect( context, __dsl_property_set_id, property_id, @@ -16286,8 +16286,8 @@ public void SpeedOfSoundDirect(ContextHandle context, float value) => [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public int EAXGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved) => - T.EAXGetBufferModeDirect(context, buffer, pReserved); + public int EaxGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved) => + T.EaxGetBufferModeDirect(context, buffer, pReserved); [NativeName("EAXGetBufferModeDirect")] [ @@ -16298,8 +16298,8 @@ public int EAXGetBufferModeDirect(ContextHandle context, uint buffer, int* pRese [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public int EAXGetBufferModeDirect(ContextHandle context, uint buffer, Ref pReserved) => - T.EAXGetBufferModeDirect(context, buffer, pReserved); + public int EaxGetBufferModeDirect(ContextHandle context, uint buffer, Ref pReserved) => + T.EaxGetBufferModeDirect(context, buffer, pReserved); [NativeName("EAXGetDirect")] [ @@ -16310,14 +16310,14 @@ public int EAXGetBufferModeDirect(ContextHandle context, uint buffer, Ref p [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public int EAXGetDirect( + public int EaxGetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, uint source_id, void* value, uint value_size - ) => T.EAXGetDirect(context, property_set_id, property_id, source_id, value, value_size); + ) => T.EaxGetDirect(context, property_set_id, property_id, source_id, value, value_size); [NativeName("EAXGetDirect")] [ @@ -16328,14 +16328,14 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public int EAXGetDirect( + public int EaxGetDirect( ContextHandle context, Ref property_set_id, uint property_id, uint source_id, Ref value, uint value_size - ) => T.EAXGetDirect(context, property_set_id, property_id, source_id, value, value_size); + ) => T.EaxGetDirect(context, property_set_id, property_id, source_id, value, value_size); [NativeName("EAXSetBufferModeDirect")] [ @@ -16346,12 +16346,12 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public sbyte EAXSetBufferModeDirect( + public sbyte EaxSetBufferModeDirect( ContextHandle context, int n, uint* buffers, int value - ) => T.EAXSetBufferModeDirect(context, n, buffers, value); + ) => T.EaxSetBufferModeDirect(context, n, buffers, value); [NativeName("EAXSetBufferModeDirect")] [ @@ -16362,12 +16362,12 @@ int value [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public MaybeBool EAXSetBufferModeDirect( + public MaybeBool EaxSetBufferModeDirect( ContextHandle context, int n, Ref buffers, int value - ) => T.EAXSetBufferModeDirect(context, n, buffers, value); + ) => T.EaxSetBufferModeDirect(context, n, buffers, value); [NativeName("EAXSetDirect")] [ @@ -16378,14 +16378,14 @@ int value [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public int EAXSetDirect( + public int EaxSetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, uint source_id, void* value, uint value_size - ) => T.EAXSetDirect(context, property_set_id, property_id, source_id, value, value_size); + ) => T.EaxSetDirect(context, property_set_id, property_id, source_id, value, value_size); [NativeName("EAXSetDirect")] [ @@ -16396,14 +16396,14 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public int EAXSetDirect( + public int EaxSetDirect( ContextHandle context, Ref property_set_id, uint property_id, uint source_id, Ref value, uint value_size - ) => T.EAXSetDirect(context, property_set_id, property_id, source_id, value, value_size); + ) => T.EaxSetDirect(context, property_set_id, property_id, source_id, value, value_size); } public partial class ThisThread @@ -25946,11 +25946,11 @@ public static void SpeedOfSoundDirect(ContextHandle context, float value) => [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXGetBufferModeDirect( + public static int EaxGetBufferModeDirect( ContextHandle context, uint buffer, int* pReserved - ) => Underlying.Value!.EAXGetBufferModeDirect(context, buffer, pReserved); + ) => Underlying.Value!.EaxGetBufferModeDirect(context, buffer, pReserved); [NativeName("EAXGetBufferModeDirect")] [ @@ -25961,7 +25961,7 @@ public static int EAXGetBufferModeDirect( [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXGetBufferModeDirect( + public static int EaxGetBufferModeDirect( ContextHandle context, uint buffer, Ref pReserved @@ -25969,7 +25969,7 @@ Ref pReserved { fixed (int* __dsl_pReserved = pReserved) { - return (int)EAXGetBufferModeDirect(context, buffer, __dsl_pReserved); + return (int)EaxGetBufferModeDirect(context, buffer, __dsl_pReserved); } } @@ -25982,7 +25982,7 @@ Ref pReserved [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXGetDirect( + public static int EaxGetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -25990,7 +25990,7 @@ public static int EAXGetDirect( void* value, uint value_size ) => - Underlying.Value!.EAXGetDirect( + Underlying.Value!.EaxGetDirect( context, property_set_id, property_id, @@ -26008,7 +26008,7 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXGetDirect( + public static int EaxGetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -26020,7 +26020,7 @@ uint value_size fixed (void* __dsl_value = value) fixed (System.Guid* __dsl_property_set_id = property_set_id) { - return (int)EAXGetDirect( + return (int)EaxGetDirect( context, __dsl_property_set_id, property_id, @@ -26040,12 +26040,12 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static sbyte EAXSetBufferModeDirect( + public static sbyte EaxSetBufferModeDirect( ContextHandle context, int n, uint* buffers, int value - ) => Underlying.Value!.EAXSetBufferModeDirect(context, n, buffers, value); + ) => Underlying.Value!.EaxSetBufferModeDirect(context, n, buffers, value); [NativeName("EAXSetBufferModeDirect")] [ @@ -26056,7 +26056,7 @@ int value [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static MaybeBool EAXSetBufferModeDirect( + public static MaybeBool EaxSetBufferModeDirect( ContextHandle context, int n, Ref buffers, @@ -26066,7 +26066,7 @@ int value fixed (uint* __dsl_buffers = buffers) { return (MaybeBool) - (sbyte)EAXSetBufferModeDirect(context, n, __dsl_buffers, value); + (sbyte)EaxSetBufferModeDirect(context, n, __dsl_buffers, value); } } @@ -26079,7 +26079,7 @@ int value [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXSetDirect( + public static int EaxSetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -26087,7 +26087,7 @@ public static int EAXSetDirect( void* value, uint value_size ) => - Underlying.Value!.EAXSetDirect( + Underlying.Value!.EaxSetDirect( context, property_set_id, property_id, @@ -26105,7 +26105,7 @@ uint value_size [MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )] - public static int EAXSetDirect( + public static int EaxSetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -26117,7 +26117,7 @@ uint value_size fixed (void* __dsl_value = value) fixed (System.Guid* __dsl_property_set_id = property_set_id) { - return (int)EAXSetDirect( + return (int)EaxSetDirect( context, __dsl_property_set_id, property_id, @@ -42711,7 +42711,7 @@ public static void SpeedOfSoundDirect(ContextHandle context, float value) => ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - int IAL.EAXGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved) => + int IAL.EaxGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved) => ( (delegate* unmanaged)( _slots[293] is not null and var loadedFnPtr @@ -42727,8 +42727,8 @@ _slots[293] is not null and var loadedFnPtr ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static int EAXGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved) => - ThisThread.EAXGetBufferModeDirect(context, buffer, pReserved); + public static int EaxGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved) => + ThisThread.EaxGetBufferModeDirect(context, buffer, pReserved); [NativeName("EAXGetBufferModeDirect")] [ @@ -42737,11 +42737,11 @@ public static int EAXGetBufferModeDirect(ContextHandle context, uint buffer, int ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - int IAL.EAXGetBufferModeDirect(ContextHandle context, uint buffer, Ref pReserved) + int IAL.EaxGetBufferModeDirect(ContextHandle context, uint buffer, Ref pReserved) { fixed (int* __dsl_pReserved = pReserved) { - return (int)((IAL)this).EAXGetBufferModeDirect(context, buffer, __dsl_pReserved); + return (int)((IAL)this).EaxGetBufferModeDirect(context, buffer, __dsl_pReserved); } } @@ -42752,11 +42752,11 @@ int IAL.EAXGetBufferModeDirect(ContextHandle context, uint buffer, Ref pRes ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static int EAXGetBufferModeDirect( + public static int EaxGetBufferModeDirect( ContextHandle context, uint buffer, Ref pReserved - ) => ThisThread.EAXGetBufferModeDirect(context, buffer, pReserved); + ) => ThisThread.EaxGetBufferModeDirect(context, buffer, pReserved); [NativeName("EAXGetDirect")] [ @@ -42765,7 +42765,7 @@ Ref pReserved ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - int IAL.EAXGetDirect( + int IAL.EaxGetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -42788,7 +42788,7 @@ _slots[294] is not null and var loadedFnPtr ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static int EAXGetDirect( + public static int EaxGetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -42796,7 +42796,7 @@ public static int EAXGetDirect( void* value, uint value_size ) => - ThisThread.EAXGetDirect( + ThisThread.EaxGetDirect( context, property_set_id, property_id, @@ -42812,7 +42812,7 @@ uint value_size ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - int IAL.EAXGetDirect( + int IAL.EaxGetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -42825,7 +42825,7 @@ uint value_size fixed (System.Guid* __dsl_property_set_id = property_set_id) { return (int) - ((IAL)this).EAXGetDirect( + ((IAL)this).EaxGetDirect( context, __dsl_property_set_id, property_id, @@ -42843,7 +42843,7 @@ uint value_size ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static int EAXGetDirect( + public static int EaxGetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -42851,7 +42851,7 @@ public static int EAXGetDirect( Ref value, uint value_size ) => - ThisThread.EAXGetDirect( + ThisThread.EaxGetDirect( context, property_set_id, property_id, @@ -42867,7 +42867,7 @@ uint value_size ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - sbyte IAL.EAXSetBufferModeDirect(ContextHandle context, int n, uint* buffers, int value) => + sbyte IAL.EaxSetBufferModeDirect(ContextHandle context, int n, uint* buffers, int value) => ( (delegate* unmanaged)( _slots[295] is not null and var loadedFnPtr @@ -42883,12 +42883,12 @@ _slots[295] is not null and var loadedFnPtr ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static sbyte EAXSetBufferModeDirect( + public static sbyte EaxSetBufferModeDirect( ContextHandle context, int n, uint* buffers, int value - ) => ThisThread.EAXSetBufferModeDirect(context, n, buffers, value); + ) => ThisThread.EaxSetBufferModeDirect(context, n, buffers, value); [NativeName("EAXSetBufferModeDirect")] [ @@ -42897,7 +42897,7 @@ int value ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - MaybeBool IAL.EAXSetBufferModeDirect( + MaybeBool IAL.EaxSetBufferModeDirect( ContextHandle context, int n, Ref buffers, @@ -42907,7 +42907,7 @@ int value fixed (uint* __dsl_buffers = buffers) { return (MaybeBool) - (sbyte)((IAL)this).EAXSetBufferModeDirect(context, n, __dsl_buffers, value); + (sbyte)((IAL)this).EaxSetBufferModeDirect(context, n, __dsl_buffers, value); } } @@ -42918,12 +42918,12 @@ int value ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static MaybeBool EAXSetBufferModeDirect( + public static MaybeBool EaxSetBufferModeDirect( ContextHandle context, int n, Ref buffers, int value - ) => ThisThread.EAXSetBufferModeDirect(context, n, buffers, value); + ) => ThisThread.EaxSetBufferModeDirect(context, n, buffers, value); [NativeName("EAXSetDirect")] [ @@ -42932,7 +42932,7 @@ int value ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - int IAL.EAXSetDirect( + int IAL.EaxSetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -42955,7 +42955,7 @@ _slots[296] is not null and var loadedFnPtr ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static int EAXSetDirect( + public static int EaxSetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -42963,7 +42963,7 @@ public static int EAXSetDirect( void* value, uint value_size ) => - ThisThread.EAXSetDirect( + ThisThread.EaxSetDirect( context, property_set_id, property_id, @@ -42979,7 +42979,7 @@ uint value_size ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - int IAL.EAXSetDirect( + int IAL.EaxSetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -42992,7 +42992,7 @@ uint value_size fixed (System.Guid* __dsl_property_set_id = property_set_id) { return (int) - ((IAL)this).EAXSetDirect( + ((IAL)this).EaxSetDirect( context, __dsl_property_set_id, property_id, @@ -43010,7 +43010,7 @@ uint value_size ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static int EAXSetDirect( + public static int EaxSetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -43018,7 +43018,7 @@ public static int EAXSetDirect( Ref value, uint value_size ) => - ThisThread.EAXSetDirect( + ThisThread.EaxSetDirect( context, property_set_id, property_id, diff --git a/sources/OpenAL/OpenAL/al/BufferCallbackSOFT.gen.cs b/sources/OpenAL/OpenAL/al/BufferCallbackSOFT.gen.cs index 821cb1670f..d28a908f9a 100644 --- a/sources/OpenAL/OpenAL/al/BufferCallbackSOFT.gen.cs +++ b/sources/OpenAL/OpenAL/al/BufferCallbackSOFT.gen.cs @@ -19,7 +19,7 @@ namespace Silk.NET.OpenAL; public BufferCallbackSOFT(delegate* unmanaged ptr) => Pointer = ptr; - public BufferCallbackSOFT(BufferCallbackDelegateSOFT proc) => + public BufferCallbackSOFT(BufferCallbackSOFTDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); public void Dispose() => SilkMarshal.Free(Pointer); diff --git a/sources/OpenAL/OpenAL/al/BufferCallbackDelegateSOFT.gen.cs b/sources/OpenAL/OpenAL/al/BufferCallbackSOFTDelegate.gen.cs similarity index 90% rename from sources/OpenAL/OpenAL/al/BufferCallbackDelegateSOFT.gen.cs rename to sources/OpenAL/OpenAL/al/BufferCallbackSOFTDelegate.gen.cs index 9304622154..00ceea77e9 100644 --- a/sources/OpenAL/OpenAL/al/BufferCallbackDelegateSOFT.gen.cs +++ b/sources/OpenAL/OpenAL/al/BufferCallbackSOFTDelegate.gen.cs @@ -11,4 +11,4 @@ namespace Silk.NET.OpenAL; [NativeName("ALBUFFERCALLBACKTYPESOFT")] -public unsafe delegate int BufferCallbackDelegateSOFT(void* arg0, void* arg1, int arg2); +public unsafe delegate int BufferCallbackSOFTDelegate(void* arg0, void* arg1, int arg2); diff --git a/sources/OpenAL/OpenAL/al/ContextEventProcSOFT.gen.cs b/sources/OpenAL/OpenAL/al/ContextEventProcSOFT.gen.cs index 36ccd70272..cc8b15a5c4 100644 --- a/sources/OpenAL/OpenAL/al/ContextEventProcSOFT.gen.cs +++ b/sources/OpenAL/OpenAL/al/ContextEventProcSOFT.gen.cs @@ -21,7 +21,7 @@ public ContextEventProcSOFT( delegate* unmanaged ptr ) => Pointer = ptr; - public ContextEventProcSOFT(ContextEventProcDelegateSOFT proc) => + public ContextEventProcSOFT(ContextEventProcSOFTDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); public void Dispose() => SilkMarshal.Free(Pointer); diff --git a/sources/OpenAL/OpenAL/al/ContextEventProcDelegateSOFT.gen.cs b/sources/OpenAL/OpenAL/al/ContextEventProcSOFTDelegate.gen.cs similarity index 92% rename from sources/OpenAL/OpenAL/al/ContextEventProcDelegateSOFT.gen.cs rename to sources/OpenAL/OpenAL/al/ContextEventProcSOFTDelegate.gen.cs index 8bf39a4158..298338bc3a 100644 --- a/sources/OpenAL/OpenAL/al/ContextEventProcDelegateSOFT.gen.cs +++ b/sources/OpenAL/OpenAL/al/ContextEventProcSOFTDelegate.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.OpenAL; [NativeName("ALCEVENTPROCTYPESOFT")] -public unsafe delegate void ContextEventProcDelegateSOFT( +public unsafe delegate void ContextEventProcSOFTDelegate( int arg0, int arg1, DeviceHandle arg2, diff --git a/sources/OpenAL/OpenAL/al/DebugProcEXT.gen.cs b/sources/OpenAL/OpenAL/al/DebugProcEXT.gen.cs index 1c7f5c2f40..2e70e56727 100644 --- a/sources/OpenAL/OpenAL/al/DebugProcEXT.gen.cs +++ b/sources/OpenAL/OpenAL/al/DebugProcEXT.gen.cs @@ -20,7 +20,7 @@ namespace Silk.NET.OpenAL; public DebugProcEXT(delegate* unmanaged ptr) => Pointer = ptr; - public DebugProcEXT(DebugProcDelegateEXT proc) => Pointer = SilkMarshal.DelegateToPtr(proc); + public DebugProcEXT(DebugProcEXTDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); public void Dispose() => SilkMarshal.Free(Pointer); diff --git a/sources/OpenAL/OpenAL/al/DebugProcDelegateEXT.gen.cs b/sources/OpenAL/OpenAL/al/DebugProcEXTDelegate.gen.cs similarity index 93% rename from sources/OpenAL/OpenAL/al/DebugProcDelegateEXT.gen.cs rename to sources/OpenAL/OpenAL/al/DebugProcEXTDelegate.gen.cs index 55d0dbf77f..2731ebb85e 100644 --- a/sources/OpenAL/OpenAL/al/DebugProcDelegateEXT.gen.cs +++ b/sources/OpenAL/OpenAL/al/DebugProcEXTDelegate.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.OpenAL; [NativeName("ALDEBUGPROCEXT")] -public unsafe delegate void DebugProcDelegateEXT( +public unsafe delegate void DebugProcEXTDelegate( int arg0, int arg1, uint arg2, diff --git a/sources/OpenAL/OpenAL/al/EventProcSOFT.gen.cs b/sources/OpenAL/OpenAL/al/EventProcSOFT.gen.cs index a9c1b55168..9bfa68cf4e 100644 --- a/sources/OpenAL/OpenAL/al/EventProcSOFT.gen.cs +++ b/sources/OpenAL/OpenAL/al/EventProcSOFT.gen.cs @@ -20,7 +20,7 @@ namespace Silk.NET.OpenAL; public EventProcSOFT(delegate* unmanaged ptr) => Pointer = ptr; - public EventProcSOFT(EventProcDelegateSOFT proc) => Pointer = SilkMarshal.DelegateToPtr(proc); + public EventProcSOFT(EventProcSOFTDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); public void Dispose() => SilkMarshal.Free(Pointer); diff --git a/sources/OpenAL/OpenAL/al/EventProcDelegateSOFT.gen.cs b/sources/OpenAL/OpenAL/al/EventProcSOFTDelegate.gen.cs similarity index 93% rename from sources/OpenAL/OpenAL/al/EventProcDelegateSOFT.gen.cs rename to sources/OpenAL/OpenAL/al/EventProcSOFTDelegate.gen.cs index 78284252ae..aeb235dd90 100644 --- a/sources/OpenAL/OpenAL/al/EventProcDelegateSOFT.gen.cs +++ b/sources/OpenAL/OpenAL/al/EventProcSOFTDelegate.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.OpenAL; [NativeName("ALEVENTPROCSOFT")] -public unsafe delegate void EventProcDelegateSOFT( +public unsafe delegate void EventProcSOFTDelegate( int arg0, uint arg1, uint arg2, diff --git a/sources/OpenAL/OpenAL/al/IAL.gen.cs b/sources/OpenAL/OpenAL/al/IAL.gen.cs index 669d756827..8d198744cf 100644 --- a/sources/OpenAL/OpenAL/al/IAL.gen.cs +++ b/sources/OpenAL/OpenAL/al/IAL.gen.cs @@ -6027,7 +6027,7 @@ Ref buffers SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] - static abstract int EAXGetBufferModeDirect( + static abstract int EaxGetBufferModeDirect( ContextHandle context, uint buffer, int* pReserved @@ -6039,7 +6039,7 @@ static abstract int EAXGetBufferModeDirect( SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] - static abstract int EAXGetBufferModeDirect( + static abstract int EaxGetBufferModeDirect( ContextHandle context, uint buffer, Ref pReserved @@ -6051,7 +6051,7 @@ Ref pReserved SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] - static abstract int EAXGetDirect( + static abstract int EaxGetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -6066,7 +6066,7 @@ uint value_size SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] - static abstract int EAXGetDirect( + static abstract int EaxGetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -6081,7 +6081,7 @@ uint value_size SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] - static abstract sbyte EAXSetBufferModeDirect( + static abstract sbyte EaxSetBufferModeDirect( ContextHandle context, int n, uint* buffers, @@ -6094,7 +6094,7 @@ int value SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] - static abstract MaybeBool EAXSetBufferModeDirect( + static abstract MaybeBool EaxSetBufferModeDirect( ContextHandle context, int n, Ref buffers, @@ -6107,7 +6107,7 @@ int value SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] - static abstract int EAXSetDirect( + static abstract int EaxSetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -6122,7 +6122,7 @@ uint value_size SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] - static abstract int EAXSetDirect( + static abstract int EaxSetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -11433,7 +11433,7 @@ long start_time SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] - int EAXGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved); + int EaxGetBufferModeDirect(ContextHandle context, uint buffer, int* pReserved); [NativeName("EAXGetBufferModeDirect")] [ @@ -11441,7 +11441,7 @@ long start_time SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetBufferModeDirect")] - int EAXGetBufferModeDirect(ContextHandle context, uint buffer, Ref pReserved); + int EaxGetBufferModeDirect(ContextHandle context, uint buffer, Ref pReserved); [NativeName("EAXGetDirect")] [ @@ -11449,7 +11449,7 @@ long start_time SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] - int EAXGetDirect( + int EaxGetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -11464,7 +11464,7 @@ uint value_size SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXGetDirect")] - int EAXGetDirect( + int EaxGetDirect( ContextHandle context, Ref property_set_id, uint property_id, @@ -11479,7 +11479,7 @@ uint value_size SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] - sbyte EAXSetBufferModeDirect(ContextHandle context, int n, uint* buffers, int value); + sbyte EaxSetBufferModeDirect(ContextHandle context, int n, uint* buffers, int value); [NativeName("EAXSetBufferModeDirect")] [ @@ -11487,7 +11487,7 @@ uint value_size SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetBufferModeDirect")] - MaybeBool EAXSetBufferModeDirect( + MaybeBool EaxSetBufferModeDirect( ContextHandle context, int n, Ref buffers, @@ -11500,7 +11500,7 @@ int value SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] - int EAXSetDirect( + int EaxSetDirect( ContextHandle context, System.Guid* property_set_id, uint property_id, @@ -11515,7 +11515,7 @@ uint value_size SupportedApiProfile("alc", ["AL_EXT_direct_context"]) ] [NativeFunction("openal", EntryPoint = "EAXSetDirect")] - int EAXSetDirect( + int EaxSetDirect( ContextHandle context, Ref property_set_id, uint property_id, diff --git a/sources/SilkTouch/SilkTouch/Mods/BakeSourceSets.cs b/sources/SilkTouch/SilkTouch/Mods/BakeSourceSets.cs index 0f1fd372ab..16885d4a3a 100644 --- a/sources/SilkTouch/SilkTouch/Mods/BakeSourceSets.cs +++ b/sources/SilkTouch/SilkTouch/Mods/BakeSourceSets.cs @@ -98,7 +98,7 @@ class Rewriter(IBakeStrategy strategy, ILogger logger) : ModCSha public override SyntaxNode? VisitIndexerDeclaration(IndexerDeclarationSyntax node) => Visit( node, - $"this[{string.Join(", ", node.ParameterList.Parameters.Select(ModUtils.DiscrimStr))}]", + $"this[{string.Join(", ", node.ParameterList.Parameters.Select(ModUtils.GetMethodDiscriminator))}]", base.VisitIndexerDeclaration ); @@ -122,7 +122,13 @@ ConstructorDeclarationSyntax node ) => Visit( node, - ModUtils.DiscrimStr(node.Modifiers, null, string.Empty, node.ParameterList, null), + ModUtils.GetMethodDiscriminator( + node.Modifiers, + null, + string.Empty, + node.ParameterList, + null + ), base.VisitConstructorDeclaration ); @@ -132,7 +138,7 @@ ConstructorDeclarationSyntax node public override SyntaxNode? VisitOperatorDeclaration(OperatorDeclarationSyntax node) => Visit( node, - ModUtils.DiscrimStr( + ModUtils.GetMethodDiscriminator( node.Modifiers, null, $"op_{node.OperatorToken.Kind()}", @@ -147,7 +153,7 @@ ConversionOperatorDeclarationSyntax node ) => Visit( node, - ModUtils.DiscrimStr( + ModUtils.GetMethodDiscriminator( node.Modifiers, null, $"op_{node.ImplicitOrExplicitKeyword.Kind()}", @@ -160,7 +166,7 @@ ConversionOperatorDeclarationSyntax node public override SyntaxNode? VisitMethodDeclaration(MethodDeclarationSyntax node) => Visit( node, - ModUtils.DiscrimStr( + ModUtils.GetMethodDiscriminator( node.Modifiers, node.TypeParameterList, node.Identifier.ToString(), diff --git a/sources/SilkTouch/SilkTouch/Mods/Common/ModLoader.cs b/sources/SilkTouch/SilkTouch/Mods/Common/ModLoader.cs index 8556bd7539..5ad3bb237d 100644 --- a/sources/SilkTouch/SilkTouch/Mods/Common/ModLoader.cs +++ b/sources/SilkTouch/SilkTouch/Mods/Common/ModLoader.cs @@ -16,24 +16,26 @@ public class ModLoader public static Type? LoadModByName(string name) => name switch { - nameof(ChangeNamespace) => typeof(ChangeNamespace), + nameof(AddApiProfiles) => typeof(AddApiProfiles), nameof(AddIncludes) => typeof(AddIncludes), - nameof(TransformFunctions) => typeof(TransformFunctions), - nameof(PrettifyNames) => typeof(PrettifyNames), nameof(AddOpaqueStructs) => typeof(AddOpaqueStructs), nameof(AddVTables) => typeof(AddVTables), nameof(BakeSourceSets) => typeof(BakeSourceSets), - nameof(AddApiProfiles) => typeof(AddApiProfiles), - nameof(MixKhronosData) => typeof(MixKhronosData), - nameof(TransformHandles) => typeof(TransformHandles), - nameof(TransformEnums) => typeof(TransformEnums), - nameof(ExtractNestedTyping) => typeof(ExtractNestedTyping), - nameof(TransformProperties) => typeof(TransformProperties), - nameof(ClangScraper) => typeof(ClangScraper), + nameof(ChangeNamespace) => typeof(ChangeNamespace), nameof(ChangeNativeClass) => typeof(ChangeNativeClass), + nameof(ClangScraper) => typeof(ClangScraper), + nameof(ExtractHandles) => typeof(ExtractHandles), + nameof(ExtractNestedTyping) => typeof(ExtractNestedTyping), + nameof(IdentifySharedPrefixes) => typeof(IdentifySharedPrefixes), nameof(InterceptNativeFunctions) => typeof(InterceptNativeFunctions), nameof(MarkNativeNames) => typeof(MarkNativeNames), + nameof(MixKhronosData) => typeof(MixKhronosData), + nameof(PrettifyNames) => typeof(PrettifyNames), nameof(StripAttributes) => typeof(StripAttributes), + nameof(TransformEnums) => typeof(TransformEnums), + nameof(TransformFunctions) => typeof(TransformFunctions), + nameof(TransformHandles) => typeof(TransformHandles), + nameof(TransformProperties) => typeof(TransformProperties), _ => null, }; } diff --git a/sources/SilkTouch/SilkTouch/Mods/Common/ModUtils.cs b/sources/SilkTouch/SilkTouch/Mods/Common/ModUtils.cs index a0a8133a80..91dcf7c06b 100644 --- a/sources/SilkTouch/SilkTouch/Mods/Common/ModUtils.cs +++ b/sources/SilkTouch/SilkTouch/Mods/Common/ModUtils.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Runtime.InteropServices; using System.Text.RegularExpressions; using ClangSharp; using Microsoft.CodeAnalysis; @@ -13,6 +14,11 @@ namespace Silk.NET.SilkTouch.Mods; /// public static class ModUtils { + /// + /// Returns the specified list as a span. + /// + public static Span AsSpan(this List list) => CollectionsMarshal.AsSpan(list); + /// /// Converts a namespace string into an . /// @@ -101,7 +107,7 @@ string candidate /// Tokens e.g. ref, in, out. /// The type syntax. /// The discriminator string. - public static string DiscrimStr(SyntaxTokenList? toks, TypeSyntax? type) => + public static string GetMethodDiscriminator(SyntaxTokenList? toks, TypeSyntax? type) => toks?.Any(x => x.Kind() is SyntaxKind.RefKeyword or SyntaxKind.InKeyword or SyntaxKind.OutKeyword ) ?? false @@ -117,7 +123,7 @@ public static string DiscrimStr(SyntaxTokenList? toks, TypeSyntax? type) => /// The parameters of the function. /// The return type of the function. /// The discriminator string. - public static string DiscrimStr( + public static string GetMethodDiscriminator( SyntaxTokenList? modifiers, TypeParameterListSyntax? tParams, ReadOnlySpan identifier, @@ -125,8 +131,8 @@ public static string DiscrimStr( TypeSyntax? returnType ) => (modifiers?.Any(SyntaxKind.StaticKeyword) ?? false ? "static " : string.Empty) - + $"{DiscrimStr(modifiers, returnType)} {identifier}{tParams}" - + $"({string.Join(", ", @params?.Select(DiscrimStr) ?? [])})"; + + $"{GetMethodDiscriminator(modifiers, returnType)} {identifier}{tParams}" + + $"({string.Join(", ", @params?.Select(GetMethodDiscriminator) ?? [])})"; /// /// Gets a string that can be used to discriminate a function-like element for baking purposes. @@ -137,21 +143,21 @@ public static string DiscrimStr( /// The parameters of the function. /// The return type of the function. /// The discriminator string. - public static string DiscrimStr( + public static string GetMethodDiscriminator( SyntaxTokenList? modifiers, TypeParameterListSyntax? tParams, ReadOnlySpan identifier, BaseParameterListSyntax? @params, TypeSyntax? returnType - ) => DiscrimStr(modifiers, tParams, identifier, @params?.Parameters, returnType); + ) => GetMethodDiscriminator(modifiers, tParams, identifier, @params?.Parameters, returnType); /// /// Gets a string that can be used to discriminate a single parameter. /// /// The parameter. /// The discriminator string. - public static string DiscrimStr(BaseParameterSyntax param) => - DiscrimStr(param.Modifiers, param.Type); + public static string GetMethodDiscriminator(BaseParameterSyntax param) => + GetMethodDiscriminator(param.Modifiers, param.Type); /// /// Gets the relative path for this document. diff --git a/sources/SilkTouch/SilkTouch/Mods/ExtractHandles.cs b/sources/SilkTouch/SilkTouch/Mods/ExtractHandles.cs new file mode 100644 index 0000000000..d1018b9caf --- /dev/null +++ b/sources/SilkTouch/SilkTouch/Mods/ExtractHandles.cs @@ -0,0 +1,324 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.Extensions.Logging; +using Silk.NET.SilkTouch.Naming; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; + +namespace Silk.NET.SilkTouch.Mods; + +/// +/// Adds empty handle structs by searching for missing types referenced through pointers. +/// If all references to the missing type are through a pointer, +/// that missing type is then added as an empty struct. +/// +/// See for applying further transformations. +/// +public class ExtractHandles(ILogger logger) : Mod +{ + /// + public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) + { + await base.ExecuteAsync(ctx, ct); + + var project = ctx.SourceProject; + if (project == null) + { + return; + } + + var compilation = await project.GetCompilationAsync(ct); + if (compilation == null) + { + throw new InvalidOperationException("Failed to get compilation"); + } + + // Find missing handle types + var handleDiscoverer = new MissingHandleTypeDiscoverer(logger, compilation, ct); + var missingHandleTypes = handleDiscoverer.GetMissingHandleTypes(); + + // Generate syntax nodes containing empty structs to represent the missing handle types + var structGenerator = new EmptyStructGenerator(); + var syntaxNodes = structGenerator.GenerateSyntaxNodes(missingHandleTypes); + + // Add syntax nodes to the project as new documents + foreach (var (fullyQualifiedName, node) in syntaxNodes) + { + var relativePath = $"Handles/{PathForFullyQualified(fullyQualifiedName)}"; + project = project + .AddDocument( + Path.GetFileName(relativePath), + node.NormalizeWhitespace(), + filePath: project.FullPath(relativePath) + ) + .Project; + } + + ctx.SourceProject = project; + } + + private class MissingHandleTypeDiscoverer( + ILogger logger, + Compilation compilation, + CancellationToken ct + ) : SymbolVisitor + { + private readonly HashSet _nonHandleTypes = + new(SymbolEqualityComparer.Default); + private readonly Dictionary _missingTypes = + new(SymbolEqualityComparer.Default); + + private string? _currentNamespace = null; + private int _pointerTypeDepth = 0; + + /// + /// Gets all missing handle types that are found and the namespace that they should be created in. + /// + public Dictionary GetMissingHandleTypes() + { + // We need to find and generate all missing handle types + // Handle types are types that are only referenced through a pointer + // We do this by parsing through the list of type errors + var typeErrors = compilation + .GetDiagnostics(ct) + .Where(d => d.Id == "CS0246") // Type errors + .ToList(); + + // Find symbols that contain ITypeErrorSymbols + // These symbols are not necessarily ITypeErrorSymbols + var symbolsFound = new HashSet(SymbolEqualityComparer.Default); + foreach (var typeError in typeErrors) + { + var syntaxTree = typeError.Location.SourceTree; + if (syntaxTree == null) + { + continue; + } + + var semanticModel = compilation.GetSemanticModel(syntaxTree); + + // Get the syntax node the type error corresponds to + var currentSyntax = syntaxTree.GetRoot().FindNode(typeError.Location.SourceSpan); + + // Search upwards to find a syntax node that we can call GetDeclaredSymbol on + // This is because calling GetDeclaredSymbol on the starting node will just return null + var isSuccess = false; + while (currentSyntax != null && currentSyntax is not TypeDeclarationSyntax) + { + switch (currentSyntax) + { + case VariableDeclarationSyntax variableDeclarationSyntax: + { + foreach (var declaratorSyntax in variableDeclarationSyntax.Variables) + { + var symbol = semanticModel.GetDeclaredSymbol(declaratorSyntax, ct); + if (symbol != null) + { + symbolsFound.Add(symbol); + isSuccess = true; + + // All of the declarators will have the same type, so getting the first symbol is enough + break; + } + } + + break; + } + case MemberDeclarationSyntax memberDeclarationSyntax: + { + var symbol = semanticModel.GetDeclaredSymbol( + memberDeclarationSyntax, + ct + ); + if (symbol != null) + { + symbolsFound.Add(symbol); + isSuccess = true; + } + + break; + } + // Skip syntaxes that will never contain handle types + case BaseTypeSyntax: + case AttributeSyntax: + { + isSuccess = true; + break; + } + } + + currentSyntax = currentSyntax.Parent; + } + + if (!isSuccess) + { + // This is to warn of unhandled cases + logger.LogWarning( + "Failed to find corresponding symbol for type error. There may be an unhandled case in the code" + ); + } + } + + // These symbols contain at least one IErrorTypeSymbol, we need to search downwards for them + foreach (var symbol in symbolsFound) + { + Visit(symbol); + } + + return new Dictionary( + _missingTypes.Where(kvp => !_nonHandleTypes.Contains(kvp.Key)), + SymbolEqualityComparer.Default + ); + } + + public override void VisitMethod(IMethodSymbol symbol) + { + base.VisitMethod(symbol); + + _currentNamespace = symbol.NamespaceFromSymbol(); + foreach (var parameterSymbol in symbol.Parameters) + { + Visit(parameterSymbol); + } + _currentNamespace = null; + } + + public override void VisitParameter(IParameterSymbol symbol) + { + base.VisitParameter(symbol); + + _currentNamespace = symbol.NamespaceFromSymbol(); + Visit(symbol.Type); + _currentNamespace = null; + } + + public override void VisitProperty(IPropertySymbol symbol) + { + base.VisitProperty(symbol); + + _currentNamespace = symbol.NamespaceFromSymbol(); + Visit(symbol.Type); + _currentNamespace = null; + } + + public override void VisitField(IFieldSymbol symbol) + { + base.VisitField(symbol); + + _currentNamespace = symbol.NamespaceFromSymbol(); + Visit(symbol.Type); + _currentNamespace = null; + } + + public override void VisitLocal(ILocalSymbol symbol) + { + base.VisitLocal(symbol); + + _currentNamespace = symbol.NamespaceFromSymbol(); + Visit(symbol.Type); + _currentNamespace = null; + } + + public override void VisitPointerType(IPointerTypeSymbol symbol) + { + base.VisitPointerType(symbol); + + _pointerTypeDepth++; + Visit(symbol.PointedAtType); + _pointerTypeDepth--; + } + + public override void VisitNamedType(INamedTypeSymbol symbol) + { + base.VisitNamedType(symbol); + + if (symbol is IErrorTypeSymbol errorTypeSymbol) + { + if (_currentNamespace == null) + { + throw new InvalidOperationException( + $"{nameof(_currentNamespace)} should not be null" + ); + } + + if (_pointerTypeDepth == 0) + { + _nonHandleTypes.Add(errorTypeSymbol); + } + + if (_missingTypes.TryGetValue(errorTypeSymbol, out var sharedNamespace)) + { + _missingTypes[errorTypeSymbol] = NameUtils + .FindCommonPrefix([sharedNamespace, _currentNamespace], true, false, true) + .Trim('.'); + } + else + { + _missingTypes[errorTypeSymbol] = _currentNamespace; + } + } + } + } + + private class EmptyStructGenerator + { + /// + /// Generates a syntax node for each specified type. + /// + /// Map from error type symbol to the namespace the type should be created in. + /// Map from the fully qualified name of the generated type to the syntax node containing code for that type. + public Dictionary GenerateSyntaxNodes( + Dictionary typesToGenerate + ) => + GenerateSyntaxNodes( + typesToGenerate + .Select(kvp => new KeyValuePair(kvp.Key.Name, kvp.Value)) + .ToDictionary() + ); + + /// + /// Generates a syntax node for each specified type. + /// + /// Map from type name to the namespace the type should be created in. + /// Map from the fully qualified name of the generated type to the syntax node containing code for that type. + public Dictionary GenerateSyntaxNodes( + Dictionary missingHandleTypes + ) + { + var results = new Dictionary(); + foreach (var (name, ns) in missingHandleTypes) + { + var fullyQualifiedName = string.IsNullOrWhiteSpace(ns) ? name : $"{ns}.{name}"; + var structDeclarationSyntax = StructDeclaration(name) + .WithModifiers( + TokenList( + Token(SyntaxKind.PublicKeyword), + Token(SyntaxKind.UnsafeKeyword), + Token(SyntaxKind.PartialKeyword) + ) + ); + + results[fullyQualifiedName] = CompilationUnit() + .WithMembers( + SingletonList( + string.IsNullOrWhiteSpace(ns) + ? structDeclarationSyntax + : FileScopedNamespaceDeclaration( + ModUtils.NamespaceIntoIdentifierName(ns) + ) + .WithMembers( + SingletonList( + structDeclarationSyntax + ) + ) + ) + ); + } + + return results; + } + } +} diff --git a/sources/SilkTouch/SilkTouch/Mods/ExtractNestedTyping.cs b/sources/SilkTouch/SilkTouch/Mods/ExtractNestedTyping.cs index fd53e3a615..e5073907e0 100644 --- a/sources/SilkTouch/SilkTouch/Mods/ExtractNestedTyping.cs +++ b/sources/SilkTouch/SilkTouch/Mods/ExtractNestedTyping.cs @@ -322,11 +322,20 @@ mem is not StructDeclarationSyntax struc continue; } - var iden = $"{node.Identifier}_{match.Groups[1].Value}"; + var iden = $"{node.Identifier}{match.Groups[1].Value}"; _typeRenames[struc.Identifier.ToString()] = iden; struc = - VisitStructDeclaration(struc.WithIdentifier(Identifier(iden))) - as StructDeclarationSyntax + VisitStructDeclaration( + struc + .WithIdentifier(Identifier(iden)) + .WithAttributeLists( + struc.AttributeLists.AddReferencedNameAffix( + NameAffixType.Prefix, + "NestedStructParent", + node.Identifier.ToString() + ) + ) + ) as StructDeclarationSyntax ?? struc; ExtractedNestedStructs.Add(struc); members = members.RemoveAt(i--); @@ -529,6 +538,11 @@ _fallbackFromOuterFunctionPointer is not null : default ) .WithNativeName(currentNativeTypeName) + .AddReferencedNameAffix( + NameAffixType.Prefix, + "FunctionPointerParent", + currentNativeTypeName + ) .AddNameAffix( NameAffixType.Suffix, "FunctionPointerDelegateType", @@ -618,8 +632,6 @@ or SyntaxKind.ULongKeyword return base.VisitPredefinedType(node); } - private readonly NameTrimmer _nameTrimmer = new(); - // This code can probably be better. public ( Dictionary< @@ -643,7 +655,7 @@ HashSet ExtractedConstants var (enumName, enumType) in _numericTypeNames.OrderByDescending(x => x.Key.Length) ) { - var enumTrimmingName = _nameTrimmer.GetTrimmingName(null, enumName, true); + var enumTrimmingName = NameSplitter.Underscore(enumName); (EnumDeclarationSyntax, HashSet, HashSet)? extractedEnum = enumType is { } theType ? ( @@ -663,11 +675,13 @@ HashSet ExtractedConstants // taking casing into account). It is possible that this could be expanded, but this should be done // carefully to ensure we don't light up prematurely. var nextConst = false; - var trimmingName = _nameTrimmer.GetTrimmingName(null, constant, false); - foreach (var enumCandidate in (IEnumerable)[enumName, enumTrimmingName]) + var trimmingName = NameSplitter.Underscore(constant); + foreach ( + var enumCandidate in (ReadOnlySpan)[enumName, enumTrimmingName] + ) { foreach ( - var constCandidate in (IEnumerable)[constant, trimmingName] + var constCandidate in (ReadOnlySpan)[constant, trimmingName] ) { // Make sure the constant name starts with the enum name, and that there is clearly a word diff --git a/sources/SilkTouch/SilkTouch/Mods/IdentifySharedPrefixes.cs b/sources/SilkTouch/SilkTouch/Mods/IdentifySharedPrefixes.cs new file mode 100644 index 0000000000..20489a9a62 --- /dev/null +++ b/sources/SilkTouch/SilkTouch/Mods/IdentifySharedPrefixes.cs @@ -0,0 +1,726 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.Extensions.Options; +using Silk.NET.SilkTouch.Naming; + +namespace Silk.NET.SilkTouch.Mods; + +/// +/// Identifies shared prefixes, +/// such as namespace prefixes (eg: vk, gl) +/// and enum constant prefixes (eg: VK_ACCESS). +/// +/// These are identified as [NameAffix] attributes that +/// and other mods can then process further. +/// +[ModConfiguration] +public class IdentifySharedPrefixes(IOptionsSnapshot config) + : Mod +{ + /// + /// This was from the original NameTrimmer code + /// Quoting from the original documentation: + /// The second pass does not use . + /// The third pass uses naive prefix detection for . + /// + /// + /// This documentation should be expanded to explain the reasoning for each pass. + /// + private const int _passCount = 3; + + /// + /// Strings that are not allowed to be part of the final prefix. + /// + private static readonly HashSet _forbiddenPrefixes = new() { "unsigned", "per" }; + + /// + /// The configuration for the mod. + /// + public record Configuration + { + /// + /// Corrections to the automatic prefix determination. + /// + public Dictionary PrefixOverrides { get; init; } = []; + + /// + /// A list of known prefixes that are commonly used by names in the native API. + /// These are preferred when identifying shared prefixes. + /// + public List GlobalPrefixHints { get; init; } = []; + } + + /// + public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) + { + var configuration = config.Get(ctx.JobKey); + var project = ctx.SourceProject; + if (project is null) + { + return; + } + + // Sort the hints from large to small + // This makes it so that we prefer longer prefixes + var hints = configuration.GlobalPrefixHints.ToList(); + hints.Sort((x, y) => -x.Length.CompareTo(y.Length)); + configuration = configuration with { GlobalPrefixHints = hints }; + + // Gather all the names + var visitor = new Visitor(); + foreach (var doc in project.Documents) + { + visitor.Visit(await doc.GetSyntaxRootAsync(ct)); + } + + // Identify shared prefixes + var results = new Dictionary>(); + foreach (var (scope, members) in visitor.Scopes) + { + var prefixes = IdentifyPrefixes(scope, members, visitor.NonDeterminant, configuration); + if (prefixes == null) + { + continue; + } + + results.Add(scope, prefixes); + } + + // Output results as NameAffix attributes + var rewriter = new Rewriter(results); + foreach (var documentId in project.DocumentIds) + { + var document = project.GetDocument(documentId); + if (document == null) + { + continue; + } + + var syntaxRoot = await document.GetSyntaxRootAsync(ct); + if (syntaxRoot == null) + { + continue; + } + + project = document.WithSyntaxRoot(rewriter.Visit(syntaxRoot)).Project; + } + + ctx.SourceProject = project; + } + + /// + /// Identifies shared prefixes and returns a dictionary mapping the member name to the identified prefix for that member. + /// + private Dictionary? IdentifyPrefixes( + string scope, + List members, + HashSet nonDeterminant, + Configuration configuration + ) + { + List? localNames = null; + string? identifiedPrefix = null; + var naive = false; + { + for (var i = 0; i < _passCount; i++) // try with both trimming name and non trimming name + { + // Attempt to identify the hint being used. + string? hint = null; + foreach (var candidateHint in configuration.GlobalPrefixHints) + { + var match = true; + foreach (var member in members) + { + if ( + !member.UnaffixedName.StartsWith( + candidateHint, + StringComparison.OrdinalIgnoreCase + ) + ) + { + match = false; + break; + } + } + + if (match) + { + hint = candidateHint; + break; + } + } + + var result = GetPrefix( + scope, + members, + configuration.PrefixOverrides, + nonDeterminant, + hint, + useTrimmingName: i == 0, + naive: naive = i == 2 + ); + + if (result is null) + { + // skip outright. + return null; + } + + (identifiedPrefix, localNames) = result.Value; + + // If we have found a prefix, + if ( + identifiedPrefix.Length > 0 + && identifiedPrefix.Length < localNames.Min(x => x.TrimmingName.Length) + ) + { + // break and use it for trimming! + break; + } + + // If not, do most of them at least start with the hint? + if ( + hint is null + || localNames.Count(x => + x.TrimmingName.StartsWith(hint, StringComparison.OrdinalIgnoreCase) + ) + >= localNames.Count / 2 + ) + { + // Nope, nothing we can do it seems, we've already tried both trimming name and non trimming name... + continue; + } + + // The prefix is the hint! + identifiedPrefix = hint; + naive = true; + break; + } + } + + // If identifiedPrefix is null, we fall back to the hints. + // I know we've checked above whether this is the obvious answer for a given pass, + // but if we've still got no possible prefix after all the passes, then this is better than nothing. + // If the name doesn't start with the prefix, we simply won't use the prefix. + if ( + string.IsNullOrWhiteSpace(identifiedPrefix) + && configuration.GlobalPrefixHints is not { Count: > 0 } + ) + { + return null; + } + + var results = new Dictionary(); + + identifiedPrefix = identifiedPrefix?.Trim('_'); + foreach (var (originalName, unaffixedName, trimmingName) in localNames!) + { + ReadOnlySpan candidatePrefixes = !string.IsNullOrWhiteSpace(identifiedPrefix) + ? [identifiedPrefix] // Otherwise we fall back to the hints + : configuration.GlobalPrefixHints.AsSpan(); + + foreach (var candidatePrefix in candidatePrefixes) + { + if ( + naive + && ( + candidatePrefix.Length >= trimmingName.Length + || !trimmingName.StartsWith( + candidatePrefix, + StringComparison.OrdinalIgnoreCase + ) + ) + ) + { + continue; + } + + var unaffixedNameI = 0; + var isPrefixTooLong = false; + foreach (var c in candidatePrefix) + { + if (unaffixedNameI >= unaffixedName.Length) + { + isPrefixTooLong = true; + break; + } + + if (char.ToLower(c) == char.ToLower(unaffixedName[unaffixedNameI])) + { + unaffixedNameI++; + continue; + } + + if (c == '_') + { + unaffixedNameI++; + } + } + + if (isPrefixTooLong) + { + continue; + } + + // Output prefix to results + results[originalName] = unaffixedName[..unaffixedNameI]; + break; + } + } + + if (results.Count == 0) + { + return null; + } + + return results; + } + + /// + /// Gets the prefix for the given constituents of the given scope. + /// + /// The scope name if applicable. + /// The names to get a prefix for. + /// Prefix overrides. + /// List of names that should not be used for prefix determination. + /// The global prefix hint if applicable. + /// + /// Whether to use or to use the native name as-is. + /// + /// + /// Just match the start of the strings; don't bother checking for obvious name separation gaps. + /// + /// + /// Null to skip this scope outright, empty if no prefix was found, or the prefix otherwise. + /// + /// A local names list is also returned. + /// This is the list of names to be used for the remainder of the trimming process. + /// + private (string Prefix, List)? GetPrefix( + string scope, + List members, + Dictionary prefixOverrides, + HashSet? nonDeterminant, + string? hint, + bool useTrimmingName, + bool naive + ) + { + // If the type has no members, + if (members.Count == 0) + { + // skip it + return null; + } + + // Get the trimming names + var rawScopeTrimmingName = + (string.IsNullOrWhiteSpace(scope) ? null : scope) ?? hint ?? string.Empty; + var scopeTrimmingName = useTrimmingName + ? GetTrimmingName(prefixOverrides, rawScopeTrimmingName, hint) + : rawScopeTrimmingName; + + var localNames = members + .Select(member => new TrimmingNames( + member.OriginalName, + member.UnaffixedName, + useTrimmingName + ? GetTrimmingName(prefixOverrides, member.UnaffixedName, hint) + : member.UnaffixedName + )) + .ToList(); + + // Set the prefix to the prefix override for this scope, if it exists. + // This is to allow us to handle poorly/inconsistently named scopes, + // without putting special cases elsewhere in the logic + // ex: For the enum: + // enum Things { + // ThingsRGB + // ThingRGB + // } + // If we specify a prefix override of "Thing", + // then it will trim ThingsRGB to sRGB and ThingRGB to RGB + // a case like this is simple to add a special case for in the generator to handle sRGB specially, + // but see ImageChannelOrder from spirv.h for a more problematic occurrence. + string prefix; + if (prefixOverrides.TryGetValue(scope, out var @override)) + { + // Use the override + prefix = @override; + } + else + { + if (members.Count == 1) + { + if (!string.IsNullOrWhiteSpace(scopeTrimmingName)) + { + // Use the member name and its scope. + prefix = NameUtils.FindCommonPrefix( + [ + members + .First(member => + !(nonDeterminant?.Contains(member.UnaffixedName) ?? false) + ) + .UnaffixedName, + scopeTrimmingName, + ], + true, + false, + naive + ); + } + else + { + // One name. Can't determine prefix. + prefix = ""; + } + } + else + { + // Common case - Find the prefix based on the scope's members + prefix = NameUtils.FindCommonPrefix( + localNames + .Where(x => !(nonDeterminant?.Contains(x.UnaffixedName) ?? false)) + .Select(x => x.TrimmingName) + .ToList(), + // If naive mode is on and we're trimming type names, allow full matches (method class is + // probably the prefix) + naive && scope == "", + false, + naive + ); + } + } + + // If any of the children's trimming name is shorter than the prefix length, + if ( + localNames.Any(x => + x.TrimmingName.Length <= prefix.Length + && !(nonDeterminant?.Contains(x.UnaffixedName) ?? false) + ) && !string.IsNullOrWhiteSpace(scopeTrimmingName) + ) + { + // Do a second pass, but put the scope name in the loop to see if it makes a difference + prefix = NameUtils.FindCommonPrefix( + localNames.Select(x => x.TrimmingName).Append(scopeTrimmingName).ToList(), + // If naive mode is on and we're trimming type names, allow full matches (method class is probably the + // prefix) + naive && scope == "", + false, + naive + ); + } + + // Prevent certain strings from being part of the final prefix + foreach (var word in _forbiddenPrefixes) + { + // If the prefix starts with a forbidden prefix + if (prefix.StartsWith($"{word}_")) + { + // Clear the prefix + prefix = string.Empty; + } + + // If the prefix contains the forbidden trimming surrounded by underscores + var idx = prefix.IndexOf($"_{word}_", StringComparison.OrdinalIgnoreCase); + if (idx != -1) + { + // Trim the end of the prefix to the start of the forbidden prefix + // ex: + // input prefix = THIS_GL_ + // forbidden prefix = GL + // + // resulting prefix = THIS + prefix = prefix[..idx]; + } + } + + return (prefix, localNames); + } + + /// + /// Gets the name to feed into . + /// + /// The prefix overrides. + /// The name to get a trimming name for. + /// The global prefix hint. + /// The trimming name. + private string GetTrimmingName( + Dictionary prefixOverrides, + string name, + string? hint = null + ) + { + // If there's a prefix override for this enum, + if (prefixOverrides.ContainsKey(name)) + { + // Use the raw native name as the trimming name + return name; + } + + if (hint is not null && name.StartsWith(hint, StringComparison.OrdinalIgnoreCase)) + { + return NameSplitter.Underscore($"{hint}_{name[hint.Length..]}"); + } + + return NameSplitter.Underscore(name); + } + + /// The name as it exists in source code. + /// The original name with affixes stripped. + private readonly record struct MemberName(string OriginalName, string UnaffixedName); + + /// The name as it exists in source code. + /// The original name with affixes stripped. + /// The unaffixed name as a trimming name. See . + private readonly record struct TrimmingNames( + string OriginalName, + string UnaffixedName, + string TrimmingName + ) + { + public override string ToString() => + $"(Unaffixed={UnaffixedName}, Trimming={TrimmingName})"; + } + + private class Visitor : CSharpSyntaxWalker + { + /// + /// A mapping from scope names to their member names. + /// These only represent names that need to have their prefixes determined. + /// + public Dictionary> Scopes { get; } = new(); + + /// + /// A set of type names marked with the [Transformed] attribute. + /// + /// + /// These are not used for prefix determination since they can contain identifiers that + /// are not part of the original source code. + /// + public HashSet NonDeterminant { get; } = []; + + private BaseTypeDeclarationSyntax? _scope = null; + + private void ReportName( + SyntaxToken memberIdentifier, + SyntaxList memberAttributeLists + ) + { + var scopeName = _scope?.Identifier.ToString() ?? ""; + var memberName = memberIdentifier.ToString(); + + if (memberAttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) + { + NonDeterminant.Add(memberName); + } + + if (!Scopes.TryGetValue(scopeName, out var members)) + { + Scopes[scopeName] = members = []; + } + + var nameAffixes = memberAttributeLists.GetNameAffixes(); + var unaffixedMemberName = NameAffixer.StripAffixes(memberName, nameAffixes); + members.Add(new MemberName(memberName, unaffixedMemberName)); + } + + // ----- Types ----- + + public override void VisitClassDeclaration(ClassDeclarationSyntax node) + { + ReportName(node.Identifier, node.AttributeLists); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; + } + + public override void VisitStructDeclaration(StructDeclarationSyntax node) + { + ReportName(node.Identifier, node.AttributeLists); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; + } + + public override void VisitEnumDeclaration(EnumDeclarationSyntax node) + { + ReportName(node.Identifier, node.AttributeLists); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; + } + + public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node) => + ReportName(node.Identifier, node.AttributeLists); + + // ----- Members ----- + + public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node) => + ReportName(node.Identifier, node.AttributeLists); + + // Only supports single variable fields + public override void VisitFieldDeclaration(FieldDeclarationSyntax node) + { + // If the node is not a constant, skip it + // Otherwise, it's likely a C constant + if ( + !node.Modifiers.Any(SyntaxKind.ConstKeyword) + && !node.Modifiers.Any(SyntaxKind.StaticKeyword) + ) + { + return; + } + + var firstVariable = node.Declaration.Variables.First(); + ReportName(firstVariable.Identifier, node.AttributeLists); + } + + public override void VisitMethodDeclaration(MethodDeclarationSyntax node) + { + // Struct methods are introduced by the generator so we skip them + // Otherwise, it's likely a C function + if (_scope.IsKind(SyntaxKind.StructDeclaration)) + { + return; + } + + ReportName(node.Identifier, node.AttributeLists); + } + + public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) + { + // If the node is not a constant, skip it + // Otherwise, it's likely a C constant (often strings) + var hasSetter = + node.AccessorList?.Accessors.Any(a => + a.IsKind(SyntaxKind.SetAccessorDeclaration) + || a.IsKind(SyntaxKind.InitAccessorDeclaration) + ) ?? false; + + if (hasSetter) + { + return; + } + + ReportName(node.Identifier, node.AttributeLists); + } + } + + /// ScopeName -> (MemberName -> MemberPrefix) + private class Rewriter(Dictionary> results) + : CSharpSyntaxRewriter + { + private BaseTypeDeclarationSyntax? _scope = null; + + private SyntaxList RewriteAttributes( + SyntaxToken memberIdentifier, + SyntaxList memberAttributeLists + ) + { + var scopeName = _scope?.Identifier.ToString() ?? ""; + if (!results.TryGetValue(scopeName, out var scopePrefixes)) + { + return memberAttributeLists; + } + + if (!scopePrefixes.TryGetValue(memberIdentifier.ToString(), out var prefix)) + { + return memberAttributeLists; + } + + return memberAttributeLists.AddNameAffix( + NameAffixType.Prefix, + "SharedPrefix", + prefix, + true + ); + } + + // ----- Types ----- + + public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node) + { + node = node.WithAttributeLists(RewriteAttributes(node.Identifier, node.AttributeLists)); + + var previousScope = _scope; + _scope = node; + node = node.WithMembers( + [.. node.Members.Select(member => (MemberDeclarationSyntax)Visit(member))] + ); + _scope = previousScope; + + return node; + } + + public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node) + { + node = node.WithAttributeLists(RewriteAttributes(node.Identifier, node.AttributeLists)); + + var previousScope = _scope; + _scope = node; + node = node.WithMembers( + [.. node.Members.Select(member => (MemberDeclarationSyntax)Visit(member))] + ); + _scope = previousScope; + + return node; + } + + public override SyntaxNode VisitEnumDeclaration(EnumDeclarationSyntax node) + { + node = node.WithAttributeLists(RewriteAttributes(node.Identifier, node.AttributeLists)); + + var previousScope = _scope; + _scope = node; + node = node.WithMembers( + [.. node.Members.Select(member => (EnumMemberDeclarationSyntax)Visit(member))] + ); + _scope = previousScope; + + return node; + } + + public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node) => + node.WithAttributeLists(RewriteAttributes(node.Identifier, node.AttributeLists)); + + // ----- Members ----- + + public override SyntaxNode VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node) => + node.WithAttributeLists(RewriteAttributes(node.Identifier, node.AttributeLists)); + + // Only supports single variable fields + public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node) => + node.WithAttributeLists( + RewriteAttributes( + node.Declaration.Variables.First().Identifier, + node.AttributeLists + ) + ); + + public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node) => + node.WithAttributeLists(RewriteAttributes(node.Identifier, node.AttributeLists)); + + public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax node) => + node.WithAttributeLists(RewriteAttributes(node.Identifier, node.AttributeLists)); + } +} diff --git a/sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs b/sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs index e7bb381c84..98395e7517 100644 --- a/sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs +++ b/sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs @@ -1915,9 +1915,8 @@ private SyntaxList ProcessAndGetNewAttributes( MethodDeclarationSyntax? methodDeclaration = null ) { - // Get the name of the identifier, preferring the native one if available // This name will be modified by the code below as different suffixes are identified - var trimmedName = attributeLists.GetNativeNameOrDefault(identifier); + var trimmedName = identifier.ToString(); if (trimHandleSuffix) { diff --git a/sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs b/sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs index a803b7ab6b..5953fabade 100644 --- a/sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs +++ b/sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -12,36 +13,21 @@ namespace Silk.NET.SilkTouch.Mods; /// /// A mod that will convert other naming conventions to the PascalCase nomenclature typically used in C#. /// -/// The logger. -/// Configuration snapshot. -/// Name trimmer providers. +/// +/// Does not support nested types. Please use before this mod. +/// Note that despite this, some initial work has been done to add nested type support so that it can be added when necessary. +/// [ModConfiguration] public class PrettifyNames( ILogger logger, - IOptionsSnapshot config, - IEnumerable> trimmerProviders + IOptionsSnapshot config ) : IMod, IResponseFileMod { /// - /// The configuration for the prettify names mod. + /// The configuration for the mod. /// - public record Configuration // DON'T USE CONSTRUCTOR-STYLE RECORDS! Needs a default ctor. + public record Configuration { - /// - /// Corrections to the automatic prefix determination. - /// - public Dictionary PrefixOverrides { get; init; } = []; - - /// - /// Manually renamed native names. - /// - public Dictionary NameOverrides { get; init; } = []; - - /// - /// The base trimmer version. If null, trimming is disabled. - /// - public Version? TrimmerBaseline { get; init; } = new(3, 0); - /// /// The maximum length of an all capitals string to be treated as a single acronym, rather than as an all /// capitals word. @@ -53,9 +39,9 @@ IEnumerable> trimmerProviders public int LongAcronymThreshold { get; init; } = 2; /// - /// Multiple candidate name prefixes that may apply across all of the bindings generated. + /// Manually renamed native names. /// - public IReadOnlyList? GlobalPrefixHints { get; init; } + public Dictionary NameOverrides { get; init; } = []; /// /// The configuration for each category of name affixes. @@ -106,212 +92,53 @@ public record NameAffixConfiguration /// public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) { - // First pass to scan the sources and create a dictionary of type/member names. var cfg = config.Get(ctx.JobKey); - - // Sort the hints from large to small (longest prefix match) - var hints = cfg.GlobalPrefixHints?.ToList(); - hints?.Sort((x, y) => -x.Length.CompareTo(y.Length)); - cfg = cfg with { GlobalPrefixHints = hints }; - - var visitor = new Visitor(); if (ctx.SourceProject is null) { return; } + // Scan sources to gather names + var visitor = new NameDataVisitor(); foreach (var doc in ctx.SourceProject.Documents) { visitor.Visit(await doc.GetSyntaxRootAsync(ct)); } - // The dictionary containing mappings from the original type names to the new names of the type and its members - var newNames = new Dictionary(); - - var nameAffixer = new PrettifyNamesAffixer(visitor.AffixTypes, cfg.Affixes); - var namePrettifier = new NamePrettifier(cfg.LongAcronymThreshold); - - // Trim the trimmable names if the trimmer baseline is set - // Otherwise, we just prettify the trimmable names - if (cfg.TrimmerBaseline is null) - { - // Only prettify the trimmable names - foreach (var (name, (nonFunctions, functions)) in visitor.TrimmableTypes) - { - newNames[name] = new RenamedType( - ApplyPrettifyOnlyPipeline( - null, - name, - cfg.NameOverrides, - nameAffixer, - namePrettifier - ), - nonFunctions.ToDictionary( - x => x, - x => - ApplyPrettifyOnlyPipeline( - name, - x, - cfg.NameOverrides, - nameAffixer, - namePrettifier - ) - ), - functions.ToDictionary( - x => x.Name, - x => - ApplyPrettifyOnlyPipeline( - name, - x.Name, - cfg.NameOverrides, - nameAffixer, - namePrettifier - ) - ) - ); - } - } - else + // Process the names + var nameProcessorContext = new NameProcessorContext(visitor); { - // Trim and prettify the trimmable names - - // Get all the trimmers that are above this baseline. We also sort by the version. Why? Because someone - // couldn't be bothered to introduce a weight property. It is also unclear what effect this has on 2.17/2.18 - // but to be honest those trimmers aren't used and are only included for posterity and understanding of the - // old logic. - var trimmers = trimmerProviders - .SelectMany(x => x.Get(ctx.JobKey)) - .Append(new NameAffixerEarlyTrimmer(nameAffixer)) - .Append(new NameAffixerLateTrimmer(nameAffixer)) - .Append(new PrettifyNamesTrimmer(namePrettifier)) - .OrderBy(x => x.Order) - .ToArray(); - - // Create a type name dictionary to trim the type names. - var typeNames = visitor.TrimmableTypes.ToDictionary( - x => x.Key, - x => new CandidateNames(x.Key, []) - ); - - // If we don't have a prefix hint and don't have more than one type, we can't determine a prefix so don't - // trim. - if (typeNames.Count > 1 || cfg.GlobalPrefixHints is not null) - { - Trim( - new NameTrimmerContext - { - Container = null, - Names = typeNames, - Configuration = cfg, - JobKey = ctx.JobKey, - NonDeterminant = visitor.NonDeterminant, - }, - trimmers - ); - } + var namePrettifier = new NamePrettifier(cfg.LongAcronymThreshold); - // Now rename everything within each type. - foreach (var (typeName, (newTypeName, _)) in typeNames) + // Define name processors + var nameProcessors = new INameProcessor[] { - var (_, (consts, functions)) = visitor.TrimmableTypes.First(x => x.Key == typeName); - - // Rename the "constants" i.e. all the consts/static readonlys in this type. These are treated - // individually because everything that isn't a constant or a function is only prettified instead of prettified & trimmed. - var constNames = consts.ToDictionary(x => x, x => new CandidateNames(x, [])); - - // Trim the constants. - Trim( - new NameTrimmerContext - { - Container = typeName, - Names = constNames, - Configuration = cfg, - JobKey = ctx.JobKey, - NonDeterminant = visitor.NonDeterminant, - }, - trimmers - ); - - // Rename the functions. More often that not functions have different nomenclature to constants, so we - // treat them separately. - var functionNames = functions - .DistinctBy(x => x.Name) - .ToDictionary(x => x.Name, x => new CandidateNames(x.Name, [])); - - // Collect the syntax as this is used for conflict resolution in the Trim function. - var functionSyntax = functionNames.Keys.ToDictionary( - x => x, - x => functions.Where(y => y.Name == x).Select(y => y.Syntax) - ); - - // Trim the functions. - Trim( - new NameTrimmerContext - { - Container = typeName, - Names = functionNames, - Configuration = cfg, - JobKey = ctx.JobKey, - NonDeterminant = visitor.NonDeterminant, - }, - trimmers, - functionSyntax - ); - - // Add it to the rewriter's list of names to... rewrite... - newNames[typeName] = new RenamedType( - newTypeName, - constNames.ToDictionary(x => x.Key, x => x.Value.Primary), - functionNames.ToDictionary(x => x.Key, x => x.Value.Primary) - ); - } - } - - // Prettify the prettify only names - foreach (var (typeName, memberNames) in visitor.PrettifyOnlyTypes) - { - if (!newNames.TryGetValue(typeName, out var renamedType)) - { - renamedType = new RenamedType( - ApplyPrettifyOnlyPipeline( - null, - typeName, - cfg.NameOverrides, - nameAffixer, - namePrettifier - ), - [], - [] - ); - } + new HandleOverridesProcessor(cfg.NameOverrides), + new StripAffixesProcessor(visitor), + new PrettifyProcessor(namePrettifier), + new ReapplyAffixesProcessor(visitor, cfg.Affixes), + new PrefixIfStartsWithNumberProcessor(), + new ResolveConflictsProcessor(visitor, logger), + new OutputFinalNamesProcessor(), + new RemoveUnmodifiedFinalNamesProcessor(), + }; - foreach (var memberName in memberNames) + foreach (var nameProcessor in nameProcessors) { - renamedType.NonFunctions[memberName] = ApplyPrettifyOnlyPipeline( - typeName, - memberName, - cfg.NameOverrides, - nameAffixer, - namePrettifier - ); + nameProcessor.ProcessNames(nameProcessorContext); } - - newNames[typeName] = renamedType; } + var newNames = nameProcessorContext.FinalNames; if (logger.IsEnabled(LogLevel.Debug)) { - foreach (var (name, (newName, nonFunctions, functions)) in newNames) + logger.LogDebug("Prettified names by scope:"); + foreach (var (scope, members) in newNames) { - logger.LogDebug("{} = {}", name, newName); - foreach (var (old, @new) in nonFunctions) - { - logger.LogDebug("{}.{} = {}.{}", name, old, newName, @new); - } - - foreach (var (old, @new) in functions) + logger.LogDebug("Scope: {}", scope); + foreach (var (oldMemberName, newMemberName) in members) { - logger.LogDebug("{}.{} = {}.{}", name, old, newName, @new); + logger.LogDebug(" {} = {}", oldMemberName, newMemberName); } } } @@ -341,53 +168,16 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) logger.LogDebug("Discovering references to symbols to rename for {}...", ctx.JobKey); ctx.SourceProject = proj; - var comp = + var compilation = await proj.GetCompilationAsync(ct) ?? throw new InvalidOperationException( "Failed to obtain compilation for source project!" ); - await NameUtils.RenameAllAsync( - ctx, - newNames.SelectMany(x => - { - var nonFunctionConflicts = x - .Value.NonFunctions.Values.Where(y => x.Value.Functions.ContainsValue(y)) - .ToHashSet(); - return comp.GetSymbolsWithName(x.Key, SymbolFilter.Type, ct) - .OfType() - .SelectMany(y => - [ - .. Enumerable.SelectMany( - [ - .. x.Value.NonFunctions.Select(z => - nonFunctionConflicts.Contains(z.Value) - ? new KeyValuePair( - z.Key, - $"{z.Value}Value" - ) - : z - ), - .. x.Value.Functions, - ], - z => - { - return y.GetMembers(z.Key).Select(w => (w, z.Value)); - } - ), - .. y.GetMembers() - .OfType() - .Where(z => - z.MethodKind is MethodKind.Constructor or MethodKind.Destructor - ) - .Select(z => (z, x.Value.NewName)), - (y, x.Value.NewName), - ] - ); - }), - logger, - ct - ); + // Gather symbols and rename + var symbolVisitor = new NameSymbolVisitor(newNames); + symbolVisitor.Visit(compilation.Assembly); + await NameUtils.RenameAllAsync(ctx, symbolVisitor.ToRename, logger, ct); logger.LogDebug( "Reference renaming took {} seconds for {}.", @@ -397,16 +187,21 @@ z.MethodKind is MethodKind.Constructor or MethodKind.Destructor // Change the filenames where appropriate. proj = ctx.SourceProject; + var typeNames = newNames.GetValueOrDefault("", []); + var typeNamesLongestFirst = typeNames.OrderByDescending(x => x.Key.Length).ToArray(); + foreach (var docId in proj.DocumentIds) { var doc = proj.GetDocument(docId); - if ( - doc is not { FilePath: not null } - || newNames - .OrderByDescending(x => x.Key.Length) - .FirstOrDefault(x => doc.FilePath.Contains(x.Key) || doc.Name.Contains(x.Key)) - is not { Key: { } oldName, Value.NewName: { } newName } - ) + if (doc?.FilePath == null) + { + continue; + } + + var firstMatch = typeNamesLongestFirst.FirstOrDefault(x => + doc.FilePath.Contains(x.Key) || doc.Name.Contains(x.Key) + ); + if (firstMatch is not { Key: { } oldName, Value: { } newName }) { continue; } @@ -453,853 +248,554 @@ z.MethodKind is MethodKind.Constructor or MethodKind.Destructor ctx.SourceProject = proj; } - /// - /// Applies the prettify only pipeline. - /// This currently consists of checking for name overrides first. - /// Then if no override is found, then the name's affixes are removed, - /// the name is prettified, and the name's affixes are added back. - /// - private string ApplyPrettifyOnlyPipeline( - string? container, - string name, - Dictionary nameOverrides, - PrettifyNamesAffixer nameAffixer, - NamePrettifier namePrettifier - ) + /// + public Task> BeforeScrapeAsync(string key, List rsps) { - // Check for overrides - foreach (var (nativeName, overriddenName) in nameOverrides) + foreach (var responseFile in rsps) { - if (nativeName.Contains('.')) + if (!responseFile.GeneratorConfiguration.DontUseUsingStaticsForEnums) { - // We're processing a type dictionary, so don't add a member thing. - if (container is null) - { - continue; - } - - // Check whether the override is for this type. - var span = nativeName.AsSpan(); - var containerSpan = span[..span.IndexOf('.')]; - if ( - !containerSpan.Equals("*", StringComparison.Ordinal) - && !containerSpan.Equals(container, StringComparison.Ordinal) - ) - { - continue; - } - - var nameToAdd = span[(span.IndexOf('.') + 1)..].ToString(); - if (nameToAdd == name) - { - return overriddenName; - } + logger.LogWarning( + "{} (for {}) should use exclude-using-statics-for-enums as PrettifyNames does not resolve " + + "conflicts with members of other types.", + responseFile.FilePath, + key + ); } - else if (nativeName == name) + if (!responseFile.GeneratorConfiguration.DontUseUsingStaticsForGuidMember) { - return overriddenName; + logger.LogWarning( + "{} (for {}) should use exclude-using-statics-for-guid-members as PrettifyNames does not resolve " + + "conflicts with members of other types.", + responseFile.FilePath, + key + ); } } - // Be lenient about caps for type names (e.g. GL) - var allowAllCaps = container == null; - - var result = name; - result = nameAffixer.RemoveAffixes(result, container, name, null); - result = namePrettifier.Prettify(result, allowAllCaps); - result = nameAffixer.ApplyAffixes(result, container, name, null); - - return result; + return Task.FromResult(rsps); } - private void Trim( - NameTrimmerContext context, - IEnumerable trimmers, - Dictionary>? functionSyntax = null - ) + /// + /// Stores additional data for each scope member. + /// + /// The affixes declared for the name. + /// The declaration syntaxes for the member. + private record struct MemberData( + NameAffix[] Affixes, + List Declarations + ); + + private class NameDataVisitor : CSharpSyntaxWalker { - // Ensure the trimmers don't see names that have been manually overridden, as we don't want them to influence - // automatic prefix determination for example - var namesToTrim = context.Names; - foreach (var (nativeName, overriddenName) in context.Configuration.NameOverrides) - { - var nameToAdd = nativeName; - if (nativeName.Contains('.')) - { - // We're processing a type dictionary, so don't add a member thing. - if (context.Container is null) - { - continue; - } + /// + /// Represents a mapping: ScopeName -> (MemberName -> MemberData). + /// This data is used by name processors to transform and prettify the names. + /// + public Dictionary> Scopes { get; } = []; - // Check whether the override is for this type. - var span = nativeName.AsSpan(); - var containerSpan = span[..span.IndexOf('.')]; - if ( - containerSpan.Equals("*", StringComparison.Ordinal) - || containerSpan.Equals(context.Container, StringComparison.Ordinal) - ) - { - nameToAdd = span[(span.IndexOf('.') + 1)..].ToString(); - } - else - { - continue; - } - } + private BaseTypeDeclarationSyntax? _scope; + + private void ReportName( + SyntaxToken memberIdentifier, + SyntaxList memberAttributeLists, + MemberDeclarationSyntax memberDeclaration + ) + { + var scopeName = _scope?.Identifier.ToString() ?? ""; + var memberName = memberIdentifier.ToString(); + var affixes = memberAttributeLists.GetNameAffixes(); - if (!namesToTrim.TryGetValue(nameToAdd, out var v)) + if (!Scopes.TryGetValue(scopeName, out var members)) { - continue; + Scopes[scopeName] = members = []; } - // If we haven't created the differentiated dictionary yet, then do so now. We do want to keep the original - // dictionary so we can actually apply the renames; if we have created two different branching dictionaries - // they are recombined following trimming. - if (namesToTrim == context.Names) + if (!members.TryGetValue(memberName, out var memberData)) { - namesToTrim = namesToTrim.ToDictionary(); + // Note that we only store affix data for the first encountered version of the name + // This is fine because if two members have the same name, they should have the same affixes + memberData = new MemberData(affixes, []); } - // Don't let the trimmers see the overridden native name. - namesToTrim.Remove(nameToAdd); - - // Apply the name override to the dictionary we actually use. - context.Names[nameToAdd] = new CandidateNames( - overriddenName, - [.. v.Secondary, nameToAdd] - ); + memberData.Declarations.Add(memberDeclaration); + members[memberName] = memberData; } - // Run each trimmer - foreach (var trimmer in trimmers) + // ----- Types ----- + + public override void VisitClassDeclaration(ClassDeclarationSyntax node) { - trimmer.Trim(context with { Names = namesToTrim }); + ReportName(node.Identifier, node.AttributeLists, node); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; } - // Apply changes - if (namesToTrim != context.Names) + public override void VisitStructDeclaration(StructDeclarationSyntax node) { - foreach (var (evalName, result) in namesToTrim) + ReportName(node.Identifier, node.AttributeLists, node); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) { - context.Names[evalName] = result; + Visit(member); } + _scope = previousScope; } - // Prefer shorter names - foreach (var (_, (_, secondary)) in context.Names) + public override void VisitEnumDeclaration(EnumDeclarationSyntax node) { - secondary.Sort((a, b) => -a.Length.CompareTo(b.Length)); + ReportName(node.Identifier, node.AttributeLists, node); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; } - // Create a map from primaries to trimming names, to account for multiple overloads with the same primary and - // same trimming name (i.e. it is a generated/transformed overload) but differing discriminators. - var primaries = new Dictionary>(); - foreach (var (trimmingName, (primary, _)) in context.Names) + public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node) => + ReportName(node.Identifier, node.AttributeLists, node); + + // ----- Members ----- + + public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node) => + ReportName(node.Identifier, node.AttributeLists, node); + + public override void VisitFieldDeclaration(FieldDeclarationSyntax node) { - var trimmingNamesForPrimary = primaries.TryGetValue(primary, out var tnfp) - ? tnfp - : primaries[primary] = []; - trimmingNamesForPrimary.Add(trimmingName); + var firstVariable = node.Declaration.Variables.First(); + ReportName(firstVariable.Identifier, node.AttributeLists, node); } - // Unwind some names back to their secondary names if the primaries would duplicate - // We'll use a hash set to determine whether or not we need to check a primary for conflicts. - var namesToEval = primaries.Keys.ToHashSet(); - - // Keep track of the method discriminators to determine whether we have incompatible overloads that need to be - // renamed. We keep track of the first trimming name so that we can add it to conflictingTrimmingNames when we - // do discover a conflict (along with the trimming name of the actual conflict). - var methDiscrims = - new Dictionary< - string, - (string? FirstTrimmingName, List Methods) - >(); - var conflictingTrimmingNames = new HashSet(); - while (namesToEval.GetEnumerator() is var e && e.MoveNext() && e.Current is var primary) + public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) => + ReportName(node.Identifier, node.AttributeLists, node); + + public override void VisitMethodDeclaration(MethodDeclarationSyntax node) => + ReportName(node.Identifier, node.AttributeLists, node); + } + + /// + /// Discovers and stores symbol to new name mappings to be used by . + /// + /// The new names in the format defined by . + private class NameSymbolVisitor(Dictionary> newNames) + : SymbolVisitor + { + public readonly List<(ISymbol Symbol, string NewName)> ToRename = []; + + private INamedTypeSymbol? _scope; + + private void ReportSymbol(ISymbol symbol) { - // ^-- We can't use a foreach loop because we're mutating below. We're also using GetEnumerator instead of - // First to avoid allocations. - - // First, let's check whether we have any conflicting discriminators. If we don't, we can mark this as all - // good right away. - methDiscrims.Clear(); - conflictingTrimmingNames.Clear(); - var trimmingNamesForOldPrimary = primaries[primary]; - - // Function-specific logic where some conflicts are okay, so we have to evaluate each signature to see if - // we can discriminate each one such that there are no conflicts. - // - // An example of where this is the case is e.g. alGetBufferf/alGetBufferfv - signatures are identical. - var nMethConflicts = 0; - var nMethods = 0; - var nNoSecondaries = 0; // <-- at least all but one needs to have a secondary to resolve conflicts - string? noSecondaryTrimmingName = null; - foreach (var trimmingNameToEval in trimmingNamesForOldPrimary) - { - // Do we even have a secondary to fall back on if there is a conflict? - if (context.Names[trimmingNameToEval].Secondary.Count == 0) - { - noSecondaryTrimmingName ??= trimmingNameToEval; - nNoSecondaries++; - } + var scopeName = _scope?.Name ?? ""; + var memberName = symbol.Name; - if (functionSyntax is not null) - { - foreach (var meth in functionSyntax[trimmingNameToEval]) - { - var discrim = ModUtils.DiscrimStr( - meth.Modifiers, - meth.TypeParameterList, - primary, - meth.ParameterList, - returnType: null - ); - var (ogTrimmingName, discrimMatches) = methDiscrims.TryGetValue( - discrim, - out var dte - ) - ? dte - : methDiscrims[discrim] = (trimmingNameToEval, []); - discrimMatches.Add(meth); - nMethods++; - - // NOTE: The number of conflicts influences how we go about conflict resolution. See the - // logic below all of these loops just in case this comment is out of date, but at time of - // writing if 50% or more of the methods with this primary name are conflicting then we - // rename all of them, otherwise we rename only the conflicting overloads. - nMethConflicts += discrimMatches.Count switch - { - 2 => 2, // The original needs to be counted as a conflict in addition to this conflict - > 2 => 1, // Just mark this conflict, original is already counted. - _ => 0, // No conflict to see here (not yet anyway, call it Schrodinger's Conflict) - }; + if ( + symbol is IMethodSymbol methodSymbol + && methodSymbol.MethodKind is MethodKind.Constructor or MethodKind.Destructor + ) + { + // Constructors/destructors use the name of their containing types + memberName = scopeName; + scopeName = ""; + } - if (discrimMatches.Count == 2 && ogTrimmingName is not null) - { - conflictingTrimmingNames.Add(ogTrimmingName); - } + if (!newNames.TryGetValue(scopeName, out var memberNewNames)) + { + return; + } - if (discrimMatches.Count > 1) - { - conflictingTrimmingNames.Add(trimmingNameToEval); - } - } - } + if (!memberNewNames.TryGetValue(memberName, out var memberNewName)) + { + return; } - // If we're checking methods for conflicts and in our travels we've discovered that there are in fact - // no conflicts, we can bail out early here. - if (nMethods > 0 && (methDiscrims.Count == 0 || nMethConflicts == 0)) + ToRename.Add((symbol, memberNewName)); + } + + // ----- Entry ----- + + public override void VisitAssembly(IAssemblySymbol symbol) => Visit(symbol.GlobalNamespace); + + public override void VisitNamespace(INamespaceSymbol symbol) + { + foreach (var member in symbol.GetMembers()) { - namesToEval.Remove(primary); - continue; + Visit(member); } + } + + // ----- Types ----- + + public override void VisitNamedType(INamedTypeSymbol symbol) + { + ReportSymbol(symbol); - // We need to determine if we even have alternative names. If one doesn't that's fine because as long - // as we unwind all the others that one still won't conflict. - if (nNoSecondaries > 1) + var previousScope = _scope; + _scope = symbol; + foreach (var member in symbol.GetMembers()) { - logger.LogError( - "Couldn't resolve conflict for \"{}\" because {} of the APIs with that primary name did not have any secondary names.", - primary, - nNoSecondaries - ); - namesToEval.Remove(primary); - continue; + Visit(member); } + _scope = previousScope; + } - var renameOnlyConflicts = nMethConflicts <= nMethods / 2.0; - - // We can afford to leave one API alone. If that place isn't already filled by a method without a secondary - // name then we should fill it with whatever has the shortest trimming name. The logic being that the more - // characters (i.e. longer suffix) a name has, the more discriminatory/important that name is ergo the - // reverse (the shorter the name, the less discriminatory/important it is) is also true. - string? first = null; - var primaryClaimed = noSecondaryTrimmingName is not null; - namesToEval.Remove(primary); // <-- just in case the below loop somehow produces the same primary again. - foreach ( - var conflictingTrimmingName in ( - renameOnlyConflicts ? conflictingTrimmingNames : primaries[primary] - ).OrderBy(x => x.Length) - ) + // ----- Members ----- + + public override void VisitField(IFieldSymbol symbol) => ReportSymbol(symbol); + + public override void VisitProperty(IPropertySymbol symbol) => ReportSymbol(symbol); + + public override void VisitMethod(IMethodSymbol symbol) => ReportSymbol(symbol); + } + + private class RenameSafeAttributeListsRewriter : CSharpSyntaxRewriter + { + public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node) => + ( + (MethodDeclarationSyntax)base.VisitMethodDeclaration(node)! + ).WithRenameSafeAttributeLists(); + } + + /// + /// Applies name overrides and moves overridden names to the final set of names. + /// Overridden names are removed from the working set to prevent later processors from directly seeing them. + /// + private class HandleOverridesProcessor(Dictionary nameOverrides) + : INameProcessor + { + public void ProcessNames(NameProcessorContext context) + { + var overriddenNames = new List<(string Scope, string Member, string OverriddenName)>(); + foreach (var (overrideTargetName, overriddenName) in nameOverrides) { - // Do not rename if this is the trimming name that does not have a secondary. - if (noSecondaryTrimmingName == conflictingTrimmingName) + // Target format can either be "Member" or "Scope.Member" + // Split into the two parts here + var overrideTargetScopeEnd = overrideTargetName.IndexOf('.'); + var overrideTargetScope = + overrideTargetScopeEnd >= 0 + ? overrideTargetName[..overrideTargetScopeEnd] + : null; + var overrideTargetMember = overrideTargetName[(overrideTargetScopeEnd + 1)..]; + + // Wildcard scope is the same as not specifying a scope + if ( + overrideTargetScope != null + && overrideTargetScope.Equals("*", StringComparison.Ordinal) + ) { - continue; + overrideTargetScope = null; } - // If the current primary hasn't been "claimed" by a trimming name without a secondary, we only want - // to let the shortest name claim it (per the logic described in the last comment) if it is actually - // the absolute shortest name and not joint-1st for that title. Therefore, the first trimming name - // is saved for the second iteration where we'll make that judgement call and handle both at the - // same time. - if (first is null) + if (overrideTargetScope == null) { - first = conflictingTrimmingName; - if (!primaryClaimed) + // Apply unscoped override + foreach (var (scope, members) in context.Scopes) { - continue; + if (members.ContainsKey(overrideTargetMember)) + { + overriddenNames.Add((scope, overrideTargetMember, overriddenName)); + } } } - - // Now we're going to make the above judgement call. If the first item has the same length as the - // second item, the first item has no right to claim the primary name therefore both items will be - // demoted to use their secondary name. - if (!primaryClaimed) + else { - if (first.Length == conflictingTrimmingName.Length) + // Apply scoped override + if ( + context.Scopes.TryGetValue(overrideTargetScope, out var members) + && members.ContainsKey(overrideTargetMember) + ) { - // Update the output name. - var firstSecondary = - context.Names[first].Secondary - ?? throw new InvalidOperationException( - "More than one trimming name without secondary names." - ); - var firstNextPrimary = firstSecondary[^1]; - firstSecondary.RemoveAt(firstSecondary.Count - 1); - context.Names[first] = new CandidateNames(firstNextPrimary, firstSecondary); - - // Update our primary to trimming name map - var trimmingNamesForFirst = primaries.TryGetValue( - firstNextPrimary, - out var tnff - ) - ? tnff - : primaries[firstNextPrimary] = []; - trimmingNamesForFirst.Add(first); - trimmingNamesForOldPrimary.Remove(first); - if (trimmingNamesForOldPrimary.Count == 0) - { - primaries.Remove(primary); - } - - // Make sure we do a pass over the new primary just in case we already have APIs with that - // primary - namesToEval.Add(firstNextPrimary); - if (logger.IsEnabled(LogLevel.Trace)) // <-- prevent needless string.Join - { - logger.LogTrace( - "{}: {} -> {} (remaining secondaries: {})", - first, - primary, - firstNextPrimary, - string.Join(", ", firstNextPrimary) - ); - } + overriddenNames.Add( + (overrideTargetScope, overrideTargetMember, overriddenName) + ); } - - primaryClaimed = true; } + } - // Conflict resolution! Update the output name. - var secondary = - context.Names[conflictingTrimmingName].Secondary - ?? throw new InvalidOperationException( - "More than one trimming name without secondary names." - ); - var nextPrimary = secondary[^1]; - secondary.RemoveAt(secondary.Count - 1); - context.Names[conflictingTrimmingName] = new CandidateNames(nextPrimary, secondary); - - // Update our primary to trimming name map - var trimmingNamesForNewPrimary = primaries.TryGetValue(nextPrimary, out var tnfp) - ? tnfp - : primaries[nextPrimary] = []; - trimmingNamesForNewPrimary.Add(conflictingTrimmingName); - trimmingNamesForOldPrimary.Remove(conflictingTrimmingName); - if (trimmingNamesForOldPrimary.Count == 0) - { - primaries.Remove(primary); - } + // Move overridden names to final output + foreach (var overriddenName in overriddenNames) + { + // Remove from working set + // This is to prevent later processors from modifying overrides + context.Scopes[overriddenName.Scope].Remove(overriddenName.Member); - // Make sure we do a pass over the new primary just in case we already have APIs with that primary - namesToEval.Add(nextPrimary); - if (logger.IsEnabled(LogLevel.Trace)) // <-- prevent needless string.Join + // Add to final names + if (!context.FinalNames.TryGetValue(overriddenName.Scope, out var members)) { - logger.LogTrace( - "{}: {} -> {} (remaining secondaries: {})", - conflictingTrimmingName, - primary, - nextPrimary, - string.Join(", ", secondary) - ); + context.FinalNames[overriddenName.Scope] = members = []; } + + members[overriddenName.Member] = overriddenName.OverriddenName; } } } - /// - public Task> BeforeScrapeAsync(string key, List rsps) + /// + /// Removes identified affixes so that other name processors can process the base name separately. + /// These affixes should be reapplied by . + /// + private class StripAffixesProcessor(NameDataVisitor nameData) : INameProcessor { - foreach (var responseFile in rsps) + public void ProcessNames(NameProcessorContext context) { - if (!responseFile.GeneratorConfiguration.DontUseUsingStaticsForEnums) + foreach (var (scope, members) in context.Scopes) { - logger.LogWarning( - "{} (for {}) should use exclude-using-statics-for-enums as PrettifyNames does not resolve " - + "conflicts with members of other types.", - responseFile.FilePath, - key - ); - } - if (!responseFile.GeneratorConfiguration.DontUseUsingStaticsForGuidMember) - { - logger.LogWarning( - "{} (for {}) should use exclude-using-statics-for-guid-members as PrettifyNames does not resolve " - + "conflicts with members of other types.", - responseFile.FilePath, - key - ); - } - } - - return Task.FromResult(rsps); - } - - /// - /// Contains the new name of a type and mappings between original names and new names of its members. - /// - /// The new name of the type. - /// The mappings from original names to new names of the type's non-function members. - /// The mappings from original names to new names of the type's function members. - private record struct RenamedType( - string NewName, - Dictionary NonFunctions, - Dictionary Functions - ); - - private record struct TypeData(List NonFunctions, List Functions); - - private record struct FunctionData(string Name, MethodDeclarationSyntax Syntax); - - private record struct TypeAffixData( - NameAffix[] TypeAffixes, - Dictionary? MemberAffixes - ); - - private class Visitor : CSharpSyntaxWalker - { - /// - /// A mapping from type names to their member names (along with some additional info). - /// These names are first trimmed, then prettified. - /// - public Dictionary TrimmableTypes { get; } = new(); - - /// - /// A mapping from type names to their member names. - /// These names do not participate in trimming and are only prettified. - /// - public Dictionary> PrettifyOnlyTypes { get; } = new(); - - /// - /// A mapping from type names to the type's affix data, which contains mappings from member names to each member's affix data. - /// This is used at the start of trimming to remove declared affixes and at the end to restore declared affixes. - /// Declared affixes are defined by the [NamePrefix] and [NameSuffix] attributes and don't contribute towards the usual trimming processes. - /// - public Dictionary AffixTypes { get; } = new(); - - /// - /// A set of type names marked with the [Transformed] attribute. - /// - /// - /// These are not used for prefix determination since they can contain identifiers that - /// are not part of the original source code. - /// - public HashSet NonDeterminant { get; } = new(); - - /// - /// Tracks the type that we currently are visiting. - /// - private TypeInProgress? _typeInProgress; - - /// - /// Tracks the enum that we currently are visiting. - /// - private EnumInProgress? _enumInProgress; - - /// - /// While this is called a "type" in progress, this represents either a class or a struct. - /// - /// The class or struct's declaration syntax node. - /// The names of the non-function members directly contained by the type. - /// The names of the function members directly contained by the type. - private record struct TypeInProgress( - TypeDeclarationSyntax Type, - List NonFunctions, - List Functions - ); - - /// - /// Represents an enum. - /// - /// The enum's declaration syntax node. - /// The names of the members directly contained by the enum. - private record struct EnumInProgress(EnumDeclarationSyntax Enum, List EnumMembers); + if (!nameData.Scopes.TryGetValue(scope, out var scopeData)) + { + continue; + } - /// - /// Returns whether we are currently inside of a type. - /// - /// - /// Note that we currently do not handle nested types. - /// If we encounter a type while we are already in a type, we ignore that type. - /// If we encounter a non-type (i.e., a type member), we add the member to the type we are already in. - /// - private bool IsCurrentlyInType(SyntaxNode node) => - _typeInProgress is not null - || _enumInProgress is not null - || node.Ancestors().OfType().Any(); - - private void ReportTypeAffixData( - string typeIdentifier, - SyntaxList attributeLists - ) - { - var affixes = attributeLists.GetNameAffixes(); - if (affixes.Length == 0) - { - return; - } + foreach (var (original, (primary, secondary)) in members) + { + if (!scopeData.TryGetValue(original, out var memberData)) + { + continue; + } - if (!AffixTypes.TryGetValue(typeIdentifier, out var typeAffixData)) - { - typeAffixData = new TypeAffixData([], null); + var newPrimary = RemoveAffixes(primary, secondary, memberData.Affixes); + members[original] = new CandidateNames(newPrimary, secondary); + } } - - AffixTypes[typeIdentifier] = typeAffixData with - { - TypeAffixes = [.. typeAffixData.TypeAffixes, .. affixes], - }; } - private void ReportMemberAffixData( - string typeIdentifier, - string memberIdentifier, - SyntaxList attributeLists - ) + /// + /// Removes affixes from the specified primary name and adds the original specified primary to the secondary list. + /// + /// The current primary name. + /// The current secondary names. + /// The affixes declared for the original name. + /// The new primary name. + private string RemoveAffixes(string primary, List secondary, NameAffix[] affixes) { - var affixes = attributeLists.GetNameAffixes(); if (affixes.Length == 0) { - return; + return primary; } - if (!AffixTypes.TryGetValue(typeIdentifier, out var typeAffixData)) + var stripped = NameAffixer.StripAffixes(primary, affixes); + if (stripped != primary) { - typeAffixData = new TypeAffixData([], null); + secondary.Add(primary); } - // Note that TryAdd will lead to affixes for later members being silently dropped. - // This is to handle methods which have the same name and affixes. It is fine to drop the affixes in this case. - (typeAffixData.MemberAffixes ??= []).TryAdd(memberIdentifier, affixes); - AffixTypes[typeIdentifier] = typeAffixData; + return stripped; } + } - // ----- Types ----- - - public override void VisitClassDeclaration(ClassDeclarationSyntax node) + /// + /// Prettifies the primary and secondary candidate names. + /// Also see . + /// + private class PrettifyProcessor(NamePrettifier namePrettifier) : INameProcessor + { + public void ProcessNames(NameProcessorContext context) { - if (IsCurrentlyInType(node)) - { - return; - } - - var identifier = node.Identifier.ToString(); - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) + foreach (var (scope, members) in context.Scopes) { - NonDeterminant.Add(identifier); - } - - ReportTypeAffixData(identifier, node.AttributeLists); + // Be lenient about caps for type names (e.g. GL) + var allowAllCaps = scope == ""; - // Recurse into members. - _typeInProgress = new TypeInProgress(node, [], []); - base.VisitClassDeclaration(node); + foreach (var (original, (primary, secondary)) in members) + { + for (var i = 0; i < secondary.Count; i++) + { + secondary[i] = namePrettifier.Prettify(secondary[i], allowAllCaps); + } - // Merge with existing data in case of partials - if (!TrimmableTypes.TryGetValue(identifier, out var typeData)) - { - typeData = new TypeData([], []); - TrimmableTypes.Add(identifier, typeData); + members[original] = new CandidateNames( + namePrettifier.Prettify(primary, allowAllCaps), + secondary + ); + } } - - typeData.NonFunctions.AddRange( - _typeInProgress.Value.NonFunctions.Where(nonFunction => - !typeData.NonFunctions.Contains(nonFunction) - ) - ); - typeData.Functions.AddRange(_typeInProgress.Value.Functions); - - _typeInProgress = null; } + } - public override void VisitStructDeclaration(StructDeclarationSyntax node) - { - if (IsCurrentlyInType(node)) - { - return; - } - - var identifier = node.Identifier.ToString(); - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) - { - NonDeterminant.Add(identifier); - } - - ReportTypeAffixData(identifier, node.AttributeLists); - - // Recurse into members - _typeInProgress = new TypeInProgress(node, [], []); - base.VisitStructDeclaration(node); - - // Merge with existing data in case of partials - if (!TrimmableTypes.TryGetValue(identifier, out var typeData)) - { - typeData = new TypeData([], []); - TrimmableTypes.Add(identifier, typeData); - } - - typeData.NonFunctions.AddRange( - _typeInProgress.Value.NonFunctions.Where(nonFunction => - !typeData.NonFunctions.Contains(nonFunction) - ) - ); - typeData.Functions.AddRange(_typeInProgress.Value.Functions); + /// + /// Reapplies and transforms identified affixes based on . + /// + private class ReapplyAffixesProcessor( + NameDataVisitor nameData, + Dictionary config + ) : INameProcessor + { + private readonly record struct MemberKey(string Scope, string Member); - _typeInProgress = null; - } + private static readonly NameAffixConfiguration _defaultConfig = new(); - public override void VisitEnumDeclaration(EnumDeclarationSyntax node) + public void ProcessNames(NameProcessorContext context) { - if (IsCurrentlyInType(node)) - { - return; - } - - var identifier = node.Identifier.ToString(); - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) - { - NonDeterminant.Add(identifier); - } + // Calculate processing order using topological sort + // Name affixes can reference other names + // We want names that don't reference other names to be processed first + var processingOrderByKey = new List(); - ReportTypeAffixData(identifier, node.AttributeLists); + var ready = new Queue(); + var dependencyCountByKey = new Dictionary(); + var notifyDependantByKey = new Dictionary>(); - // Recurse into members - _enumInProgress = new EnumInProgress(node, []); - base.VisitEnumDeclaration(node); - - // Merge with existing data in case of partials - if (!TrimmableTypes.TryGetValue(identifier, out var typeData)) + foreach (var (scope, members) in context.Scopes) { - typeData = new TypeData([], []); - TrimmableTypes.Add(identifier, typeData); - } - - typeData.NonFunctions.AddRange(_enumInProgress.Value.EnumMembers); - _enumInProgress = null; - } - - public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node) - { - var identifier = node.Identifier.ToString(); - if (IsCurrentlyInType(node)) - { - if (node.Parent == _typeInProgress?.Type) + if (!nameData.Scopes.TryGetValue(scope, out var scopeData)) { - _typeInProgress!.Value.NonFunctions.Add(identifier); + continue; } - return; - } - - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) - { - NonDeterminant.Add(identifier); - } - - ReportTypeAffixData(identifier, node.AttributeLists); - TrimmableTypes.Add(identifier, new TypeData([], [])); - } - - // ----- Members ----- - - public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node) - { - if (node.Parent == _enumInProgress?.Enum) - { - var typeIdentifier = _enumInProgress!.Value.Enum.Identifier.ToString(); - var memberIdentifier = node.Identifier.ToString(); - ReportMemberAffixData(typeIdentifier, memberIdentifier, node.AttributeLists); - - _enumInProgress!.Value.EnumMembers.Add(memberIdentifier); - } - } - - public override void VisitFieldDeclaration(FieldDeclarationSyntax node) - { - // If it's not a constant then we only prettify - // C constants are globally scoped and typically prefixed, so we trim in addition to prettifying - var prettifyOnly = - !node.Modifiers.Any(SyntaxKind.ConstKeyword) - && !node.Modifiers.Any(SyntaxKind.StaticKeyword); - - if (node.Parent == _typeInProgress?.Type) - { - var typeIdentifier = _typeInProgress!.Value.Type.Identifier.ToString(); - foreach (var variable in node.Declaration.Variables) + // Build dependency graph + foreach (var (member, _) in members) { - var memberIdentifier = variable.Identifier.ToString(); - ReportMemberAffixData(typeIdentifier, memberIdentifier, node.AttributeLists); + if (!scopeData.TryGetValue(member, out var memberData)) + { + continue; + } - if (prettifyOnly) + var dependencyCount = 0; + var affixes = memberData.Affixes; + foreach (var affix in affixes) { - if (!PrettifyOnlyTypes.TryGetValue(typeIdentifier, out var typeData)) + if (!affix.IsReference) { - typeData = []; - PrettifyOnlyTypes.Add(typeIdentifier, typeData); + continue; } - typeData.Add(memberIdentifier); - } - else - { - _typeInProgress.Value.NonFunctions.Add(memberIdentifier); - } - } - } - } + var referencedMemberOriginalName = affix.Affix; + if ( + TryResolveName( + context, + scope, + referencedMemberOriginalName, + out var referencedMemberScope, + out _, + out var isInFinalSet + ) + ) + { + // Add as dependency only if not in final set + // This is because this processor does not process names from the final set + // Names from the final set should therefore not affect the processing order + if (!isInFinalSet) + { + var referencedMemberkey = new MemberKey( + referencedMemberScope, + referencedMemberOriginalName + ); + if ( + !notifyDependantByKey.TryGetValue( + referencedMemberkey, + out var dependants + ) + ) + { + notifyDependantByKey[referencedMemberkey] = dependants = []; + } - public override void VisitMethodDeclaration(MethodDeclarationSyntax node) - { - if (node.Parent == _typeInProgress?.Type) - { - var typeIdentifier = _typeInProgress!.Value.Type.Identifier.ToString(); - var memberIdentifier = node.Identifier.ToString(); + dependants.Add(new MemberKey(scope, member)); + dependencyCount++; + } + } + else + { + // Failed to resolve reference + throw new InvalidOperationException( + $"Failed to resolve a name affix reference '{affix.Affix}' defined on '{member}'" + ); + } + } - if (_typeInProgress!.Value.Type.IsKind(SyntaxKind.StructDeclaration)) - { - // Prettify only - // Struct methods are introduced by the generator so they are not prefixed - if (!PrettifyOnlyTypes.TryGetValue(typeIdentifier, out var typeData)) + if (dependencyCount == 0) { - typeData = []; - PrettifyOnlyTypes.Add(typeIdentifier, typeData); + // No dependencies + ready.Enqueue(new MemberKey(scope, member)); + continue; } - typeData.Add(memberIdentifier); - } - else - { - // Trim + Prettify - ReportMemberAffixData(typeIdentifier, memberIdentifier, node.AttributeLists); - - _typeInProgress!.Value.Functions.Add(new FunctionData(memberIdentifier, node)); + // Store dependency count + dependencyCountByKey.Add(new MemberKey(scope, member), dependencyCount); } } - } - public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) - { - if (node.Parent == _typeInProgress?.Type) + // Output final order + while (ready.TryDequeue(out var key)) { - var typeIdentifier = _typeInProgress!.Value.Type.Identifier.ToString(); - var memberIdentifier = node.Identifier.ToString(); - ReportMemberAffixData(typeIdentifier, memberIdentifier, node.AttributeLists); - - // If it's not a constant then we only prettify. - var hasSetter = - node.AccessorList?.Accessors.Any(a => - a.IsKind(SyntaxKind.SetAccessorDeclaration) - || a.IsKind(SyntaxKind.InitAccessorDeclaration) - ) ?? false; - if (hasSetter) + processingOrderByKey.Add(key); + if (notifyDependantByKey.TryGetValue(key, out var dependants)) { - if (!PrettifyOnlyTypes.TryGetValue(typeIdentifier, out var typeData)) + foreach (var dependant in dependants) { - typeData = []; - PrettifyOnlyTypes.Add(typeIdentifier, typeData); + if (dependencyCountByKey.TryGetValue(dependant, out var dependencyCount)) + { + dependencyCount--; + if (dependencyCount == 0) + { + ready.Enqueue(dependant); + dependencyCountByKey.Remove(dependant); + continue; + } + + dependencyCountByKey[dependant] = dependencyCount; + } } - - typeData.Add(memberIdentifier); - } - else - { - _typeInProgress!.Value.NonFunctions.Add(memberIdentifier); } } - } - } - private class RenameSafeAttributeListsRewriter : CSharpSyntaxRewriter - { - public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node) => - ( - (MethodDeclarationSyntax)base.VisitMethodDeclaration(node)! - ).WithRenameSafeAttributeLists(); - } - - /// The affix data retrieved by the . - /// The configuration from . - private class PrettifyNamesAffixer( - Dictionary affixTypes, - Dictionary config - ) - { - private static readonly NameAffixConfiguration _defaultConfig = new(); - - /// - /// Removes affixes from the specified primary name and adds the original specified primary to the secondary list if provided. - /// - /// - /// Designed to be used by either or . - /// - /// The current primary name. - /// The container name. Either null or the containing type. - /// The original name of the identifier. Either the type name or the member name. - /// The list of secondary names. This should be null if used by . - /// The new primary name. - public string RemoveAffixes( - string primary, - string? container, - string originalName, - List? secondary - ) - { - var affixes = GetAffixes(container, originalName); - if (affixes.Length == 0) + // Check for cycles + if (dependencyCountByKey.Count != 0) { - return primary; + throw new InvalidOperationException( + $"Detected cycle in referenced affixes. Names that are part of the cycle: {string.Join(", ", dependencyCountByKey.Keys)}" + ); } - var stripped = NameAffixer.StripAffixes(primary, affixes); - if (stripped != primary) + foreach (var key in processingOrderByKey) { - secondary?.Add(primary); - } + var scopeData = nameData.Scopes[key.Scope]; + var scopeMembers = context.Scopes[key.Scope]; + if (!scopeData.TryGetValue(key.Member, out var memberData)) + { + continue; + } - return stripped; + var (primary, secondary) = scopeMembers[key.Member]; + var newPrimary = ApplyAffixes( + key.Scope, + primary, + secondary, + memberData.Affixes, + context + ); + scopeMembers[key.Member] = new CandidateNames(newPrimary, secondary); + } } /// - /// Applies affixes to the specified primary name and adds fallbacks to the secondary list if provided. + /// Applies affixes to the specified primary name and adds fallbacks to the secondary list. /// - /// - /// Designed to be used by either or . - /// + /// The scope of the original name. Used for resolving referenced affixes. /// The current primary name. - /// The container name. Either null or the containing type. - /// The original name of the identifier. Either the type name or the member name. - /// The list of secondary names. This should be null if used by . + /// The current secondary names. + /// The affixes declared for the original name. /// The new primary name. - public string ApplyAffixes( + /// The current . Used for resolving referenced affixes. + /// The new primary name. + private string ApplyAffixes( + string scope, string primary, - string? container, - string originalName, - List? secondary + List secondary, + NameAffix[] affixes, + NameProcessorContext context ) { - var affixes = GetAffixes(container, originalName); if (affixes.Length == 0) { return primary; @@ -1332,6 +828,7 @@ public string ApplyAffixes( string? newPrimary = null; // Process each group of affixes + var secondaryNamesAdded = 0; var hasProcessedNonDiscriminator = false; var currentPriority = int.MaxValue; for (var affixI = 0; affixI < affixes.Length; affixI++) @@ -1351,16 +848,16 @@ public string ApplyAffixes( hasProcessedNonDiscriminator = true; currentPriority = GetConfiguration(affix).DiscriminatorPriority; CreateName(primary, affixes.AsSpan()[..affixI]); - if (secondary == null) - { - return newPrimary!; - } } } // Process final group since the loop above skips the final group CreateName(primary, affixes); + // Reverse the secondaries added since secondaries later in the list have higher priority + // The original code above assumed that earlier had higher priority so this fixes that + secondary.AsSpan()[^secondaryNamesAdded..].Reverse(); + return newPrimary!; void CreateName(string name, Span currentAffixes) @@ -1384,15 +881,33 @@ void CreateName(string name, Span currentAffixes) foreach (var affix in currentAffixes) { + var affixValue = affix.Affix; + if (affix.IsReference) + { + if ( + TryResolveName( + context, + scope, + affixValue, + out _, + out var referencedMemberValue, + out _ + ) + ) + { + affixValue = referencedMemberValue; + } + } + if (!GetConfiguration(affix).Remove) { if (affix.Type == NameAffixType.Prefix) { - name = affix.Affix + name; + name = affixValue + name; } else { - name += affix.Affix; + name += affixValue; } } } @@ -1403,41 +918,75 @@ void CreateName(string name, Span currentAffixes) } else { - secondary?.Add(name); + secondary.Add(name); + secondaryNamesAdded++; } } } /// - /// Gets affix data for the specified container and original name of the identifier. + /// Tries the resolve the current output name of the referenced member from the current scope. /// - /// The container name. Either null or the containing type. - /// The original name of the identifier. Either the type name or the member name. - /// The name affixes for the specified identifier. - private NameAffix[] GetAffixes(string? container, string originalName) + /// The name processor context. Used during the name resolution process. + /// The scope from which the reference was made. The reference scope and its parent scopes will be used during the resolution process. + /// The original name of the member being referenced. + /// The scope in which the referenced member was found. + /// The current output name of the member being referenced. + /// Whether the referenced member was found in the final set. + private bool TryResolveName( + NameProcessorContext context, + string referenceScope, + string referencedMember, + [NotNullWhen(true)] out string? referencedMemberScope, + [NotNullWhen(true)] out string? referencedMemberValue, + out bool isInFinalSet + ) { - TypeAffixData typeAffixData; - if (container == null) + var currentScope = referenceScope; + while (true) { - if (!affixTypes.TryGetValue(originalName, out typeAffixData)) + // Try resolve from working set + if ( + context.Scopes.TryGetValue(currentScope, out var workingScopeMembers) + && workingScopeMembers.TryGetValue( + referencedMember, + out var referencedCandidateNames + ) + ) { - return []; + referencedMemberScope = currentScope; + referencedMemberValue = referencedCandidateNames.Primary; + isInFinalSet = false; + return true; } - return typeAffixData.TypeAffixes; - } - - if (affixTypes.TryGetValue(container, out typeAffixData)) - { + // Try resolve from final set if ( - typeAffixData.MemberAffixes?.TryGetValue(originalName, out var affixes) ?? false + context.FinalNames.TryGetValue(currentScope, out var finalScopeMembers) + && finalScopeMembers.TryGetValue(referencedMember, out var referencedFinalName) ) { - return affixes; + referencedMemberScope = currentScope; + referencedMemberValue = referencedFinalName; + isInFinalSet = true; + return true; } + + // Try to go up a scope + // This currently does not handle nested scopes + if (currentScope != "") + { + currentScope = ""; + continue; + } + + break; } - return []; + referencedMemberScope = null; + referencedMemberValue = null; + isInFinalSet = false; + return false; } private NameAffixConfiguration GetConfiguration(NameAffix affix) => @@ -1448,109 +997,604 @@ private NameAffixConfiguration GetConfiguration(string category) => } /// - /// Removes identified affixes so that other trimmers can process the base name separately. - /// These affixes should be reapplied by . + /// Prefixes candidate names that start with a number. + /// This is required because C# identifiers cannot start with a number. /// - private class NameAffixerEarlyTrimmer(PrettifyNamesAffixer affixer) : INameTrimmer + private class PrefixIfStartsWithNumberProcessor : INameProcessor { - /// - public Version Version => new(0, 0, 0); + public void ProcessNames(NameProcessorContext context) + { + foreach (var (_, members) in context.Scopes) + { + foreach (var (original, (primary, secondary)) in members) + { + for (var i = 0; i < secondary.Count; i++) + { + secondary[i] = NameUtils.PrefixIfStartsWithNumber(secondary[i]); + } - /// - public int Order => (int)TrimmerOrder.NameAffixerEarlyTrimmer; + members[original] = new CandidateNames( + NameUtils.PrefixIfStartsWithNumber(primary), + secondary + ); + } + } + } + } - public void Trim(NameTrimmerContext context) + /// + /// Resolves conflicts where multiple names have been transformed into the same output name. + /// This also considers cases where the methods with the same name are compatible because of method overloading rules. + /// + /// + /// This also copies the names from the final set back into the working set. + /// This is to ensure that all names are considered by the conflict resolution algorithm. + /// + private class ResolveConflictsProcessor(NameDataVisitor nameData, ILogger logger) + : INameProcessor + { + public void ProcessNames(NameProcessorContext context) { - if (context.Container == null) + // Add the names from the final set to the working set + // This is so that conflicts are resolved with all names available + foreach (var (scope, finalMembers) in context.FinalNames) { - foreach (var (original, (primary, secondary)) in context.Names) + if (!context.Scopes.TryGetValue(scope, out var workingMembers)) { - var secondaries = secondary; - var newPrimary = affixer.RemoveAffixes(primary, null, original, secondaries); - context.Names[original] = new CandidateNames(newPrimary, secondaries); + context.Scopes[scope] = workingMembers = []; } - return; + // Naively overwrite working set names + foreach (var (member, newMemberName) in finalMembers) + { + workingMembers[member] = new CandidateNames(newMemberName, []); + } } - foreach (var (original, (primary, secondary)) in context.Names) + // These collections are used later. + // These keep track of method discriminators to determine whether we have incompatible overloads. + // We keep track of the first original name so that we can add it to conflictingOriginalNames when we + // do discover a conflict (along with the original name of the actual conflict). + var methodDiscriminators = + new Dictionary< + string, + (string? FirstOriginalName, List Methods) + >(); + var conflictingOriginalNames = new HashSet(); + + // This loop cannot be part of the loop below because it modifies the primaries + foreach (var (scope, members) in context.Scopes) { - var secondaries = secondary; - var newPrimary = affixer.RemoveAffixes( - primary, - context.Container, - original, - secondaries - ); - context.Names[original] = new CandidateNames(newPrimary, secondaries); + if (!nameData.Scopes.TryGetValue(scope, out var scopeData)) + { + continue; + } + + var originalNamesByPrimary = GetOriginalNamesByPrimary(members); + foreach (var (_, originalNames) in originalNamesByPrimary) + { + // Count the number of original members that share this primary name + var nNonMethods = 0; + var nMethods = 0; + foreach (var originalName in originalNames) + { + if (scopeData.TryGetValue(originalName, out var memberData)) + { + foreach (var declaration in memberData.Declarations) + { + if (declaration is MethodDeclarationSyntax) + { + nMethods++; + continue; + } + + nNonMethods++; + } + } + } + + // If there are both non-methods and methods sharing the primary name, + // suffix the non-methods with "-Value" + // + // Main case: Non-method and method share the same name, but with different casing/underscoring + // GL_PROGRAM_STRING_ARB (constant) and glProgramStringARB (method) + // Both usually result in primaries of ProgramStringARB + // Prefixing the non-member with "-Value" works here + // + // Another way to handle this is to restore the namespace prefix for one of the members + // This works here, but is not always the case + // Suffixing with "-Value" should almost always work + if (nNonMethods != 0 && nMethods != 0) + { + foreach (var originalName in originalNames) + { + if ( + scopeData.TryGetValue(originalName, out var memberData) + && memberData.Declarations.Any(d => + d is not MethodDeclarationSyntax + ) + ) + { + var candidateNames = members[originalName]; + candidateNames.Secondary.Add(candidateNames.Primary); + members[originalName] = new CandidateNames( + $"{candidateNames.Primary}Value", + candidateNames.Secondary + ); + } + } + } + } + } + + foreach (var (scope, members) in context.Scopes) + { + nameData.Scopes.TryGetValue(scope, out var scopeData); + var originalNamesByPrimary = GetOriginalNamesByPrimary(members); + + // Unwind some names back to their secondary names if the primaries would duplicate + // We'll use a hash set to determine whether we need to check a primary for conflicts. + var primariesToEval = originalNamesByPrimary.Keys.ToHashSet(); + + while ( + primariesToEval.GetEnumerator() is var e + && e.MoveNext() + && e.Current is var primary + ) + { + // ^-- We can't use a foreach loop because we're mutating below. + // We're also using GetEnumerator instead of First to avoid allocations. + + // Clear temporary collections + methodDiscriminators.Clear(); + conflictingOriginalNames.Clear(); + + // We map the primary name to the original names so we can fetch information about the original members + var originalNamesForPrimary = originalNamesByPrimary[primary]; + + // Count the number of original members that share this primary name + var nNonMethods = 0; + var nMethods = 0; + if (scopeData != null) + { + foreach (var originalName in originalNamesForPrimary) + { + if (scopeData.TryGetValue(originalName, out var memberData)) + { + foreach (var declaration in memberData.Declarations) + { + if (declaration is MethodDeclarationSyntax) + { + nMethods++; + continue; + } + + nNonMethods++; + } + } + } + } + + // Methods can have the same names assuming their overloads are compatible + // We need to evaluate each signature to see + // if we can discriminate each one such that there are no conflicts. + // + // Example: alGetBufferf/alGetBufferfv (signatures are identical) + // In this case, we have to use secondary names to prevent the methods from conflicting + var nMethodConflicts = 0; + var nNoSecondaries = 0; // <-- at least all but one needs to have a secondary to resolve conflicts + string? noSecondaryOriginalName = null; + foreach (var originalName in originalNamesForPrimary) + { + // Do we even have a secondary to fall back on if there is a conflict? + if (members[originalName].Secondary.Count == 0) + { + noSecondaryOriginalName ??= originalName; + nNoSecondaries++; + } + + if ( + scopeData != null + && scopeData.TryGetValue(originalName, out var memberData) + ) + { + foreach (var declaration in memberData.Declarations) + { + if (declaration is not MethodDeclarationSyntax methodDeclaration) + { + continue; + } + + var discriminator = ModUtils.GetMethodDiscriminator( + methodDeclaration.Modifiers, + methodDeclaration.TypeParameterList, + primary, + methodDeclaration.ParameterList, + returnType: null + ); + + if ( + !methodDiscriminators.TryGetValue( + discriminator, + out var methodDiscriminator + ) + ) + { + methodDiscriminators[discriminator] = methodDiscriminator = ( + originalName, + [] + ); + } + + var (firstOriginalName, discriminatorMatches) = methodDiscriminator; + + discriminatorMatches.Add(methodDeclaration); + + // NOTE: The number of conflicts influences how we go about conflict resolution. See the + // logic below all of these loops just in case this comment is out of date, but at time of + // writing if 50% or more of the methods with this primary name are conflicting then we + // rename all of them, otherwise we rename only the conflicting overloads. + nMethodConflicts += discriminatorMatches.Count switch + { + 2 => 2, // The original needs to be counted as a conflict in addition to this conflict + > 2 => 1, // Just mark this conflict, original is already counted. + _ => 0, // No conflict to see here (not yet anyway, call it Schrodinger's Conflict) + }; + + if ( + discriminatorMatches.Count == 2 + && firstOriginalName is not null + ) + { + conflictingOriginalNames.Add(firstOriginalName); + } + + if (discriminatorMatches.Count > 1) + { + conflictingOriginalNames.Add(originalName); + } + } + } + } + + // If there are methods, check for two conditions: + // 1. That there are no non-methods (these always conflict) + // 2. That there are no conflicting method signatures + // If these conditions are satisfied, we can bail out early + if ( + nMethods > 0 + && nNonMethods == 0 + && (methodDiscriminators.Count == 0 || nMethodConflicts == 0) + ) + { + primariesToEval.Remove(primary); + continue; + } + + // We need to determine if we even have alternative names. If one doesn't that's fine because as long + // as we unwind all the others that one still won't conflict. + if (nNoSecondaries > 1) + { + logger.LogError( + "Couldn't resolve conflict for \"{}\" because {} of the APIs with that primary name did not have any secondary names.", + primary, + nNoSecondaries + ); + primariesToEval.Remove(primary); + continue; + } + + // Only rename the conflicts if most of the methods do not conflict + // Exception to this rule: If we have both non-methods and methods + var renameOnlyConflicts = + nMethodConflicts <= (nMethods / 2.0) && !(nNonMethods > 0 && nMethods > 0); + + // We can afford to leave one API alone. If that place isn't already filled by a method without a secondary + // name then we should fill it with whatever has the shortest original name. The logic being that the more + // characters (i.e. longer suffix) a name has, the more discriminatory/important that name is ergo the + // reverse (the shorter the name, the less discriminatory/important it is) is also true. + string? first = null; + var primaryClaimed = noSecondaryOriginalName is not null; + primariesToEval.Remove(primary); // <-- just in case the below loop somehow produces the same primary again. + foreach ( + var conflictingOriginalName in ( + renameOnlyConflicts + ? conflictingOriginalNames + : originalNamesByPrimary[primary] + ) + .OrderBy(x => x.Length) // Short names have priority + .ThenBy(x => x) // Tie-breaker + ) + { + // Do not rename if this is the original name that does not have a secondary. + if (noSecondaryOriginalName == conflictingOriginalName) + { + continue; + } + + // If the current primary hasn't been "claimed" by an original name without a secondary, we only want + // to let the shortest name claim it (per the logic described in the last comment) if it is actually + // the absolute shortest name and not joint-1st for that title. Therefore, the first original name + // is saved for the second iteration where we'll make that judgement call and handle both at the + // same time. + if (first is null) + { + first = conflictingOriginalName; + if (!primaryClaimed) + { + continue; + } + } + + // Now we're going to make the above judgement call. If the first item has the same length as the + // second item, the first item has no right to claim the primary name therefore both items will be + // demoted to use their secondary name. + if (!primaryClaimed) + { + if (first.Length == conflictingOriginalName.Length) + { + // Update the output name. + var firstSecondary = + members[first].Secondary + ?? throw new InvalidOperationException( + "More than one original member name without secondary names." + ); + var firstNextPrimary = firstSecondary[^1]; + firstSecondary.RemoveAt(firstSecondary.Count - 1); + members[first] = new CandidateNames( + firstNextPrimary, + firstSecondary + ); + + // Update our primary to original name map + if ( + !originalNamesByPrimary.TryGetValue( + firstNextPrimary, + out var originalNamesForFirst + ) + ) + { + originalNamesByPrimary[firstNextPrimary] = + originalNamesForFirst = []; + } + + originalNamesForFirst.Add(first); + originalNamesForPrimary.Remove(first); + if (originalNamesForPrimary.Count == 0) + { + originalNamesByPrimary.Remove(primary); + } + + // Make sure we do a pass over the new primary just in case we already have APIs with that + // primary + primariesToEval.Add(firstNextPrimary); + if (logger.IsEnabled(LogLevel.Trace)) // <-- prevent needless string.Join + { + logger.LogTrace( + "{}: {} -> {} (remaining secondaries: {})", + first, + primary, + firstNextPrimary, + string.Join(", ", firstNextPrimary) + ); + } + } + + primaryClaimed = true; + } + + // Conflict resolution! Update the output name. + var secondary = + members[conflictingOriginalName].Secondary + ?? throw new InvalidOperationException( + "More than one original member name without secondary names." + ); + var nextPrimary = secondary[^1]; + secondary.RemoveAt(secondary.Count - 1); + members[conflictingOriginalName] = new CandidateNames( + nextPrimary, + secondary + ); + + // Update our primary to original name map + if ( + !originalNamesByPrimary.TryGetValue( + nextPrimary, + out var originalNamesForNewPrimary + ) + ) + { + originalNamesByPrimary[nextPrimary] = originalNamesForNewPrimary = []; + } + + originalNamesForNewPrimary.Add(conflictingOriginalName); + originalNamesForPrimary.Remove(conflictingOriginalName); + if (originalNamesForPrimary.Count == 0) + { + originalNamesByPrimary.Remove(primary); + } + + // Make sure we do a pass over the new primary just in case we already have APIs with that primary + primariesToEval.Add(nextPrimary); + if (logger.IsEnabled(LogLevel.Trace)) // <-- prevent needless string.Join + { + logger.LogTrace( + "{}: {} -> {} (remaining secondaries: {})", + conflictingOriginalName, + primary, + nextPrimary, + string.Join(", ", secondary) + ); + } + } + } + } + + return; + + Dictionary> GetOriginalNamesByPrimary( + Dictionary members + ) + { + // Create a mapping: Primary name -> Original name + // Primary name refers to the primary candidate name + // Original name refers to the original name of the member as seen in source code + // + // This is to account for method overloads that have the + // same primary candidate name and original name, but different discriminators + // + // This usually happens with generated/transformed overloads + var originalNamesByPrimary = new Dictionary>(); + foreach (var (originalName, (primary, _)) in members) + { + if ( + !originalNamesByPrimary.TryGetValue( + primary, + out var originalNamesForPrimary + ) + ) + { + originalNamesByPrimary[primary] = originalNamesForPrimary = []; + } + + originalNamesForPrimary.Add(originalName); + } + + return originalNamesByPrimary; } } } /// - /// Reapplies and transforms identified affixes based on . + /// Outputs all primary names to the final set of names. /// - private class NameAffixerLateTrimmer(PrettifyNamesAffixer affixer) : INameTrimmer + /// + /// This is intentionally implemented in a naive manner. + /// The working set of names is not cleared and existing data in the final set can be overwritten. + /// + private class OutputFinalNamesProcessor : INameProcessor { - /// - public Version Version => new(0, 0, 0); + public void ProcessNames(NameProcessorContext context) + { + foreach (var (scope, members) in context.Scopes) + { + if (!context.FinalNames.TryGetValue(scope, out var outputScope)) + { + context.FinalNames[scope] = outputScope = []; + } - /// - public int Order => (int)TrimmerOrder.NameAffixerLateTrimmer; + foreach (var (member, (primary, _)) in members) + { + outputScope[member] = primary; + } + } + } + } - public void Trim(NameTrimmerContext context) + /// + /// Removes all unmodified names from the final set of names. + /// + private class RemoveUnmodifiedFinalNamesProcessor : INameProcessor + { + public void ProcessNames(NameProcessorContext context) { - if (context.Container == null) + var unmodified = new List(); + + // Remove unmodified members + foreach (var (_, members) in context.FinalNames) { - foreach (var (original, (primary, secondary)) in context.Names) + unmodified.Clear(); + foreach (var (originalName, newName) in members) { - var secondaries = secondary; - var newPrimary = affixer.ApplyAffixes(primary, null, original, secondaries); - context.Names[original] = new CandidateNames(newPrimary, secondaries); + if (originalName == newName) + { + unmodified.Add(originalName); + } } - return; + foreach (var unmodifiedMember in unmodified) + { + members.Remove(unmodifiedMember); + } } - foreach (var (original, (primary, secondary)) in context.Names) + // Remove unmodified scopes + foreach (var (scope, members) in context.FinalNames) { - var secondaries = secondary; - var newPrimary = affixer.ApplyAffixes( - primary, - context.Container, - original, - secondaries - ); - context.Names[original] = new CandidateNames(newPrimary, secondaries); + if (members.Count == 0) + { + unmodified.Add(scope); + } + } + + foreach (var unmodifiedScope in unmodified) + { + context.FinalNames.Remove(unmodifiedScope); } } } - private class PrettifyNamesTrimmer(NamePrettifier namePrettifier) : INameTrimmer + /// + /// Represents a name processor. + /// + private interface INameProcessor { - /// - public Version Version => new(0, 0, 0); + /// + /// Process and transform the names within the given scope. + /// + public void ProcessNames(NameProcessorContext context); + } - /// - public int Order => (int)TrimmerOrder.PrettifyNamesTrimmer; + /// + /// State made available to implementations. + /// + private class NameProcessorContext + { + /// + /// Represents a mapping: ScopeName -> (MemberName -> MemberCandidateNames). + /// This stores the candidates for the final prettified name for each name organized by scope. + /// Also known as the working set of names. + /// + public Dictionary> Scopes { get; } - public void Trim(NameTrimmerContext context) - { - foreach (var (original, (primary, secondary)) in context.Names) - { - // Be lenient about caps for type names (e.g. GL) - var allowAllCaps = context.Container == null; + /// + /// Represents a mapping: ScopeName -> (MemberName -> NewMemberName). + /// This stores the final names for each member. + /// + /// + /// Processors are allowed to modify these, but should have a good reason in doing so. + /// + public Dictionary> FinalNames { get; } = []; - for (var i = 0; i < secondary.Count; i++) - { - secondary[i] = namePrettifier.Prettify(secondary[i], allowAllCaps); - } + /// + /// Creates a new context from the scraped name data. + /// + public NameProcessorContext(NameDataVisitor nameData) => + Scopes = nameData.Scopes.ToDictionary( + // Scope + x => x.Key, + x => + x.Value.ToDictionary( + // Member name + y => y.Key, + // Member candidate names + y => new CandidateNames(y.Key, []) + ) + ); + } - context.Names[original] = new CandidateNames( - namePrettifier.Prettify(primary, allowAllCaps), - secondary - ); - } - } + /// + /// Represents the set of primary and secondary candidates for the prettified version of a name. + /// + /// The preferred version of the output name. + /// + /// The fallback versions of the output name. + /// Used in the case the primary causes conflicts. + /// Names later in the list have higher priority. + /// + private readonly record struct CandidateNames(string Primary, List Secondary) + { + public override string ToString() => + $"(Primary={Primary}, Secondary=[{string.Join(", ", Secondary)}])"; } } diff --git a/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs b/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs index 5e958705c6..04feaa8cd0 100644 --- a/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs +++ b/sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs @@ -25,11 +25,6 @@ namespace Silk.NET.SilkTouch.Mods; /// VkBuffer*, usages of that pointer will be replaced by VkBufferHandle. For a 2-dimensional pointer, /// VkBuffer**, the resulting replacement is VkBufferHandle*. /// -/// -/// It is assumed that all handle types in the generated syntax do not require a using directive in order to be -/// in scope. That is, if a file with the namespace Silk.NET.OpenGL is encountered and it is referencing -/// Program, Program must be declared in Silk.NET.OpenGL, Silk.NET, or Silk. -/// [ModConfiguration] public class TransformHandles( IOptionsSnapshot config, @@ -41,16 +36,10 @@ ILogger logger /// public class Config { - /// - /// Whether it should be assumed that missing types are likely opaque if they are only used as a pointer type - /// and therefore should be subjected to handle transformations. - /// - public bool AssumeMissingTypesOpaque { get; init; } - /// /// Whether the DSL (i.e. nullptr) should be usable with handle types. /// - public bool UseDSL { get; init; } + public bool UseDsl { get; init; } } /// @@ -58,6 +47,7 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct = { await base.ExecuteAsync(ctx, ct); + var cfg = config.Get(ctx.JobKey); var project = ctx.SourceProject; if (project == null) { @@ -70,45 +60,13 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct = throw new InvalidOperationException("Failed to get compilation"); } - var cfg = config.Get(ctx.JobKey); - if (cfg.AssumeMissingTypesOpaque) - { - // Find missing handle types - var handleDiscoverer = new MissingHandleTypeDiscoverer(logger, compilation, ct); - var missingHandleTypes = handleDiscoverer.GetMissingHandleTypes(); - - // Generate syntax nodes containing empty structs to represent the missing handle types - var structGenerator = new EmptyStructGenerator(); - var syntaxNodes = structGenerator.GenerateSyntaxNodes(missingHandleTypes); - - // Add syntax nodes to the project as new documents - foreach (var (fullyQualifiedName, node) in syntaxNodes) - { - var relativePath = $"Handles/{PathForFullyQualified(fullyQualifiedName)}"; - project = project - .AddDocument( - Path.GetFileName(relativePath), - node.NormalizeWhitespace(), - filePath: project.FullPath(relativePath) - ) - .Project; - } - - // Update compilation - compilation = await project.GetCompilationAsync(ct); - if (compilation == null) - { - throw new InvalidOperationException("Failed to get compilation"); - } - } - // Find handle documents var handleTypeDiscoverer = new HandleTypeDiscoverer(project, compilation, ct); var handleTypes = await handleTypeDiscoverer.GetHandleTypesAsync(); // Store handle document IDs for later // We will use these IDs to know which documents to rewrite and rename - var handleTypeDocumentIds = new List<(string OriginalName, DocumentId DocumentId)>(); + var handleTypeDocumentIds = new List(); foreach (var handleTypeSymbol in handleTypes) { if (handleTypeSymbol.DeclaringSyntaxReferences.Length > 1) @@ -124,7 +82,7 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct = var documentId = project.GetDocumentId(declaringSyntaxReference.SyntaxTree); if (documentId != null) { - handleTypeDocumentIds.Add((handleTypeSymbol.Name, documentId)); + handleTypeDocumentIds.Add(documentId); } } @@ -141,8 +99,8 @@ [new PointerDimensionReductionTransformer()], project = ctx.SourceProject; // Use document IDs from earlier - var handleTypeRewriter = new HandleTypeRewriter(cfg.UseDSL); - foreach (var (originalName, documentId) in handleTypeDocumentIds) + var handleTypeRewriter = new HandleTypeRewriter(cfg.UseDsl); + foreach (var documentId in handleTypeDocumentIds) { var document = project.GetDocument(documentId) @@ -165,270 +123,6 @@ [new PointerDimensionReductionTransformer()], } ctx.SourceProject = project; - - return; - } - - private class MissingHandleTypeDiscoverer( - ILogger logger, - Compilation compilation, - CancellationToken ct - ) : SymbolVisitor - { - private readonly HashSet _nonHandleTypes = - new(SymbolEqualityComparer.Default); - private readonly Dictionary _missingTypes = - new(SymbolEqualityComparer.Default); - - private string? _currentNamespace = null; - private int _pointerTypeDepth = 0; - - /// - /// Gets all missing handle types that are found and the namespace that they should be created in. - /// - public Dictionary GetMissingHandleTypes() - { - // We need to find and generate all missing handle types - // Handle types are types that are only referenced through a pointer - // We do this by parsing through the list of type errors - var typeErrors = compilation - .GetDiagnostics(ct) - .Where(d => d.Id == "CS0246") // Type errors - .ToList(); - - // Find symbols that contain ITypeErrorSymbols - // These symbols are not necessarily ITypeErrorSymbols - var symbolsFound = new HashSet(SymbolEqualityComparer.Default); - foreach (var typeError in typeErrors) - { - var syntaxTree = typeError.Location.SourceTree; - if (syntaxTree == null) - { - continue; - } - - var semanticModel = compilation.GetSemanticModel(syntaxTree); - - // Get the syntax node the type error corresponds to - var currentSyntax = syntaxTree.GetRoot().FindNode(typeError.Location.SourceSpan); - - // Search upwards to find a syntax node that we can call GetDeclaredSymbol on - // This is because calling GetDeclaredSymbol on the starting node will just return null - var isSuccess = false; - while (currentSyntax != null && currentSyntax is not TypeDeclarationSyntax) - { - switch (currentSyntax) - { - case VariableDeclarationSyntax variableDeclarationSyntax: - { - foreach (var declaratorSyntax in variableDeclarationSyntax.Variables) - { - var symbol = semanticModel.GetDeclaredSymbol(declaratorSyntax, ct); - if (symbol != null) - { - symbolsFound.Add(symbol); - isSuccess = true; - - // All of the declarators will have the same type, so getting the first symbol is enough - break; - } - } - - break; - } - case MemberDeclarationSyntax memberDeclarationSyntax: - { - var symbol = semanticModel.GetDeclaredSymbol( - memberDeclarationSyntax, - ct - ); - if (symbol != null) - { - symbolsFound.Add(symbol); - isSuccess = true; - } - - break; - } - // Skip syntaxes that will never contain handle types - case BaseTypeSyntax: - case AttributeSyntax: - { - isSuccess = true; - break; - } - } - - currentSyntax = currentSyntax.Parent; - } - - if (!isSuccess) - { - // This is to warn of unhandled cases - logger.LogWarning( - "Failed to find corresponding symbol for type error. There may be an unhandled case in the code" - ); - } - } - - // These symbols contain at least one IErrorTypeSymbol, we need to search downwards for them - foreach (var symbol in symbolsFound) - { - Visit(symbol); - } - - return new Dictionary( - _missingTypes.Where(kvp => !_nonHandleTypes.Contains(kvp.Key)), - SymbolEqualityComparer.Default - ); - } - - public override void VisitMethod(IMethodSymbol symbol) - { - base.VisitMethod(symbol); - - _currentNamespace = symbol.NamespaceFromSymbol(); - foreach (var parameterSymbol in symbol.Parameters) - { - Visit(parameterSymbol); - } - _currentNamespace = null; - } - - public override void VisitParameter(IParameterSymbol symbol) - { - base.VisitParameter(symbol); - - _currentNamespace = symbol.NamespaceFromSymbol(); - Visit(symbol.Type); - _currentNamespace = null; - } - - public override void VisitProperty(IPropertySymbol symbol) - { - base.VisitProperty(symbol); - - _currentNamespace = symbol.NamespaceFromSymbol(); - Visit(symbol.Type); - _currentNamespace = null; - } - - public override void VisitField(IFieldSymbol symbol) - { - base.VisitField(symbol); - - _currentNamespace = symbol.NamespaceFromSymbol(); - Visit(symbol.Type); - _currentNamespace = null; - } - - public override void VisitLocal(ILocalSymbol symbol) - { - base.VisitLocal(symbol); - - _currentNamespace = symbol.NamespaceFromSymbol(); - Visit(symbol.Type); - _currentNamespace = null; - } - - public override void VisitPointerType(IPointerTypeSymbol symbol) - { - base.VisitPointerType(symbol); - - _pointerTypeDepth++; - Visit(symbol.PointedAtType); - _pointerTypeDepth--; - } - - public override void VisitNamedType(INamedTypeSymbol symbol) - { - base.VisitNamedType(symbol); - - if (symbol is IErrorTypeSymbol errorTypeSymbol) - { - if (_currentNamespace == null) - { - throw new InvalidOperationException( - $"{nameof(_currentNamespace)} should not be null" - ); - } - - if (_pointerTypeDepth == 0) - { - _nonHandleTypes.Add(errorTypeSymbol); - } - - if (_missingTypes.TryGetValue(errorTypeSymbol, out var sharedNamespace)) - { - _missingTypes[errorTypeSymbol] = NameUtils - .FindCommonPrefix([sharedNamespace, _currentNamespace], true, false, true) - .Trim('.'); - } - else - { - _missingTypes[errorTypeSymbol] = _currentNamespace; - } - } - } - } - - private class EmptyStructGenerator - { - /// - /// Generates a syntax node for each specified type. - /// - /// Map from error type symbol to the namespace the type should be created in. - /// Map from the fully qualified name of the generated type to the syntax node containing code for that type. - public Dictionary GenerateSyntaxNodes( - Dictionary typesToGenerate - ) => - GenerateSyntaxNodes( - typesToGenerate - .Select(kvp => new KeyValuePair(kvp.Key.Name, kvp.Value)) - .ToDictionary() - ); - - /// - /// Generates a syntax node for each specified type. - /// - /// Map from type name to the namespace the type should be created in. - /// Map from the fully qualified name of the generated type to the syntax node containing code for that type. - public Dictionary GenerateSyntaxNodes( - Dictionary missingHandleTypes - ) - { - var results = new Dictionary(); - foreach (var (name, ns) in missingHandleTypes) - { - var fullyQualifiedName = string.IsNullOrWhiteSpace(ns) ? name : $"{ns}.{name}"; - var structDeclarationSyntax = StructDeclaration(name) - .WithModifiers( - TokenList( - Token(SyntaxKind.PublicKeyword), - Token(SyntaxKind.UnsafeKeyword), - Token(SyntaxKind.PartialKeyword) - ) - ); - - results[fullyQualifiedName] = CompilationUnit() - .WithMembers( - SingletonList( - string.IsNullOrWhiteSpace(ns) - ? structDeclarationSyntax - : FileScopedNamespaceDeclaration( - ModUtils.NamespaceIntoIdentifierName(ns) - ) - .WithMembers( - SingletonList( - structDeclarationSyntax - ) - ) - ) - ); - } - - return results; - } } private class HandleTypeDiscoverer( @@ -533,7 +227,7 @@ public override void VisitNamedType(INamedTypeSymbol symbol) } } - private class HandleTypeRewriter(bool useDSL) : CSharpSyntaxRewriter + private class HandleTypeRewriter(bool useDsl) : CSharpSyntaxRewriter { public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node) { @@ -547,7 +241,7 @@ public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node) .WithMembers( List( GetDefaultHandleMembers(structName) - .Concat(useDSL ? GetDSLHandleMembers(structName) : []) + .Concat(useDsl ? GetDslHandleMembers(structName) : []) ) ) .WithModifiers( @@ -629,7 +323,7 @@ string structName Identifier("Equals") ) .WithModifiers( - TokenList([Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.OverrideKeyword)]) + TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.OverrideKeyword)) ) .WithParameterList( ParameterList( @@ -668,7 +362,7 @@ string structName Identifier("GetHashCode") ) .WithModifiers( - TokenList([Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.OverrideKeyword)]) + TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.OverrideKeyword)) ) .WithExpressionBody( ArrowExpressionClause( @@ -700,7 +394,7 @@ string structName Token(SyntaxKind.EqualsEqualsToken) ) .WithModifiers( - TokenList([Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)]) + TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)) ) .WithParameterList( ParameterList( @@ -737,7 +431,7 @@ string structName Token(SyntaxKind.ExclamationEqualsToken) ) .WithModifiers( - TokenList([Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)]) + TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)) ) .WithParameterList( ParameterList( @@ -771,7 +465,7 @@ string structName .WithSemicolonToken(Token(SyntaxKind.SemicolonToken)); } - private static IEnumerable GetDSLHandleMembers(string structName) + private static IEnumerable GetDslHandleMembers(string structName) { yield return MethodDeclaration( PredefinedType(Token(SyntaxKind.BoolKeyword)), @@ -800,7 +494,7 @@ private static IEnumerable GetDSLHandleMembers(string s Token(SyntaxKind.EqualsEqualsToken) ) .WithModifiers( - TokenList([Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)]) + TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)) ) .WithParameterList( ParameterList( @@ -837,7 +531,7 @@ private static IEnumerable GetDSLHandleMembers(string s Token(SyntaxKind.ExclamationEqualsToken) ) .WithModifiers( - TokenList([Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)]) + TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)) ) .WithParameterList( ParameterList( @@ -875,7 +569,7 @@ private static IEnumerable GetDSLHandleMembers(string s IdentifierName(structName) ) .WithModifiers( - TokenList([Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)]) + TokenList(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)) ) .WithParameterList( ParameterList( diff --git a/sources/SilkTouch/SilkTouch/Mods/Transformation/FunctionTransformer.cs b/sources/SilkTouch/SilkTouch/Mods/Transformation/FunctionTransformer.cs index cc221c4561..ba663df169 100644 --- a/sources/SilkTouch/SilkTouch/Mods/Transformation/FunctionTransformer.cs +++ b/sources/SilkTouch/SilkTouch/Mods/Transformation/FunctionTransformer.cs @@ -56,14 +56,14 @@ public IEnumerable GetTransformedFunctions( // to null as overloads that differ only by return type aren't acceptable. However, we do need a // discriminator that does include the return type so we can determine whether the function has gone // through the transformation pipeline completely unmodified. - var discrim = ModUtils.DiscrimStr( + var discrim = ModUtils.GetMethodDiscriminator( meth.Modifiers, meth.TypeParameterList, meth.Identifier.ToString(), meth.ParameterList, returnType: null ); - var discrimWithRet = ModUtils.DiscrimStr( + var discrimWithRet = ModUtils.GetMethodDiscriminator( meth.Modifiers, meth.TypeParameterList, meth.Identifier.ToString(), @@ -127,14 +127,14 @@ meth.Body.Statements[0] as ExpressionStatementSyntax // to null as overloads that differ only by return type aren't acceptable. However, we do need a // discriminator that does include the return type so we can determine whether the function has gone // through the transformation pipeline completely unmodified. - var discrim = ModUtils.DiscrimStr( + var discrim = ModUtils.GetMethodDiscriminator( function.Modifiers, function.TypeParameterList, function.Identifier.ToString(), function.ParameterList, returnType: null ); - var discrimWithRet = ModUtils.DiscrimStr( + var discrimWithRet = ModUtils.GetMethodDiscriminator( function.Modifiers, function.TypeParameterList, function.Identifier.ToString(), @@ -190,7 +190,7 @@ meth.Body.Statements[0] as ExpressionStatementSyntax ) ); - discrim = ModUtils.DiscrimStr( + discrim = ModUtils.GetMethodDiscriminator( function.Modifiers, function.TypeParameterList, newIden, diff --git a/sources/SilkTouch/SilkTouch/Naming/CandidateNames.cs b/sources/SilkTouch/SilkTouch/Naming/CandidateNames.cs deleted file mode 100644 index 101122c6c8..0000000000 --- a/sources/SilkTouch/SilkTouch/Naming/CandidateNames.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Silk.NET.SilkTouch.Naming; - -/// -/// Represents the set of primary and secondary options for the trimmed version of a name. -/// -/// The preferred version of the trimmed name. -/// The fallback versions of the trimmed name in case the primary does not work. -public record struct CandidateNames(string Primary, List Secondary) -{ - /// - /// Formats this instance as a string. - /// - public override string ToString() => - $"(Primary={Primary}, Secondary=[{string.Join(", ", Secondary)}])"; -} diff --git a/sources/SilkTouch/SilkTouch/Naming/INameTrimmer.cs b/sources/SilkTouch/SilkTouch/Naming/INameTrimmer.cs deleted file mode 100644 index ec77fef58e..0000000000 --- a/sources/SilkTouch/SilkTouch/Naming/INameTrimmer.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Silk.NET.SilkTouch.Naming; - -/// -/// Represents a name trimmer. -/// -public interface INameTrimmer -{ - /// - /// Gets the name trimmer version i.e. the Silk.NET version that introduced this name trimming method. This is so - /// new bindings released with or after this version don't have to have older trimming methods executed (the name - /// version can be specified in the mod configuration) - /// - Version Version { get; } - - /// - /// Used to define the order that the trimmers will run in. - /// Higher values indicate that the trimmer should run later. - /// - int Order { get; } - - /// - /// Trims prefixes from the given constituent names within the given container. - /// - /// The arguments. - void Trim(NameTrimmerContext context); -} diff --git a/sources/SilkTouch/SilkTouch/Naming/NameAffix.cs b/sources/SilkTouch/SilkTouch/Naming/NameAffix.cs index c5c132a9fc..90be238ffa 100644 --- a/sources/SilkTouch/SilkTouch/Naming/NameAffix.cs +++ b/sources/SilkTouch/SilkTouch/Naming/NameAffix.cs @@ -13,9 +13,14 @@ namespace Silk.NET.SilkTouch.Naming; /// The order that the attribute was declared in. /// 0 is the first and indicates that the affix is on the inside of the name. /// +/// +/// Whether the affix uses the name of a referenced symbol. +/// See . +/// public record struct NameAffix( NameAffixType Type, string Category, string Affix, - int DeclarationOrder + int DeclarationOrder, + bool IsReference = false ); diff --git a/sources/SilkTouch/SilkTouch/Naming/NameAffixer.cs b/sources/SilkTouch/SilkTouch/Naming/NameAffixer.cs index a778a7d2dc..22fcfdd1f7 100644 --- a/sources/SilkTouch/SilkTouch/Naming/NameAffixer.cs +++ b/sources/SilkTouch/SilkTouch/Naming/NameAffixer.cs @@ -32,13 +32,21 @@ public static NameAffix[] GetNameAffixes(this SyntaxList at var argumentList = attribute.ArgumentList; if ( - argumentList != null - && argumentList.Arguments[0].Expression - is LiteralExpressionSyntax { Token.Value: string type } - && argumentList.Arguments[1].Expression - is LiteralExpressionSyntax { Token.Value: string category } - && argumentList.Arguments[2].Expression - is LiteralExpressionSyntax { Token.Value: string affix } + argumentList == null + || argumentList.Arguments[0].Expression + is not LiteralExpressionSyntax { Token.Value: string type } + || argumentList.Arguments[1].Expression + is not LiteralExpressionSyntax { Token.Value: string category } + ) + { + continue; + } + + if ( + argumentList.Arguments[2].Expression is LiteralExpressionSyntax + { + Token.Value: string affix + } ) { affixes = @@ -51,6 +59,36 @@ public static NameAffix[] GetNameAffixes(this SyntaxList at declarationOrder ), ]; + + declarationOrder++; + } + else if ( + argumentList.Arguments[2].Expression is InvocationExpressionSyntax + { + Expression: IdentifierNameSyntax { Identifier.ValueText: "nameof" }, + ArgumentList.Arguments: [ + { + Expression: IdentifierNameSyntax + { + Identifier.ValueText: var referencedAffix, + }, + }, + ], + } + ) + { + affixes = + [ + .. affixes, + new NameAffix( + type == "Prefix" ? NameAffixType.Prefix : NameAffixType.Suffix, + category, + referencedAffix, + declarationOrder, + true + ), + ]; + declarationOrder++; } } @@ -92,17 +130,92 @@ public static SyntaxList AddNameAffix( Literal($"\"{affixType}\"", affixType) ) ); + var categoryArgument = AttributeArgument( LiteralExpression( SyntaxKind.StringLiteralExpression, Literal($"\"{category}\"", category) ) ); + var affixArgument = AttributeArgument( LiteralExpression(SyntaxKind.StringLiteralExpression, Literal($"\"{affix}\"", affix)) ); + var argumentList = AttributeArgumentList([typeArgument, categoryArgument, affixArgument]); + var attribute = AttributeList([Attribute(IdentifierName("NameAffix"), argumentList)]); + + return addToInner ? [attribute, .. attributeLists] : [.. attributeLists, attribute]; + } + + /// + /// This is similar to + /// but allows the name of another symbol to be referenced. + /// + /// This ensures transformations applied to the referenced symbol's name + /// are also applied to this affix. + /// + /// + /// This allows compound names to be handled more cleanly. + /// + /// For simplicity, only names within the same name container are currently supported. + /// This lets us skip sorting across different containers. + /// This should cover most real world use cases since if something is nested and + /// has the parent name as a prefix, then the prefix is likely unnecessary. + /// + /// + /// For example, PerformanceCounterDescriptionARM can be used as a referenced prefix for PerformanceCounterDescriptionARMName. + /// If PerformanceCounterDescriptionARM becomes ARMPerformanceCounterDescription, + /// then PerformanceCounterDescriptionARMName will also be output as ARMPerformanceCounterDescriptionName. + /// + public static SyntaxList AddReferencedNameAffix( + this IEnumerable attributeLists, + NameAffixType type, + string category, + string referencedAffix, + bool addToInner = false + ) + { + var affixType = type switch + { + NameAffixType.Prefix => "Prefix", + NameAffixType.Suffix => "Suffix", + _ => throw new ArgumentOutOfRangeException(nameof(type)), + }; + + var typeArgument = AttributeArgument( + LiteralExpression( + SyntaxKind.StringLiteralExpression, + Literal($"\"{affixType}\"", affixType) + ) + ); + var categoryArgument = AttributeArgument( + LiteralExpression( + SyntaxKind.StringLiteralExpression, + Literal($"\"{category}\"", category) + ) + ); + + // nameof(referencedAffix) + var affixArgument = AttributeArgument( + InvocationExpression( + IdentifierName( + Identifier( + TriviaList(), + SyntaxKind.NameOfKeyword, + "nameof", + "nameof", + TriviaList() + ) + ) + ) + .WithArgumentList( + ArgumentList(SingletonSeparatedList(Argument(IdentifierName(referencedAffix)))) + ) + ); + + var argumentList = AttributeArgumentList([typeArgument, categoryArgument, affixArgument]); var attribute = AttributeList([Attribute(IdentifierName("NameAffix"), argumentList)]); return addToInner ? [attribute, .. attributeLists] : [.. attributeLists, attribute]; diff --git a/sources/SilkTouch/SilkTouch/Naming/NamePrettifier.cs b/sources/SilkTouch/SilkTouch/Naming/NamePrettifier.cs index 1e9f5387ea..0b6cbce8e5 100644 --- a/sources/SilkTouch/SilkTouch/Naming/NamePrettifier.cs +++ b/sources/SilkTouch/SilkTouch/Naming/NamePrettifier.cs @@ -21,6 +21,7 @@ public class NamePrettifier(int longAcronymThreshold) { /// /// Prettifies the given C# identifier. + /// This involves transformation steps such as removing underscores and pascal casing the identifier. /// /// /// See the test cases for this method to see examples on how this method behaves. @@ -31,12 +32,7 @@ public class NamePrettifier(int longAcronymThreshold) /// Thrown when the input or output is an empty identifier. public string Prettify(string identifier, bool allowAllCaps = false) { - if (identifier.Length == 0) - { - throw new InvalidOperationException("Cannot prettify an empty identifier"); - } - - var words = NameSplitter.BreakIntoWords(identifier); + var words = NameSplitter.SplitIntoWords(identifier); // Add "X" to separate out numbers for (var i = words.Count - 1; i >= 1; i--) @@ -50,15 +46,6 @@ public string Prettify(string identifier, bool allowAllCaps = false) } } - // Add "X" if first word is a number - if (words.Count > 0) - { - if (NameUtils.GetCharType(words[0][0]) is CharType.Number) - { - words.Insert(0, "X"); - } - } - // Pretend there is an underscore between each word // This is used as a heuristic for determining whether we can treat short, all uppercase words as acronyms // @@ -179,17 +166,11 @@ public string Prettify(string identifier, bool allowAllCaps = false) } } - var result = string.Join("", words); - if (result.Length == 0) - { - throw new InvalidOperationException( - $"Prettification for '{identifier}' led to an empty identifier" - ); - } + var result = string.Join(null, words); // Disallow all capitals var resultSpan = result.AsSpan(); - if (!allowAllCaps && IsAllCaps(result)) + if (result.Length > 0 && !allowAllCaps && IsAllCaps(result)) { Span caps = stackalloc char[resultSpan.Length - 1]; resultSpan[1..].ToLower(caps, CultureInfo.InvariantCulture); diff --git a/sources/SilkTouch/SilkTouch/Naming/NameSplitter.cs b/sources/SilkTouch/SilkTouch/Naming/NameSplitter.cs index abf8c0af12..4b67b5dac8 100644 --- a/sources/SilkTouch/SilkTouch/Naming/NameSplitter.cs +++ b/sources/SilkTouch/SilkTouch/Naming/NameSplitter.cs @@ -10,6 +10,12 @@ namespace Silk.NET.SilkTouch.Naming; /// public static class NameSplitter { + /// + /// Splits the given C# identifier into separate words and rejoins them using an underscore as a separator. + /// + public static string Underscore(string identifier) => + string.Join("_", SplitIntoWords(identifier)); + /// /// Splits the given C# identifier into separate words. /// @@ -17,7 +23,7 @@ public static class NameSplitter /// See the test cases for this method to see examples on how this method behaves. /// /// A string that contains only valid C# identifier characters. - public static List BreakIntoWords(string identifier) + public static List SplitIntoWords(string identifier) { var words = new List(); var currentWord = new StringBuilder(); diff --git a/sources/SilkTouch/SilkTouch/Naming/NameTrimmer.cs b/sources/SilkTouch/SilkTouch/Naming/NameTrimmer.cs deleted file mode 100644 index 3bc9c92deb..0000000000 --- a/sources/SilkTouch/SilkTouch/Naming/NameTrimmer.cs +++ /dev/null @@ -1,407 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text.Json; - -namespace Silk.NET.SilkTouch.Naming; - -/// -/// The default name trimmer ported from Silk.NET 2.18 with modifications for 3.0. -/// -public class NameTrimmer : INameTrimmer -{ - /// - public virtual Version Version => new(3, 0); - - /// - public virtual int Order => (int)TrimmerOrder.NameTrimmer; - - /// - /// Determines whether a second pass without using is warranted. - /// - protected virtual bool HasRawPass => true; - - /// - /// Determines whether a third pass using "naive" prefix detection is warranted. Only applicable if - /// is true. - /// - /// - protected virtual bool HasNaivePass => true; - - private static readonly HashSet s_forbiddenTrimmings = new() { "unsigned", "per" }; - - /// - public void Trim(NameTrimmerContext context) - { - string? identifiedPrefix = null; - List localNames = null!; - var nPasses = HasRawPass - ? HasNaivePass - ? 3 - : 2 - : 1; - var naive = false; - if (identifiedPrefix is null) - { - for (var i = 0; i < nPasses; i++) // try with both trimming name and non trimming name - { - // Attempt to identify the hint being used. - string? hint = null; - foreach (var candidateHint in context.Configuration.GlobalPrefixHints ?? []) - { - var match = true; - foreach (var (name, _) in context.Names.Values) - { - if (!name.StartsWith(candidateHint, StringComparison.OrdinalIgnoreCase)) - { - match = false; - break; - } - } - - if (match) - { - hint = candidateHint; - break; - } - } - - var result = GetPrefix( - context.Container, - hint, - context.Names, - context.Configuration.PrefixOverrides, - context.NonDeterminant, - i == 0, - naive = i == 2 - ); - - if (result is null) - { - // skip outright. - return; - } - - (identifiedPrefix, localNames) = result.Value; - - // If we have found a prefix, - if ( - identifiedPrefix.Length > 0 - && identifiedPrefix.Length < localNames.Min(x => x.TrimmingName.Length) - ) - { - // break and use it for trimming! - break; - } - - // If not, do most of them at least start with the hint? - if ( - hint is null - || localNames.Count(x => - x.TrimmingName.StartsWith(hint, StringComparison.OrdinalIgnoreCase) - ) - >= localNames.Count / 2 - ) - { - // Nope, nothing we can do it seems, we've already tried both trimming name and non trimming name... - continue; - } - - // The prefix is the hint! - identifiedPrefix = hint; - naive = true; - break; - } - } - - // If identifiedPrefix is null, we fall back to the hints. I know we've checked above whether this is the - // obvious answer for a given pass, but if we've still got no possible prefix after all of the passes then this - // is better than nothing - if the name doesn't start with the prefix we simply won't use the prefix. - if ( - string.IsNullOrWhiteSpace(identifiedPrefix) - && context.Configuration.GlobalPrefixHints is not { Count: > 0 } - ) - { - return; - } - - identifiedPrefix = identifiedPrefix?.Trim('_'); - foreach (var (oldPrimary, secondary, originalName, trimmingName) in localNames) - { - foreach ( - var candidatePrefix in !string.IsNullOrWhiteSpace(identifiedPrefix) - ? [identifiedPrefix] // otherwise we fall back to the hints... - : context.Configuration.GlobalPrefixHints ?? [] - ) - { - if ( - naive - && ( - candidatePrefix.Length >= trimmingName.Length - || !trimmingName.StartsWith( - candidatePrefix, - StringComparison.OrdinalIgnoreCase - ) - ) - ) - { - continue; - } - - var oldPrimaryI = 0; - var isPrefixTooLong = false; - for (var candidateI = 0; candidateI < candidatePrefix.Length; candidateI++) - { - if (oldPrimaryI >= oldPrimary.Length) - { - isPrefixTooLong = true; - break; - } - - if ( - char.ToLower(candidatePrefix[candidateI]) - == char.ToLower(oldPrimary[oldPrimaryI]) - ) - { - oldPrimaryI++; - continue; - } - - if (candidatePrefix[candidateI] == '_') - { - oldPrimaryI++; - } - } - - if (isPrefixTooLong) - { - continue; - } - - // this was trimmingName originally. given that we're using trimming name to determine a prefix but then - // using that prefix on the old primary, this could cause intended behaviour in some cases. there's probably - // a better way to do this. (this is working around glDisablei -> glDisable -> Disablei). - context.Names[originalName] = new CandidateNames( - oldPrimary[oldPrimaryI..].Trim('_'), - secondary - ); - break; - } - } - } - - /// - /// Gets the prefix for the given constituents of the given container. - /// - /// The container name if applicable. - /// The global prefix hint if applicable. - /// The names to get a prefix for. - /// Prefix overrides. - /// List of names that should not be used for prefix determination. - /// - /// Whether to use or to use the native name as-is. - /// - /// - /// Just match the start of the strings, don't bother checking for obvious name separation gaps. - /// - /// - /// Null to skip this container outright, empty if no prefix was found, or the prefix otherwise. - /// - /// A local names list is also returned. - /// This is the list of names to be used for the remainder of the trimming process - /// and contains the trimming name and original name. - /// - protected (string Prefix, List)? GetPrefix( - string? container, - string? hint, - Dictionary names, - Dictionary? prefixOverrides, - HashSet? nonDeterminant, - bool getTrimmingName, - bool naive - ) - { - // If the type has no members, - if (names.Count == 0) - { - // skip it - return null; - } - - // Get the trimming names - var containerTrimmingName = getTrimmingName - ? GetTrimmingName(prefixOverrides, container ?? hint ?? string.Empty, true, hint) - : container ?? hint ?? string.Empty; - - var localNames = names - .Select(x => new AugmentedCandidateNames( - x.Value.Primary, - x.Value.Secondary, - x.Key, - getTrimmingName - ? GetTrimmingName(prefixOverrides, x.Value.Primary, false, hint) - : x.Value.Primary - )) - .ToList(); - - // Set the prefix to the prefix override for this container, if it exists. - // This is to allow us to handle poorly/inconsistently named containers, - // without putting special cases elsewhere in the logic - // ex: For the enum - // enum Things { - // ThingsRGB - // ThingRGB - // } - // If we specify a prefix override of "Thing", - // then it will trim ThingsRGB to sRGB and ThingRGB to RGB - // a case like this is simple to add a special case for in the generator to handle sRGB specially, - // but see ImageChannelOrder from spirv.h for a more problematic occurrence. - string prefix; - if ( - container is not null - && (prefixOverrides?.TryGetValue(container, out var @override) ?? false) - ) - { - // Use the override - prefix = @override; - } - else - { - if (names.Count == 1) - { - if (!string.IsNullOrWhiteSpace(containerTrimmingName)) - { - // Use the member name and its container. - prefix = NameUtils.FindCommonPrefix( - [ - names - .First(x => !(nonDeterminant?.Contains(x.Key) ?? false)) - .Value.Primary, - containerTrimmingName, - ], - true, - false, - naive - ); - } - else - { - // One name. Can't determine prefix. - prefix = ""; - } - } - else - { - // Common case - Find the prefix based on the container's members - prefix = NameUtils.FindCommonPrefix( - localNames - .Where(x => !(nonDeterminant?.Contains(x.Original) ?? false)) - .Select(x => x.TrimmingName) - .ToList(), - // If naive mode is on and we're trimming type names, allow full matches (method class is - // probably the prefix) - naive && container is null, - false, - naive - ); - } - } - - // If any of the children's trimming name is shorter than the prefix length, - if ( - localNames.Any(x => - x.TrimmingName.Length <= prefix.Length - && !(nonDeterminant?.Contains(x.Original) ?? false) - ) && !string.IsNullOrWhiteSpace(containerTrimmingName) - ) - { - // Do a second pass, but put the container name in the loop to see if it makes a difference - prefix = NameUtils.FindCommonPrefix( - localNames.Select(x => x.TrimmingName).Append(containerTrimmingName).ToList(), - // If naive mode is on and we're trimming type names, allow full matches (method class is probably the - // prefix) - naive && container is null, - false, - naive - ); - } - - // Iterate through all of the forbidden trimmings, - foreach (var word in s_forbiddenTrimmings) - { - // If the prefix starts with a forbidden trimming, - if (prefix.StartsWith($"{word}_")) - { - // Clear the prefix - prefix = string.Empty; - } - - // If the prefix contains the forbidden trimming surrounded by underscores, - var idx = prefix.IndexOf($"_{word}_", StringComparison.OrdinalIgnoreCase); - if (idx != -1) - { - // Trim the end of the prefix to the start of the forbidden trimming - // ex: - // input prefix = THIS_GL_ - // forbidden trimming = GL - // - // resulting prefix = THIS - prefix = prefix[..idx]; - } - } - - return (prefix, localNames); - } - - /// - /// Gets the name to feed into . - /// - /// The prefix overrides. - /// The name to get a trimming name for. - /// Whether the name passed into is the container name. - /// The global prefix hint. - /// The trimming name. - public virtual string GetTrimmingName( - Dictionary? prefixOverrides, - string name, - bool isContainer, - string? hint = null - ) - { - // If theres a prefix override for this enum, - if (prefixOverrides?.ContainsKey(name) ?? false) - { - // Use the raw native name as the trimming name - return name; - } - - if (hint is not null && name.StartsWith(hint, StringComparison.OrdinalIgnoreCase)) - { - return $"{hint}_{name[hint.Length..].Trim('_').LenientUnderscore()}"; - } - - return name.Trim('_').LenientUnderscore(); - } - - /// - /// Similar to , but with some additional information. - /// - /// The preferred version of the trimmed name. - /// The fallback versions of the trimmed name in case the primary does not work. - /// The original, unmodified name. - /// The name used for trimming purposes. - protected record struct AugmentedCandidateNames( - string Primary, - List Secondary, - string Original, - string TrimmingName - ) - { - /// - /// Formats this instance as a string. - /// - public override string ToString() => - $"(Original={Original}, TrimmingName={TrimmingName}, Primary={Primary}, Secondary=[{string.Join(", ", Secondary)}])"; - } -} diff --git a/sources/SilkTouch/SilkTouch/Naming/NameTrimmer217.cs b/sources/SilkTouch/SilkTouch/Naming/NameTrimmer217.cs deleted file mode 100644 index e188daad90..0000000000 --- a/sources/SilkTouch/SilkTouch/Naming/NameTrimmer217.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using Humanizer; - -namespace Silk.NET.SilkTouch.Naming; - -/// -/// The 2.17 name trimmer. -/// -[Obsolete("Use NameTrimmer instead for 3.0 names")] -public class NameTrimmer217 : NameTrimmer -{ - /// - public override Version Version => new(2, 17); - - /// - public override int Order => (int)TrimmerOrder.NameTrimmer217; - - /// - protected override bool HasRawPass => false; - - /// - protected override bool HasNaivePass => false; - - /// - public override string GetTrimmingName( - Dictionary? prefixOverrides, - string name, - bool isContainer, - string? hint = null - ) - { - if (!isContainer) - { - return name; - } - - return !name.Contains('_') ? name.Underscore() : name; - } -} diff --git a/sources/SilkTouch/SilkTouch/Naming/NameTrimmer218.cs b/sources/SilkTouch/SilkTouch/Naming/NameTrimmer218.cs deleted file mode 100644 index fd9a0b8fbf..0000000000 --- a/sources/SilkTouch/SilkTouch/Naming/NameTrimmer218.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace Silk.NET.SilkTouch.Naming; - -/// -/// The 2.18 name trimmer. -/// -[Obsolete("Use NameTrimmer instead for 3.0 names")] -public class NameTrimmer218 : NameTrimmer -{ - /// - public override Version Version => new(2, 18); - - /// - public override int Order => (int)TrimmerOrder.NameTrimmer218; - - /// - protected override bool HasRawPass => false; - - /// - protected override bool HasNaivePass => false; -} diff --git a/sources/SilkTouch/SilkTouch/Naming/NameTrimmerContext.cs b/sources/SilkTouch/SilkTouch/Naming/NameTrimmerContext.cs deleted file mode 100644 index caede1740e..0000000000 --- a/sources/SilkTouch/SilkTouch/Naming/NameTrimmerContext.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Silk.NET.SilkTouch.Mods; - -namespace Silk.NET.SilkTouch.Naming; - -/// -/// State made available to implementations when determining a trimmed name. -/// -public readonly struct NameTrimmerContext -{ - /// - /// Gets the name of the "container" (e.g. a type name) of the APIs in . - /// - public string? Container { get; init; } - - /// - /// Gets the identifier for the current generation job, unique across the current - /// instance. - /// - public string? JobKey { get; init; } - - /// - /// Gets a dictionary mapping the original API name to a primary candidate name to rename that API to. The previous - /// names or other names that are otherwise less preferred to the primary name are listed in the optional secondary - /// list (in order of preference). - /// - public required Dictionary Names { get; init; } - - /// - /// Gets the current configuration for the mod. - /// - public PrettifyNames.Configuration Configuration { get; init; } - - /// - /// Gets a set of original API names (i.e. the key stored in ) that have been marked with - /// the [Transformed] attribute. - /// - public HashSet NonDeterminant { get; init; } -} diff --git a/sources/SilkTouch/SilkTouch/Naming/NameUtils.cs b/sources/SilkTouch/SilkTouch/Naming/NameUtils.cs index 9f0b34e21c..391e25a521 100644 --- a/sources/SilkTouch/SilkTouch/Naming/NameUtils.cs +++ b/sources/SilkTouch/SilkTouch/Naming/NameUtils.cs @@ -1,6 +1,5 @@ using System.Buffers; using System.Diagnostics.CodeAnalysis; -using System.Text.RegularExpressions; using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; using Silk.NET.SilkTouch.Mods; @@ -12,7 +11,7 @@ namespace Silk.NET.SilkTouch.Naming; /// Contains utilities used throughout the naming namespace. /// [SuppressMessage("ReSharper", "LoopCanBeConvertedToQuery")] -public static partial class NameUtils +public static class NameUtils { /// /// All capital letters. @@ -38,6 +37,19 @@ public static partial class NameUtils "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" ); + /// + /// Prefixes the given identifier with the specified prefix if it starts with a number. + /// + public static string PrefixIfStartsWithNumber(string identifier, string prefix = "X") + { + if (identifier.Length > 0 && char.IsDigit(identifier[0])) + { + return $"X{identifier}"; + } + + return identifier; + } + /// /// Gets the char type for the specified character according /// to the categorization defined by . @@ -174,47 +186,6 @@ public static string FindCommonPrefix( return foundPrefix[..(naive ? foundPrefix.Length : foundPrefix.LastIndexOf('_') + 1)]; } - /// - /// Separates the input words with underscore - /// - /// The string to be underscored - /// - public static string LenientUnderscore(this string input) => - // This is a modified version of Humanizer's Underscore methods with the following changes: - // - The regex ([\p{Ll}\d])([\p{Lu}]) has been replaced with - // ([\p{Ll}\d])(?=[\p{Lu}][\p{Lu}\p{Ll}])([\p{Lu}]) - In this regex, the positive lookahead assertion - // (?=[\p{Lu}][\p{Lu}\p{Ll}]) ensures that the next character after the match is an uppercase letter, - // followed by any letter (uppercase or lowercase). This will only match if the 2nd character after the - // initial match is uppercase. That was suggested by ChatGPT, a human had to add the final - // [\p{Ll}])([\p{Lu}]) to ensure we don't erroneous match non-pascal case strings and to capture the - // second character to ensure we can do the replacement. Still pretty smart though. - // - The final ToLower has been omitted as it was not deemed necessary - // - The regex ([\p{Ll}])([\p{Lu}]) has been added to replace lowercase letters followed by an uppercase letter with the - // same sequence but with an underscore inbetween, - // this fixes cases like SpvImageFormatR32ui being Spv_Image_FormatR32ui instead of Spv_Image_Format_R32ui - KebabOrSpace() - .Replace( - LowerUpper() - .Replace( - LowerUpperAnyUpper() - .Replace(LowerUpperLower().Replace(input, "$1_$2"), "$1_$2"), - "$1_$2" - ), - "_" - ); - - [GeneratedRegex(@"[-\s]")] - private static partial Regex KebabOrSpace(); - - [GeneratedRegex(@"([\p{Ll}])([\p{Lu}])")] - private static partial Regex LowerUpper(); - - [GeneratedRegex(@"([\p{Ll}])(?=[\p{Lu}][\p{Lu}\p{Ll}])([\p{Lu}])")] - private static partial Regex LowerUpperAnyUpper(); - - [GeneratedRegex(@"([\p{Lu}]+)([\p{Lu}][\p{Ll}])")] - private static partial Regex LowerUpperLower(); - /// /// Rename all symbols with the given new names /// diff --git a/sources/SilkTouch/SilkTouch/Naming/TrimmerOrder.cs b/sources/SilkTouch/SilkTouch/Naming/TrimmerOrder.cs deleted file mode 100644 index 1ec873a1e9..0000000000 --- a/sources/SilkTouch/SilkTouch/Naming/TrimmerOrder.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Silk.NET.SilkTouch.Naming; - -/// -/// Defines the order for SilkTouch's implementations. -/// -internal enum TrimmerOrder -{ - NameAffixerEarlyTrimmer = 100, - - NameTrimmer = 200, - NameTrimmer217 = 210, - NameTrimmer218 = 220, - - PrettifyNamesTrimmer = 400, - - NameAffixerLateTrimmer = 500, -} diff --git a/sources/SilkTouch/SilkTouch/ServiceCollectionExtensions.cs b/sources/SilkTouch/SilkTouch/ServiceCollectionExtensions.cs index 4809f51f0b..66bf03df6a 100644 --- a/sources/SilkTouch/SilkTouch/ServiceCollectionExtensions.cs +++ b/sources/SilkTouch/SilkTouch/ServiceCollectionExtensions.cs @@ -54,8 +54,6 @@ static ServiceCollectionExtensions() /// /// /// - /// - /// One or more s /// An appropriate implementation of /// Mod implementations referenced in the configurations /// @@ -96,16 +94,13 @@ IConfiguration config // - https://andrewlock.net/how-to-register-a-service-with-multiple-interfaces-for-in-asp-net-core-di/ // - https://discordapp.com/channels/143867839282020352/663803973119115264/1129546023388332075 (C# Discord) - // services.AddSingleton(); <-- this is a mod now services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.TryAddSingleton(s => s.GetRequiredService() ); - services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(s => s.GetRequiredService()); services.AddSingleton(s => s.GetRequiredService()); services.AddSingleton(typeof(IJobDependency<>), typeof(JobDependencies.Global<>)); services.TryAddSingleton(); diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXT.gen.cs index 13b4dabafe..77a76d9b27 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXT.gen.cs @@ -26,5 +26,5 @@ public unsafe partial struct DebugMarkerMarkerInfoEXT [NativeName("color")] [SupportedApiProfile("vulkan", ["VK_EXT_debug_marker"], ImpliesSets = ["VK_EXT_debug_report"])] - public DebugMarkerMarkerInfoExtColor Color; + public DebugMarkerMarkerInfoEXTColor Color; } diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoExtColor.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXTColor.gen.cs similarity index 91% rename from sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoExtColor.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXTColor.gen.cs index a087892818..d5f5533600 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoExtColor.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXTColor.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_color_e__FixedBuffer")] [InlineArray(4)] [SupportedApiProfile("vulkan")] -public partial struct DebugMarkerMarkerInfoExtColor +public partial struct DebugMarkerMarkerInfoEXTColor { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXT.gen.cs index 1fbcc76130..17ca5c46b9 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXT.gen.cs @@ -52,7 +52,7 @@ public DebugReportCallbackEXT( ) => Pointer = ptr; [SupportedApiProfile("vulkan", ["VK_EXT_debug_report"])] - public DebugReportCallbackEXT(DebugReportCallbackDelegateEXT proc) => + public DebugReportCallbackEXT(DebugReportCallbackEXTDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); [SupportedApiProfile("vulkan", ["VK_EXT_debug_report"])] diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackDelegateEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXTDelegate.gen.cs similarity index 91% rename from sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackDelegateEXT.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXTDelegate.gen.cs index 6d5f18666f..1fc82b973b 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackDelegateEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXTDelegate.gen.cs @@ -10,7 +10,7 @@ namespace Silk.NET.Vulkan; [NativeName("PFN_vkDebugReportCallbackEXT")] [SupportedApiProfile("vulkan")] -public unsafe delegate uint DebugReportCallbackDelegateEXT( +public unsafe delegate uint DebugReportCallbackEXTDelegate( DebugReportFlagsEXT arg0, DebugReportObjectTypeEXT arg1, ulong arg2, diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXT.gen.cs index 13684e4abe..ef3b1e23fd 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXT.gen.cs @@ -26,5 +26,5 @@ public unsafe partial struct DebugUtilsLabelEXT [NativeName("color")] [SupportedApiProfile("vulkan", ["VK_EXT_debug_utils"])] - public DebugUtilsLabelExtColor Color; + public DebugUtilsLabelEXTColor Color; } diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelExtColor.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXTColor.gen.cs similarity index 92% rename from sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelExtColor.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXTColor.gen.cs index ead85ca18f..26aabcef9d 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelExtColor.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXTColor.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_color_e__FixedBuffer")] [InlineArray(4)] [SupportedApiProfile("vulkan")] -public partial struct DebugUtilsLabelExtColor +public partial struct DebugUtilsLabelEXTColor { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXT.gen.cs index 282236565a..1ac52b77f8 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXT.gen.cs @@ -40,7 +40,7 @@ public DebugUtilsMessengerCallbackEXT( ) => Pointer = ptr; [SupportedApiProfile("vulkan", ["VK_EXT_debug_utils"])] - public DebugUtilsMessengerCallbackEXT(DebugUtilsMessengerCallbackDelegateEXT proc) => + public DebugUtilsMessengerCallbackEXT(DebugUtilsMessengerCallbackEXTDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); [SupportedApiProfile("vulkan", ["VK_EXT_debug_utils"])] diff --git a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackDelegateEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXTDelegate.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackDelegateEXT.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXTDelegate.gen.cs index 91a410e8c5..4b0d3d12ee 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackDelegateEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXTDelegate.gen.cs @@ -10,7 +10,7 @@ namespace Silk.NET.Vulkan; [NativeName("PFN_vkDebugUtilsMessengerCallbackEXT")] [SupportedApiProfile("vulkan")] -public unsafe delegate uint DebugUtilsMessengerCallbackDelegateEXT( +public unsafe delegate uint DebugUtilsMessengerCallbackEXTDelegate( DebugUtilsMessageSeverityFlagsEXT arg0, DebugUtilsMessageTypeFlagsEXT arg1, DebugUtilsMessengerCallbackDataEXT* arg2, diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoEXT.gen.cs index c241a1bc4d..0428db281f 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoEXT.gen.cs @@ -42,7 +42,7 @@ public unsafe partial struct DeviceFaultInfoEXT "VK_EXT_device_fault+VK_VERSION_1_1", ] )] - public DeviceFaultInfoExtDescription Description; + public DeviceFaultInfoEXTDescription Description; [NativeName("pAddressInfos")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoExtDescription.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoEXTDescription.gen.cs similarity index 92% rename from sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoExtDescription.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoEXTDescription.gen.cs index c4cbc58aa9..a2f27be648 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoExtDescription.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultInfoEXTDescription.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_description_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct DeviceFaultInfoExtDescription +public partial struct DeviceFaultInfoEXTDescription { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneEXT.gen.cs index 0a7a83c41a..603198dba3 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneEXT.gen.cs @@ -75,7 +75,7 @@ public partial struct DeviceFaultVendorBinaryHeaderVersionOneEXT "VK_EXT_device_fault+VK_VERSION_1_1", ] )] - public DeviceFaultVendorBinaryHeaderVersionOneExtPipelineCacheUuid PipelineCacheUuid; + public DeviceFaultVendorBinaryHeaderVersionOneEXTPipelineCacheUuid PipelineCacheUuid; [NativeName("applicationNameOffset")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneExtPipelineCacheUuid.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneEXTPipelineCacheUuid.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneExtPipelineCacheUuid.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneEXTPipelineCacheUuid.gen.cs index ed9aa0c92f..6ce5eea9de 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneExtPipelineCacheUuid.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorBinaryHeaderVersionOneEXTPipelineCacheUuid.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_pipelineCacheUUID_e__FixedBuffer")] [InlineArray(16)] [SupportedApiProfile("vulkan")] -public partial struct DeviceFaultVendorBinaryHeaderVersionOneExtPipelineCacheUuid +public partial struct DeviceFaultVendorBinaryHeaderVersionOneEXTPipelineCacheUuid { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoEXT.gen.cs index b4e39a666c..753adcbc03 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoEXT.gen.cs @@ -21,7 +21,7 @@ public partial struct DeviceFaultVendorInfoEXT "VK_EXT_device_fault+VK_VERSION_1_1", ] )] - public DeviceFaultVendorInfoExtDescription Description; + public DeviceFaultVendorInfoEXTDescription Description; [NativeName("vendorFaultCode")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoExtDescription.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoEXTDescription.gen.cs similarity index 91% rename from sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoExtDescription.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoEXTDescription.gen.cs index f84c0d4223..6f754dab2e 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoExtDescription.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceFaultVendorInfoEXTDescription.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_description_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct DeviceFaultVendorInfoExtDescription +public partial struct DeviceFaultVendorInfoEXTDescription { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKHR.gen.cs index 44e75160f8..fed8459d69 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKHR.gen.cs @@ -37,7 +37,7 @@ public unsafe partial struct DeviceGroupPresentCapabilitiesKHR ImpliesSets = ["VK_KHR_surface"], RequireAll = true )] - public DeviceGroupPresentCapabilitiesKhrPresentMask PresentMask; + public DeviceGroupPresentCapabilitiesKHRPresentMask PresentMask; [NativeName("modes")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKhrPresentMask.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKHRPresentMask.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKhrPresentMask.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKHRPresentMask.gen.cs index d6b865390b..ebee5fd756 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKhrPresentMask.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceGroupPresentCapabilitiesKHRPresentMask.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_presentMask_e__FixedBuffer")] [InlineArray(32)] [SupportedApiProfile("vulkan")] -public partial struct DeviceGroupPresentCapabilitiesKhrPresentMask +public partial struct DeviceGroupPresentCapabilitiesKHRPresentMask { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackEXT.gen.cs index 547894dd2f..9f9fa3e3e3 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackEXT.gen.cs @@ -53,7 +53,7 @@ public DeviceMemoryReportCallbackEXT( "VK_EXT_device_memory_report+VK_VERSION_1_1", ] )] - public DeviceMemoryReportCallbackEXT(DeviceMemoryReportCallbackDelegateEXT proc) => + public DeviceMemoryReportCallbackEXT(DeviceMemoryReportCallbackEXTDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackDelegateEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackEXTDelegate.gen.cs similarity index 89% rename from sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackDelegateEXT.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackEXTDelegate.gen.cs index deaccc8c73..c5ca8bf774 100644 --- a/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackDelegateEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/DeviceMemoryReportCallbackEXTDelegate.gen.cs @@ -10,7 +10,7 @@ namespace Silk.NET.Vulkan; [NativeName("PFN_vkDeviceMemoryReportCallbackEXT")] [SupportedApiProfile("vulkan")] -public unsafe delegate void DeviceMemoryReportCallbackDelegateEXT( +public unsafe delegate void DeviceMemoryReportCallbackEXTDelegate( DeviceMemoryReportCallbackDataEXT* arg0, void* arg1 ); diff --git a/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrLUNARG.gen.cs b/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrLUNARG.gen.cs index efa078ca71..d6faa30480 100644 --- a/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrLUNARG.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrLUNARG.gen.cs @@ -25,7 +25,7 @@ public GetInstanceProcAddrLUNARG( ) => Pointer = ptr; [SupportedApiProfile("vulkan", ["VK_LUNARG_direct_driver_loading"])] - public GetInstanceProcAddrLUNARG(GetInstanceProcAddrDelegateLUNARG proc) => + public GetInstanceProcAddrLUNARG(GetInstanceProcAddrLUNARGDelegate proc) => Pointer = SilkMarshal.DelegateToPtr(proc); [SupportedApiProfile("vulkan", ["VK_LUNARG_direct_driver_loading"])] diff --git a/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrDelegateLUNARG.gen.cs b/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrLUNARGDelegate.gen.cs similarity index 96% rename from sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrDelegateLUNARG.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrLUNARGDelegate.gen.cs index 3a8b09e9da..2f7915729f 100644 --- a/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrDelegateLUNARG.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/GetInstanceProcAddrLUNARGDelegate.gen.cs @@ -10,7 +10,7 @@ namespace Silk.NET.Vulkan; [NativeName("PFN_vkGetInstanceProcAddrLUNARG")] [SupportedApiProfile("vulkan")] -public unsafe delegate GetInstanceProcAddrLunargP2 GetInstanceProcAddrDelegateLUNARG( +public unsafe delegate GetInstanceProcAddrLunargP2 GetInstanceProcAddrLUNARGDelegate( InstanceHandle arg0, sbyte* arg1 ); diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionARM.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionARM.gen.cs index dec072b919..b97c601f2f 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionARM.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionARM.gen.cs @@ -54,5 +54,5 @@ public unsafe partial struct PerformanceCounterDescriptionARM "VK_ARM_performance_counters_by_region+VK_VERSION_1_1", ] )] - public PerformanceCounterDescriptionArmName Name; + public PerformanceCounterDescriptionARMName Name; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionArmName.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionARMName.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionArmName.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionARMName.gen.cs index e20908c4ce..5a86dc4127 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionArmName.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionARMName.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_name_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PerformanceCounterDescriptionArmName +public partial struct PerformanceCounterDescriptionARMName { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHR.gen.cs index 2eb342b252..d1652a9826 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHR.gen.cs @@ -53,7 +53,7 @@ public unsafe partial struct PerformanceCounterDescriptionKHR "VK_KHR_performance_query+VK_VERSION_1_1", ] )] - public PerformanceCounterDescriptionKhrName Name; + public PerformanceCounterDescriptionKHRName Name; [NativeName("category")] [SupportedApiProfile( @@ -64,7 +64,7 @@ public unsafe partial struct PerformanceCounterDescriptionKHR "VK_KHR_performance_query+VK_VERSION_1_1", ] )] - public PerformanceCounterDescriptionKhrCategory Category; + public PerformanceCounterDescriptionKHRCategory Category; [NativeName("description")] [SupportedApiProfile( @@ -75,5 +75,5 @@ public unsafe partial struct PerformanceCounterDescriptionKHR "VK_KHR_performance_query+VK_VERSION_1_1", ] )] - public PerformanceCounterDescriptionKhrDescription Description; + public PerformanceCounterDescriptionKHRDescription Description; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrCategory.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRCategory.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrCategory.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRCategory.gen.cs index ee58dfe571..41ebd3e9fe 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrCategory.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRCategory.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_category_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PerformanceCounterDescriptionKhrCategory +public partial struct PerformanceCounterDescriptionKHRCategory { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoExtDescription.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRDescription.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoExtDescription.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRDescription.gen.cs index 5fe2577487..8a1728d76d 100644 --- a/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoExtDescription.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRDescription.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_description_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct RenderPassSubpassFeedbackInfoExtDescription +public partial struct PerformanceCounterDescriptionKHRDescription { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrName.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRName.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrName.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRName.gen.cs index a35447ccba..f58216aeb8 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrName.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKHRName.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_name_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PerformanceCounterDescriptionKhrName +public partial struct PerformanceCounterDescriptionKHRName { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKHR.gen.cs index 4802d80517..62d78a8919 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKHR.gen.cs @@ -75,5 +75,5 @@ public unsafe partial struct PerformanceCounterKHR "VK_KHR_performance_query+VK_VERSION_1_1", ] )] - public PerformanceCounterKhrUuid Uuid; + public PerformanceCounterKHRUuid Uuid; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKhrUuid.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKHRUuid.gen.cs similarity index 92% rename from sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKhrUuid.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKHRUuid.gen.cs index 3a78cef254..dbb1421f79 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKhrUuid.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterKHRUuid.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_uuid_e__FixedBuffer")] [InlineArray(16)] [SupportedApiProfile("vulkan")] -public partial struct PerformanceCounterKhrUuid +public partial struct PerformanceCounterKHRUuid { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEI.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEI.gen.cs index b92c913fde..77b0b6c226 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEI.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEI.gen.cs @@ -43,7 +43,7 @@ public unsafe partial struct PhysicalDeviceClusterCullingShaderPropertiesHUAWEI "VK_HUAWEI_cluster_culling_shader+VK_VERSION_1_1", ] )] - public PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupCount MaxWorkGroupCount; + public PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupCount MaxWorkGroupCount; [NativeName("maxWorkGroupSize")] [SupportedApiProfile( @@ -54,7 +54,7 @@ public unsafe partial struct PhysicalDeviceClusterCullingShaderPropertiesHUAWEI "VK_HUAWEI_cluster_culling_shader+VK_VERSION_1_1", ] )] - public PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupSize MaxWorkGroupSize; + public PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupSize MaxWorkGroupSize; [NativeName("maxOutputClusterCount")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupCount.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupCount.gen.cs similarity index 96% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupCount.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupCount.gen.cs index 48dab6dbde..b7d88a6160 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupCount.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupCount.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_maxWorkGroupCount_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupCount +public partial struct PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupCount { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupSize.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupSize.gen.cs similarity index 96% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupSize.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupSize.gen.cs index 0485b6731f..65713a1cec 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupSize.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupSize.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_maxWorkGroupSize_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceClusterCullingShaderPropertiesHuaweiMaxWorkGroupSize +public partial struct PhysicalDeviceClusterCullingShaderPropertiesHUAWEIMaxWorkGroupSize { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportARM.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportARM.gen.cs index 8ba7a9716d..61f19560dd 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportARM.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportARM.gen.cs @@ -26,7 +26,7 @@ public partial struct PhysicalDeviceDataGraphOperationSupportARM ["VK_ARM_data_graph"], ImpliesSets = ["VK_KHR_deferred_host_operations", "VK_KHR_maintenance5", "VK_VERSION_1_3"] )] - public PhysicalDeviceDataGraphOperationSupportArmName Name; + public PhysicalDeviceDataGraphOperationSupportARMName Name; [NativeName("version")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportArmName.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportARMName.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportArmName.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportARMName.gen.cs index 2576ec8325..d9e71b528e 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportArmName.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceDataGraphOperationSupportARMName.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_name_e__FixedBuffer")] [InlineArray(128)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceDataGraphOperationSupportArmName +public partial struct PhysicalDeviceDataGraphOperationSupportARMName { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKHR.gen.cs index 1c49013c9e..8cdd72e207 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKHR.gen.cs @@ -34,5 +34,5 @@ public unsafe partial struct PhysicalDeviceLayeredApiPropertiesKHR [NativeName("deviceName")] [SupportedApiProfile("vulkan", ["VK_KHR_maintenance7"], ImpliesSets = ["VK_VERSION_1_1"])] - public PhysicalDeviceLayeredApiPropertiesKhrDeviceName DeviceName; + public PhysicalDeviceLayeredApiPropertiesKHRDeviceName DeviceName; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKhrDeviceName.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKHRDeviceName.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKhrDeviceName.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKHRDeviceName.gen.cs index 865e576fb0..22f7aac188 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKhrDeviceName.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceLayeredApiPropertiesKHRDeviceName.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_deviceName_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceLayeredApiPropertiesKhrDeviceName +public partial struct PhysicalDeviceLayeredApiPropertiesKHRDeviceName { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXT.gen.cs index c90d993fb7..2ad35cf788 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXT.gen.cs @@ -43,7 +43,7 @@ public unsafe partial struct PhysicalDeviceMemoryBudgetPropertiesEXT "VK_EXT_memory_budget+VK_VERSION_1_1", ] )] - public PhysicalDeviceMemoryBudgetPropertiesExtHeapBudget HeapBudget; + public PhysicalDeviceMemoryBudgetPropertiesEXTHeapBudget HeapBudget; [NativeName("heapUsage")] [SupportedApiProfile( @@ -54,5 +54,5 @@ public unsafe partial struct PhysicalDeviceMemoryBudgetPropertiesEXT "VK_EXT_memory_budget+VK_VERSION_1_1", ] )] - public PhysicalDeviceMemoryBudgetPropertiesExtHeapUsage HeapUsage; + public PhysicalDeviceMemoryBudgetPropertiesEXTHeapUsage HeapUsage; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesExtHeapBudget.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXTHeapBudget.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesExtHeapBudget.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXTHeapBudget.gen.cs index 894f05aec0..ad7dd9f29d 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesExtHeapBudget.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXTHeapBudget.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_heapBudget_e__FixedBuffer")] [InlineArray(16)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceMemoryBudgetPropertiesExtHeapBudget +public partial struct PhysicalDeviceMemoryBudgetPropertiesEXTHeapBudget { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesExtHeapUsage.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXTHeapUsage.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesExtHeapUsage.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXTHeapUsage.gen.cs index d0a0f80ac0..0e4dba1860 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesExtHeapUsage.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMemoryBudgetPropertiesEXTHeapUsage.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_heapUsage_e__FixedBuffer")] [InlineArray(16)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceMemoryBudgetPropertiesExtHeapUsage +public partial struct PhysicalDeviceMemoryBudgetPropertiesEXTHeapUsage { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXT.gen.cs index cc7a986b13..e0de0c0c94 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXT.gen.cs @@ -42,7 +42,7 @@ public unsafe partial struct PhysicalDeviceMeshShaderPropertiesEXT ["VK_EXT_mesh_shader"], ImpliesSets = ["VK_EXT_mesh_shader+VK_KHR_spirv_1_4", "VK_EXT_mesh_shader+VK_VERSION_1_2"] )] - public PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupCount MaxTaskWorkGroupCount; + public PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupCount MaxTaskWorkGroupCount; [NativeName("maxTaskWorkGroupInvocations")] [SupportedApiProfile( @@ -58,7 +58,7 @@ public unsafe partial struct PhysicalDeviceMeshShaderPropertiesEXT ["VK_EXT_mesh_shader"], ImpliesSets = ["VK_EXT_mesh_shader+VK_KHR_spirv_1_4", "VK_EXT_mesh_shader+VK_VERSION_1_2"] )] - public PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupSize MaxTaskWorkGroupSize; + public PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupSize MaxTaskWorkGroupSize; [NativeName("maxTaskPayloadSize")] [SupportedApiProfile( @@ -98,7 +98,7 @@ public unsafe partial struct PhysicalDeviceMeshShaderPropertiesEXT ["VK_EXT_mesh_shader"], ImpliesSets = ["VK_EXT_mesh_shader+VK_KHR_spirv_1_4", "VK_EXT_mesh_shader+VK_VERSION_1_2"] )] - public PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupCount MaxMeshWorkGroupCount; + public PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupCount MaxMeshWorkGroupCount; [NativeName("maxMeshWorkGroupInvocations")] [SupportedApiProfile( @@ -114,7 +114,7 @@ public unsafe partial struct PhysicalDeviceMeshShaderPropertiesEXT ["VK_EXT_mesh_shader"], ImpliesSets = ["VK_EXT_mesh_shader+VK_KHR_spirv_1_4", "VK_EXT_mesh_shader+VK_VERSION_1_2"] )] - public PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupSize MaxMeshWorkGroupSize; + public PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupSize MaxMeshWorkGroupSize; [NativeName("maxMeshSharedMemorySize")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupCount.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupCount.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupCount.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupCount.gen.cs index d1f2310b36..977a31b1fa 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupCount.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupCount.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_maxMeshWorkGroupCount_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupCount +public partial struct PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupCount { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupSize.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupSize.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupSize.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupSize.gen.cs index 12961ac8a9..b30925a2a9 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupSize.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupSize.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_maxMeshWorkGroupSize_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceMeshShaderPropertiesExtMaxMeshWorkGroupSize +public partial struct PhysicalDeviceMeshShaderPropertiesEXTMaxMeshWorkGroupSize { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupCount.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupCount.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupCount.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupCount.gen.cs index a557c05273..e41d505b44 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupCount.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupCount.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_maxTaskWorkGroupCount_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupCount +public partial struct PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupCount { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupSize.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupSize.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupSize.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupSize.gen.cs index b06d3e34c6..2f4d299bac 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupSize.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupSize.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_maxTaskWorkGroupSize_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceMeshShaderPropertiesExtMaxTaskWorkGroupSize +public partial struct PhysicalDeviceMeshShaderPropertiesEXTMaxTaskWorkGroupSize { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesEXT.gen.cs index 5ab9bde64a..3d88b2a27e 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesEXT.gen.cs @@ -65,7 +65,7 @@ public unsafe partial struct PhysicalDeviceSampleLocationsPropertiesEXT "VK_EXT_sample_locations+VK_VERSION_1_1", ] )] - public PhysicalDeviceSampleLocationsPropertiesExtSampleLocationCoordinateRange SampleLocationCoordinateRange; + public PhysicalDeviceSampleLocationsPropertiesEXTSampleLocationCoordinateRange SampleLocationCoordinateRange; [NativeName("sampleLocationSubPixelBits")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesExtSampleLocationCoordinateRange.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesEXTSampleLocationCoordinateRange.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesExtSampleLocationCoordinateRange.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesEXTSampleLocationCoordinateRange.gen.cs index 3417743e63..4d369f33c8 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesExtSampleLocationCoordinateRange.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceSampleLocationsPropertiesEXTSampleLocationCoordinateRange.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_sampleLocationCoordinateRange_e__FixedBuffer")] [InlineArray(2)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceSampleLocationsPropertiesExtSampleLocationCoordinateRange +public partial struct PhysicalDeviceSampleLocationsPropertiesEXTSampleLocationCoordinateRange { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesEXT.gen.cs index 0b5368f576..d5a8af6c6a 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesEXT.gen.cs @@ -46,5 +46,5 @@ public unsafe partial struct PhysicalDeviceShaderModuleIdentifierPropertiesEXT "VK_VERSION_1_3", ] )] - public PhysicalDeviceShaderModuleIdentifierPropertiesExtShaderModuleIdentifierAlgorithmUuid ShaderModuleIdentifierAlgorithmUuid; + public PhysicalDeviceShaderModuleIdentifierPropertiesEXTShaderModuleIdentifierAlgorithmUuid ShaderModuleIdentifierAlgorithmUuid; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesExtShaderModuleIdentifierAlgorithmUuid.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesEXTShaderModuleIdentifierAlgorithmUuid.gen.cs similarity index 94% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesExtShaderModuleIdentifierAlgorithmUuid.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesEXTShaderModuleIdentifierAlgorithmUuid.gen.cs index a424c4fe84..f9eef0036e 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesExtShaderModuleIdentifierAlgorithmUuid.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderModuleIdentifierPropertiesEXTShaderModuleIdentifierAlgorithmUuid.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_shaderModuleIdentifierAlgorithmUUID_e__FixedBuffer")] [InlineArray(16)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceShaderModuleIdentifierPropertiesExtShaderModuleIdentifierAlgorithmUuid +public partial struct PhysicalDeviceShaderModuleIdentifierPropertiesEXTShaderModuleIdentifierAlgorithmUuid { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesEXT.gen.cs index fae13ddf43..69948c0476 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesEXT.gen.cs @@ -46,7 +46,7 @@ public unsafe partial struct PhysicalDeviceShaderObjectPropertiesEXT "VK_VERSION_1_3", ] )] - public PhysicalDeviceShaderObjectPropertiesExtShaderBinaryUuid ShaderBinaryUuid; + public PhysicalDeviceShaderObjectPropertiesEXTShaderBinaryUuid ShaderBinaryUuid; [NativeName("shaderBinaryVersion")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesExtShaderBinaryUuid.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesEXTShaderBinaryUuid.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesExtShaderBinaryUuid.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesEXTShaderBinaryUuid.gen.cs index d5d7775d49..158faa64c8 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesExtShaderBinaryUuid.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PhysicalDeviceShaderObjectPropertiesEXTShaderBinaryUuid.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_shaderBinaryUUID_e__FixedBuffer")] [InlineArray(16)] [SupportedApiProfile("vulkan")] -public partial struct PhysicalDeviceShaderObjectPropertiesExtShaderBinaryUuid +public partial struct PhysicalDeviceShaderObjectPropertiesEXTShaderBinaryUuid { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKHR.gen.cs index 1b625fb2ad..8277e212c0 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKHR.gen.cs @@ -54,5 +54,5 @@ public unsafe partial struct PipelineBinaryKeyKHR "VK_KHR_pipeline_binary+VK_VERSION_1_4", ] )] - public PipelineBinaryKeyKhrKey Key; + public PipelineBinaryKeyKHRKey Key; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKhrKey.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKHRKey.gen.cs similarity index 92% rename from sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKhrKey.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKHRKey.gen.cs index 2ebcc9e12b..64cc2768fe 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKhrKey.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineBinaryKeyKHRKey.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_key_e__FixedBuffer")] [InlineArray(32)] [SupportedApiProfile("vulkan")] -public partial struct PipelineBinaryKeyKhrKey +public partial struct PipelineBinaryKeyKHRKey { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQCOM.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQCOM.gen.cs index 4fd572d78c..a11b1850c3 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQCOM.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQCOM.gen.cs @@ -49,5 +49,5 @@ public partial struct PipelineCacheHeaderVersionDataGraphQCOM ["VK_QCOM_data_graph_model"], ImpliesSets = ["VK_ARM_data_graph"] )] - public PipelineCacheHeaderVersionDataGraphQcomToolchainVersion ToolchainVersion; + public PipelineCacheHeaderVersionDataGraphQCOMToolchainVersion ToolchainVersion; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQcomToolchainVersion.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQCOMToolchainVersion.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQcomToolchainVersion.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQCOMToolchainVersion.gen.cs index 6b3d5605f2..deb955425d 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQcomToolchainVersion.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineCacheHeaderVersionDataGraphQCOMToolchainVersion.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_toolchainVersion_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct PipelineCacheHeaderVersionDataGraphQcomToolchainVersion +public partial struct PipelineCacheHeaderVersionDataGraphQCOMToolchainVersion { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHR.gen.cs index 185d3d494a..2bacc42a67 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHR.gen.cs @@ -42,7 +42,7 @@ public unsafe partial struct PipelineExecutableInternalRepresentationKHR "VK_KHR_pipeline_executable_properties+VK_VERSION_1_1", ] )] - public PipelineExecutableInternalRepresentationKhrName Name; + public PipelineExecutableInternalRepresentationKHRName Name; [NativeName("description")] [SupportedApiProfile( @@ -53,7 +53,7 @@ public unsafe partial struct PipelineExecutableInternalRepresentationKHR "VK_KHR_pipeline_executable_properties+VK_VERSION_1_1", ] )] - public PipelineExecutableInternalRepresentationKhrDescription Description; + public PipelineExecutableInternalRepresentationKHRDescription Description; [NativeName("isText")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKhrDescription.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHRDescription.gen.cs similarity index 88% rename from sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKhrDescription.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHRDescription.gen.cs index 312e53184c..c67b997886 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKhrDescription.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHRDescription.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_description_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PipelineExecutableInternalRepresentationKhrDescription +public partial struct PipelineExecutableInternalRepresentationKHRDescription { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKhrName.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHRName.gen.cs similarity index 89% rename from sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKhrName.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHRName.gen.cs index 0349deb036..b6a86fbd66 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKhrName.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableInternalRepresentationKHRName.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_name_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PipelineExecutableInternalRepresentationKhrName +public partial struct PipelineExecutableInternalRepresentationKHRName { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHR.gen.cs index f3df15140f..39c513e0de 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHR.gen.cs @@ -54,7 +54,7 @@ public unsafe partial struct PipelineExecutablePropertiesKHR "VK_KHR_pipeline_executable_properties+VK_VERSION_1_1", ] )] - public PipelineExecutablePropertiesKhrName Name; + public PipelineExecutablePropertiesKHRName Name; [NativeName("description")] [SupportedApiProfile( @@ -65,7 +65,7 @@ public unsafe partial struct PipelineExecutablePropertiesKHR "VK_KHR_pipeline_executable_properties+VK_VERSION_1_1", ] )] - public PipelineExecutablePropertiesKhrDescription Description; + public PipelineExecutablePropertiesKHRDescription Description; [NativeName("subgroupSize")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKhrDescription.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHRDescription.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKhrDescription.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHRDescription.gen.cs index 98a785eccc..5087c7a96f 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKhrDescription.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHRDescription.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_description_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PipelineExecutablePropertiesKhrDescription +public partial struct PipelineExecutablePropertiesKHRDescription { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKhrName.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHRName.gen.cs similarity index 91% rename from sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKhrName.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHRName.gen.cs index 2ef8155c5c..34610b935b 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKhrName.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutablePropertiesKHRName.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_name_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PipelineExecutablePropertiesKhrName +public partial struct PipelineExecutablePropertiesKHRName { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHR.gen.cs index afd8dd8105..68684fac74 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHR.gen.cs @@ -43,7 +43,7 @@ public unsafe partial struct PipelineExecutableStatisticKHR "VK_KHR_pipeline_executable_properties+VK_VERSION_1_1", ] )] - public PipelineExecutableStatisticKhrName Name; + public PipelineExecutableStatisticKHRName Name; [NativeName("description")] [SupportedApiProfile( @@ -54,7 +54,7 @@ public unsafe partial struct PipelineExecutableStatisticKHR "VK_KHR_pipeline_executable_properties+VK_VERSION_1_1", ] )] - public PipelineExecutableStatisticKhrDescription Description; + public PipelineExecutableStatisticKHRDescription Description; [NativeName("format")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKhrDescription.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHRDescription.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKhrDescription.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHRDescription.gen.cs index f0ac80cbde..415856170c 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKhrDescription.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHRDescription.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_description_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PipelineExecutableStatisticKhrDescription +public partial struct PipelineExecutableStatisticKHRDescription { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKhrName.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHRName.gen.cs similarity index 91% rename from sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKhrName.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHRName.gen.cs index a375d53881..83ad7e8b27 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKhrName.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineExecutableStatisticKHRName.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_name_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PipelineExecutableStatisticKhrName +public partial struct PipelineExecutableStatisticKHRName { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKHR.gen.cs index 6bbf687e7a..501fbdc92e 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKHR.gen.cs @@ -58,5 +58,5 @@ public unsafe partial struct PipelineFragmentShadingRateStateCreateInfoKHR "VK_VERSION_1_2", ] )] - public PipelineFragmentShadingRateStateCreateInfoKhrCombinerOps CombinerOps; + public PipelineFragmentShadingRateStateCreateInfoKHRCombinerOps CombinerOps; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKhrCombinerOps.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKHRCombinerOps.gen.cs similarity index 97% rename from sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKhrCombinerOps.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKHRCombinerOps.gen.cs index 610ce41098..09d0f5a570 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKhrCombinerOps.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelineFragmentShadingRateStateCreateInfoKHRCombinerOps.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_combinerOps_e__FixedBuffer")] [InlineArray(2)] [SupportedApiProfile("vulkan")] -public partial struct PipelineFragmentShadingRateStateCreateInfoKhrCombinerOps +public partial struct PipelineFragmentShadingRateStateCreateInfoKHRCombinerOps { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierEXT.gen.cs index 3399de1e61..033a8f07e2 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierEXT.gen.cs @@ -42,5 +42,5 @@ public unsafe partial struct PipelinePropertiesIdentifierEXT "VK_EXT_pipeline_properties+VK_VERSION_1_1", ] )] - public PipelinePropertiesIdentifierExtPipelineIdentifier PipelineIdentifier; + public PipelinePropertiesIdentifierEXTPipelineIdentifier PipelineIdentifier; } diff --git a/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierExtPipelineIdentifier.gen.cs b/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierEXTPipelineIdentifier.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierExtPipelineIdentifier.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierEXTPipelineIdentifier.gen.cs index 5ea1bbef40..094bcb22ea 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierExtPipelineIdentifier.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/PipelinePropertiesIdentifierEXTPipelineIdentifier.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_pipelineIdentifier_e__FixedBuffer")] [InlineArray(16)] [SupportedApiProfile("vulkan")] -public partial struct PipelinePropertiesIdentifierExtPipelineIdentifier +public partial struct PipelinePropertiesIdentifierEXTPipelineIdentifier { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoEXT.gen.cs index e438d100dc..0b5bac773a 100644 --- a/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoEXT.gen.cs @@ -31,7 +31,7 @@ public partial struct RenderPassSubpassFeedbackInfoEXT "VK_EXT_subpass_merge_feedback+VK_VERSION_1_1", ] )] - public RenderPassSubpassFeedbackInfoExtDescription Description; + public RenderPassSubpassFeedbackInfoEXTDescription Description; [NativeName("postMergeIndex")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrDescription.gen.cs b/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoEXTDescription.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrDescription.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoEXTDescription.gen.cs index e3dfc1c0dd..524f869655 100644 --- a/sources/Vulkan/Vulkan/Vulkan/PerformanceCounterDescriptionKhrDescription.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/RenderPassSubpassFeedbackInfoEXTDescription.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_description_e__FixedBuffer")] [InlineArray(256)] [SupportedApiProfile("vulkan")] -public partial struct PerformanceCounterDescriptionKhrDescription +public partial struct RenderPassSubpassFeedbackInfoEXTDescription { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierEXT.gen.cs b/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierEXT.gen.cs index 03390913c3..fd46feafdb 100644 --- a/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierEXT.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierEXT.gen.cs @@ -58,5 +58,5 @@ public unsafe partial struct ShaderModuleIdentifierEXT "VK_VERSION_1_3", ] )] - public ShaderModuleIdentifierExtIdentifier Identifier; + public ShaderModuleIdentifierEXTIdentifier Identifier; } diff --git a/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierExtIdentifier.gen.cs b/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierEXTIdentifier.gen.cs similarity index 91% rename from sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierExtIdentifier.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierEXTIdentifier.gen.cs index 0bdc1fbe07..bd65d09623 100644 --- a/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierExtIdentifier.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/ShaderModuleIdentifierEXTIdentifier.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_identifier_e__FixedBuffer")] [InlineArray(32)] [SupportedApiProfile("vulkan")] -public partial struct ShaderModuleIdentifierExtIdentifier +public partial struct ShaderModuleIdentifierEXTIdentifier { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAMD.gen.cs b/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAMD.gen.cs index ff42a5f68d..90b1d3d7e1 100644 --- a/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAMD.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAMD.gen.cs @@ -38,5 +38,5 @@ public partial struct ShaderStatisticsInfoAMD [NativeName("computeWorkGroupSize")] [SupportedApiProfile("vulkan", ["VK_AMD_shader_info"])] - public ShaderStatisticsInfoAmdComputeWorkGroupSize ComputeWorkGroupSize; + public ShaderStatisticsInfoAMDComputeWorkGroupSize ComputeWorkGroupSize; } diff --git a/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAmdComputeWorkGroupSize.gen.cs b/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAMDComputeWorkGroupSize.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAmdComputeWorkGroupSize.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAMDComputeWorkGroupSize.gen.cs index 27cb1d8d62..bd4f621b25 100644 --- a/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAmdComputeWorkGroupSize.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/ShaderStatisticsInfoAMDComputeWorkGroupSize.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_computeWorkGroupSize_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct ShaderStatisticsInfoAmdComputeWorkGroupSize +public partial struct ShaderStatisticsInfoAMDComputeWorkGroupSize { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKHR.gen.cs index f4738cc432..d607fcd235 100644 --- a/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKHR.gen.cs @@ -21,5 +21,5 @@ public partial struct TransformMatrixKHR "VK_KHR_deferred_host_operations+VK_VERSION_1_2", ] )] - public TransformMatrixKhrMatrix Matrix; + public TransformMatrixKHRMatrix Matrix; } diff --git a/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKhrMatrix.gen.cs b/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKHRMatrix.gen.cs similarity index 92% rename from sources/Vulkan/Vulkan/Vulkan/TransformMatrixKhrMatrix.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/TransformMatrixKHRMatrix.gen.cs index 4e4539a9a0..50e6bcdcfc 100644 --- a/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKhrMatrix.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/TransformMatrixKHRMatrix.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_matrix_e__FixedBuffer")] [InlineArray(3 * 4)] [SupportedApiProfile("vulkan")] -public partial struct TransformMatrixKhrMatrix +public partial struct TransformMatrixKHRMatrix { [NativeName("e0_0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKHR.gen.cs index 5a0f43fb19..90fbb40509 100644 --- a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKHR.gen.cs @@ -42,7 +42,7 @@ public unsafe partial struct VideoDecodeAv1PictureInfoKHR ["VK_KHR_video_decode_av1"], ImpliesSets = ["VK_KHR_video_decode_queue"] )] - public VideoDecodeAv1PictureInfoKhrReferenceNameSlotIndices ReferenceNameSlotIndices; + public VideoDecodeAv1PictureInfoKHRReferenceNameSlotIndices ReferenceNameSlotIndices; [NativeName("frameHeaderOffset")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKhrReferenceNameSlotIndices.gen.cs b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKHRReferenceNameSlotIndices.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKhrReferenceNameSlotIndices.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKHRReferenceNameSlotIndices.gen.cs index 2366c0fb58..b2393cbd5f 100644 --- a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKhrReferenceNameSlotIndices.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeAv1PictureInfoKHRReferenceNameSlotIndices.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_referenceNameSlotIndices_e__FixedBuffer")] [InlineArray(7)] [SupportedApiProfile("vulkan")] -public partial struct VideoDecodeAv1PictureInfoKhrReferenceNameSlotIndices +public partial struct VideoDecodeAv1PictureInfoKHRReferenceNameSlotIndices { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKHR.gen.cs index 5d182704e4..c6a7ff5ab9 100644 --- a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKHR.gen.cs @@ -41,7 +41,7 @@ public unsafe partial struct VideoDecodeVp9PictureInfoKHR ["VK_KHR_video_decode_vp9"], ImpliesSets = ["VK_KHR_video_decode_queue"] )] - public VideoDecodeVp9PictureInfoKhrReferenceNameSlotIndices ReferenceNameSlotIndices; + public VideoDecodeVp9PictureInfoKHRReferenceNameSlotIndices ReferenceNameSlotIndices; [NativeName("uncompressedHeaderOffset")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKhrReferenceNameSlotIndices.gen.cs b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKHRReferenceNameSlotIndices.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKhrReferenceNameSlotIndices.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKHRReferenceNameSlotIndices.gen.cs index 440db46db7..78b884b45f 100644 --- a/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKhrReferenceNameSlotIndices.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/VideoDecodeVp9PictureInfoKHRReferenceNameSlotIndices.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_referenceNameSlotIndices_e__FixedBuffer")] [InlineArray(3)] [SupportedApiProfile("vulkan")] -public partial struct VideoDecodeVp9PictureInfoKhrReferenceNameSlotIndices +public partial struct VideoDecodeVp9PictureInfoKHRReferenceNameSlotIndices { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKHR.gen.cs b/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKHR.gen.cs index dbf5460fb2..ef8754bab0 100644 --- a/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKHR.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKHR.gen.cs @@ -65,7 +65,7 @@ public unsafe partial struct VideoEncodeAv1PictureInfoKHR ["VK_KHR_video_encode_av1"], ImpliesSets = ["VK_KHR_video_encode_queue"] )] - public VideoEncodeAv1PictureInfoKhrReferenceNameSlotIndices ReferenceNameSlotIndices; + public VideoEncodeAv1PictureInfoKHRReferenceNameSlotIndices ReferenceNameSlotIndices; [NativeName("primaryReferenceCdfOnly")] [SupportedApiProfile( diff --git a/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKhrReferenceNameSlotIndices.gen.cs b/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKHRReferenceNameSlotIndices.gen.cs similarity index 90% rename from sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKhrReferenceNameSlotIndices.gen.cs rename to sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKHRReferenceNameSlotIndices.gen.cs index d166afde1d..10a02cf16c 100644 --- a/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKhrReferenceNameSlotIndices.gen.cs +++ b/sources/Vulkan/Vulkan/Vulkan/VideoEncodeAv1PictureInfoKHRReferenceNameSlotIndices.gen.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan; [NativeName("_referenceNameSlotIndices_e__FixedBuffer")] [InlineArray(7)] [SupportedApiProfile("vulkan")] -public partial struct VideoEncodeAv1PictureInfoKhrReferenceNameSlotIndices +public partial struct VideoEncodeAv1PictureInfoKHRReferenceNameSlotIndices { [NativeName("e0")] [SupportedApiProfile("vulkan")] diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.DoesNotIdentifyPrefix_WhenSingleName_WithNoHint.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.DoesNotIdentifyPrefix_WhenSingleName_WithNoHint.verified.txt new file mode 100644 index 0000000000..5b3fe30996 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.DoesNotIdentifyPrefix_WhenSingleName_WithNoHint.verified.txt @@ -0,0 +1,3 @@ +public enum VkPresentModeKHR +{ +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.DoesNotTrimTypeName_WhenNotMatchingHint_AndOnlyOneType.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.DoesNotIdentifyPrefix_WhenSingleName_WithNonMatchingHint.verified.txt similarity index 100% rename from tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.DoesNotTrimTypeName_WhenNotMatchingHint_AndOnlyOneType.verified.txt rename to tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.DoesNotIdentifyPrefix_WhenSingleName_WithNonMatchingHint.verified.txt diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesPrefix_WhenMatchingHint.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesPrefix_WhenMatchingHint.verified.txt new file mode 100644 index 0000000000..3e84535354 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesPrefix_WhenMatchingHint.verified.txt @@ -0,0 +1,4 @@ +[NameAffix("Prefix", "SharedPrefix", "Vk")] +public enum VkPresentModeKHR +{ +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix.verified.txt new file mode 100644 index 0000000000..fda9eee7f4 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix.verified.txt @@ -0,0 +1,7 @@ +public enum OcclusionQueryParameterNameNV +{ + [NameAffix("Prefix", "SharedPrefix", "GL_PIXEL_COUNT")] + GL_PIXEL_COUNT_NV = 34918, + [NameAffix("Prefix", "SharedPrefix", "GL_PIXEL_COUNT")] + GL_PIXEL_COUNT_AVAILABLE_NV = 34919 +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix2.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix2.verified.txt new file mode 100644 index 0000000000..e667f964d3 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix2.verified.txt @@ -0,0 +1,9 @@ +public enum VocalMorpherPhoneme +{ + [NameAffix("Prefix", "SharedPrefix", "AL_VOCAL_MORPHER_PHONEME")] + AL_VOCAL_MORPHER_PHONEME_A = 0, + [NameAffix("Prefix", "SharedPrefix", "AL_VOCAL_MORPHER_PHONEME")] + AL_VOCAL_MORPHER_PHONEME_E = 1, + [NameAffix("Prefix", "SharedPrefix", "AL_VOCAL_MORPHER_PHONEME")] + AL_VOCAL_MORPHER_PHONEME_I = 2 +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefixGlfw_hint=glfw.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefixGlfw_hint=glfw.verified.txt new file mode 100644 index 0000000000..80b5bf0e4f --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefixGlfw_hint=glfw.verified.txt @@ -0,0 +1,17 @@ +public struct Glfw; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWallocator; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWcursor; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWgamepadstate; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWgammaramp; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWimage; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWmonitor; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWvidmode; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWwindow; \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefixGlfw_hint=null.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefixGlfw_hint=null.verified.txt new file mode 100644 index 0000000000..80b5bf0e4f --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefixGlfw_hint=null.verified.txt @@ -0,0 +1,17 @@ +public struct Glfw; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWallocator; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWcursor; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWgamepadstate; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWgammaramp; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWimage; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWmonitor; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWvidmode; +[NameAffix("Prefix", "SharedPrefix", "GLFW")] +public struct GLFWwindow; \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_ForTypes.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_ForTypes.verified.txt new file mode 100644 index 0000000000..ae42e933ba --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_ForTypes.verified.txt @@ -0,0 +1,9 @@ +[NameAffix("Prefix", "SharedPrefix", "VkPresent")] +public enum VkPresentModeKHR +{ +} + +[NameAffix("Prefix", "SharedPrefix", "VkPresent")] +public enum VkPresentIdKHR +{ +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict.verified.txt new file mode 100644 index 0000000000..cf2cfb5ef8 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict.verified.txt @@ -0,0 +1,10 @@ +[NameAffix("Suffix", "KhronosVendor", "KHR")] +public enum VkPresentModeKHR +{ + [NameAffix("Prefix", "SharedPrefix", "VK_PRESENT_MODE_FIFO_LATEST")] + [NameAffix("Suffix", "KhronosVendor", "KHR")] + VK_PRESENT_MODE_FIFO_LATEST_READY_KHR = 1000361000, + [NameAffix("Prefix", "SharedPrefix", "VK_PRESENT_MODE_FIFO_LATEST")] + [NameAffix("Suffix", "KhronosVendor", "EXT")] + VK_PRESENT_MODE_FIFO_LATEST_READY_EXT = VK_PRESENT_MODE_FIFO_LATEST_READY_KHR +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_WhenSuffixesDeclared.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_WhenSuffixesDeclared.verified.txt new file mode 100644 index 0000000000..15ef517d5e --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.IdentifiesSharedPrefix_WhenSuffixesDeclared.verified.txt @@ -0,0 +1,9 @@ +public enum OcclusionQueryParameterNameNV +{ + [NameAffix("Prefix", "SharedPrefix", "GL_PIXEL")] + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_NV = 34918, + [NameAffix("Prefix", "SharedPrefix", "GL_PIXEL")] + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_AVAILABLE_NV = 34919 +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.MultipleGlobalPrefixHints.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.MultipleGlobalPrefixHints.verified.txt new file mode 100644 index 0000000000..72bc5da1a1 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.MultipleGlobalPrefixHints.verified.txt @@ -0,0 +1,5 @@ +public enum ContextFlagsEXT +{ + [NameAffix("Prefix", "SharedPrefix", "ALC")] + ALC_CONTEXT_DEBUG_BIT_EXT +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.PreserveKhronosNamespaceEnumPrefix.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.PreserveKhronosNamespaceEnumPrefix.verified.txt similarity index 100% rename from tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.PreserveKhronosNamespaceEnumPrefix.verified.txt rename to tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.PreserveKhronosNamespaceEnumPrefix.verified.txt diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionEvalTargetNV.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionEvalTargetNV.verified.txt new file mode 100644 index 0000000000..ce47f6c2b4 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionEvalTargetNV.verified.txt @@ -0,0 +1,7 @@ +public enum EvalTargetNV +{ + [NameAffix("Prefix", "SharedPrefix", "GL")] + GL_EVAL_2D_NV, + [NameAffix("Prefix", "SharedPrefix", "GL")] + GL_EVAL_TRIANGULAR_2D_NV +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionFragmentShaderColorModMaskATI.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionFragmentShaderColorModMaskATI.verified.txt new file mode 100644 index 0000000000..c705fa7e85 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionFragmentShaderColorModMaskATI.verified.txt @@ -0,0 +1,11 @@ +public enum FragmentShaderDestModMask +{ + [NameAffix("Prefix", "SharedPrefix", "GL")] + GL_2X_BIT_ATI, + [NameAffix("Prefix", "SharedPrefix", "GL")] + GL_COMP_BIT_ATI, + [NameAffix("Prefix", "SharedPrefix", "GL")] + GL_NEGATE_BIT_ATI, + [NameAffix("Prefix", "SharedPrefix", "GL")] + GL_BIAS_BIT_ATI +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionSingleMemberEnumUsesGlobalPrefixHint.verified.txt b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionSingleMemberEnumUsesGlobalPrefixHint.verified.txt new file mode 100644 index 0000000000..129f94dbeb --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.RegressionSingleMemberEnumUsesGlobalPrefixHint.verified.txt @@ -0,0 +1,5 @@ +public enum EvalMapsModeNV +{ + [NameAffix("Prefix", "SharedPrefix", "GL")] + GL_FILL_NV +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.cs b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.cs new file mode 100644 index 0000000000..c87e545903 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/IdentifySharedPrefixesTests.cs @@ -0,0 +1,610 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.CodeAnalysis; +using Silk.NET.SilkTouch.Mods; + +namespace Silk.NET.SilkTouch.UnitTests.Naming; + +public class IdentifySharedPrefixesTests +{ + static IdentifySharedPrefixesTests() + { + if (!VerifyDiffPlex.Initialized) + { + VerifyDiffPlex.Initialize(); + } + } + + [Test] + public async Task IdentifiesSharedPrefix() + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "OcclusionQueryParameterNameNV.gen.cs", + """ + public enum OcclusionQueryParameterNameNV + { + GL_PIXEL_COUNT_NV = 34918, + GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The prefix shared by the member names should be identified (GL_PIXEL_COUNT) + // The type itself should be left untouched + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task IdentifiesSharedPrefix2() + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "VocalMorpherPhoneme.gen.cs", + """ + public enum VocalMorpherPhoneme + { + AL_VOCAL_MORPHER_PHONEME_A = 0, + AL_VOCAL_MORPHER_PHONEME_E = 1, + AL_VOCAL_MORPHER_PHONEME_I = 2, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The prefix shared by the member names should be identified (AL_VOCAL_MORPHER_PHONEME) + // The type itself should be left untouched + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + [TestCase(null)] + [TestCase("glfw")] + public async Task IdentifiesSharedPrefixGlfw(string? hint) + { + // This is ported from the old NameTrimmerTests + var project = TestUtils + .CreateTestProject() + .AddDocument( + "VocalMorpherPhoneme.gen.cs", + """ + public struct Glfw; + public struct GLFWallocator; + public struct GLFWcursor; + public struct GLFWgamepadstate; + public struct GLFWgammaramp; + public struct GLFWimage; + public struct GLFWmonitor; + public struct GLFWvidmode; + public struct GLFWwindow; + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + { + GlobalPrefixHints = hint is null ? [] : [hint], + } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The hint should not affect the output because the shared prefix is shared by most of the names + // Glfw should not have a prefix + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task IdentifiesSharedPrefix_ForTypes() + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "Vk.gen.cs", + """ + public enum VkPresentModeKHR { } + public enum VkPresentIdKHR { } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The prefixes should be identified as "VkPresent", not "Vk" + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task IdentifiesSharedPrefix_WhenSuffixesDeclared() + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "OcclusionQueryParameterNameNV.gen.cs", + """ + public enum OcclusionQueryParameterNameNV + { + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_NV = 34918, + + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The declaration of the 2 NV member suffixes should make PrettifyNames trim less of the member name + // IdentifySharedPrefixes should only use the unaffixed name for prefix identification + // The shared prefix should be "GL_PIXEL" + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task HintShouldNotAffectSharedPrefixIdentification() + { + string result1; + string result2; + + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "OcclusionQueryParameterNameNV.gen.cs", + """ + public enum OcclusionQueryParameterNameNV + { + GL_PIXEL_COUNT_NV = 34918, + GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["gl"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + result1 = result!.NormalizeWhitespace().ToString(); + } + + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "OcclusionQueryParameterNameNV.gen.cs", + """ + public enum OcclusionQueryParameterNameNV + { + GL_PIXEL_COUNT_NV = 34918, + GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + result2 = result!.NormalizeWhitespace().ToString(); + } + + // The two results should match because member names share prefixes in both cases, regardless of what the hint is + // The NameAffix attributes are also required to cause the regression back when this test was first added + Assert.That(result1, Is.EqualTo(result2)); + } + + [Test] + public async Task HintShouldNotAffectSharedPrefixIdentification_WhenAffixesDeclared() + { + string result1; + string result2; + + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "OcclusionQueryParameterNameNV.gen.cs", + """ + public enum OcclusionQueryParameterNameNV + { + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_NV = 34918, + + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["gl"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + result1 = result!.NormalizeWhitespace().ToString(); + } + + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "OcclusionQueryParameterNameNV.gen.cs", + """ + public enum OcclusionQueryParameterNameNV + { + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_NV = 34918, + + [NameAffix("Suffix", "KhronosVendor", "NV")] + GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + result2 = result!.NormalizeWhitespace().ToString(); + } + + // The two results should match because member names share prefixes in both cases, regardless of what the hint is + // The NameAffix attributes are also required to cause the regression back when this test was first added + Assert.That(result1, Is.EqualTo(result2)); + } + + [Test] + public async Task IdentifiesSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict() + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "VkPresentModeKHR.gen.cs", + """ + [NameAffix("Suffix", "KhronosVendor", "KHR")] + public enum VkPresentModeKHR + { + [NameAffix("Suffix", "KhronosVendor", "KHR")] + VK_PRESENT_MODE_FIFO_LATEST_READY_KHR = 1000361000, + + [NameAffix("Suffix", "KhronosVendor", "EXT")] + VK_PRESENT_MODE_FIFO_LATEST_READY_EXT = VK_PRESENT_MODE_FIFO_LATEST_READY_KHR, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // This test should run without erroring + // This is to catch potential regressions + // where the names without affixes would conflict + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task IdentifiesPrefix_WhenMatchingHint() + { + var project = TestUtils + .CreateTestProject() + .AddDocument("VkPresentModeKHR.gen.cs", "public enum VkPresentModeKHR { }") + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["vk"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The type prefix should be identified as Vk + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task DoesNotIdentifyPrefix_WhenSingleName_WithNoHint() + { + var project = TestUtils + .CreateTestProject() + .AddDocument("VkPresentModeKHR.gen.cs", "public enum VkPresentModeKHR { }") + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // No prefix should be identified + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task DoesNotIdentifyPrefix_WhenSingleName_WithNonMatchingHint() + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "OcclusionQueryParameterNameNV.gen.cs", + "public enum OcclusionQueryParameterNameNV { }" + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["gl"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // No prefix should be identified + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task PreserveKhronosNamespaceEnumPrefix() + { + var project = TestUtils + .CreateTestProject() + .AddDocument( + "GLEnum.gen.cs", + """ + [NameAffix("Prefix", "KhronosNamespaceEnum", "GL")] + public enum GLEnum { } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["gl"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The presence of the NameAffix attribute should prevent the GL- prefix of GLEnum from being identified as a shared prefix + // This is because IdentifySharedPrefixes should only use the unaffixed name for prefix identification + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task RegressionFragmentShaderColorModMaskATI() + { + // This is ported from the old NameTrimmerTests + var project = TestUtils + .CreateTestProject() + .AddDocument( + "FragmentShaderDestModMask.gen.cs", + """ + public enum FragmentShaderDestModMask + { + GL_2X_BIT_ATI, + GL_COMP_BIT_ATI, + GL_NEGATE_BIT_ATI, + GL_BIAS_BIT_ATI, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["gl"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The identified prefix should be "GL" + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task RegressionEvalTargetNV() + { + // This is ported from the old NameTrimmerTests + var project = TestUtils + .CreateTestProject() + .AddDocument( + "EvalTargetNV.gen.cs", + """ + public enum EvalTargetNV + { + GL_EVAL_2D_NV, + GL_EVAL_TRIANGULAR_2D_NV, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["gl"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The identified prefix should be "GL" + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task RegressionSingleMemberEnumUsesGlobalPrefixHint() + { + // This is ported from the old NameTrimmerTests + var project = TestUtils + .CreateTestProject() + .AddDocument( + "EvalMapsModeNV.gen.cs", + """ + public enum EvalMapsModeNV + { + GL_FILL_NV, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["gl"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The identified prefix should be "GL" + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } + + [Test] + public async Task MultipleGlobalPrefixHints() + { + // This is ported from the old NameTrimmerTests + var project = TestUtils + .CreateTestProject() + .AddDocument( + "ContextFlagsEXT.gen.cs", + """ + public enum ContextFlagsEXT + { + ALC_CONTEXT_DEBUG_BIT_EXT, + } + """ + ) + .Project; + + var context = new DummyModContext() { SourceProject = project }; + + var identifySharedPrefixes = new IdentifySharedPrefixes( + new DummyOptions( + new IdentifySharedPrefixes.Configuration() { GlobalPrefixHints = ["alc", "al"] } + ) + ); + + await identifySharedPrefixes.ExecuteAsync(context); + + // The identified prefix should be "ALC" + var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); + await Verify(result!.NormalizeWhitespace().ToString()); + } +} diff --git a/tests/SilkTouch/SilkTouch/Naming/NamePrettifierTests.cs b/tests/SilkTouch/SilkTouch/Naming/NamePrettifierTests.cs index 206162a001..b60e81f769 100644 --- a/tests/SilkTouch/SilkTouch/Naming/NamePrettifierTests.cs +++ b/tests/SilkTouch/SilkTouch/Naming/NamePrettifierTests.cs @@ -71,17 +71,21 @@ public string AcronymsWithNumbers2(string input, int longAcronymThreshold = 0) = public string ConsecutiveAcronyms(string input, int longAcronymThreshold = 0) => new NamePrettifier(longAcronymThreshold).Prettify(input); + /// + /// C# identifiers cannot start with numbers, but no longer handles this + /// in favor of calling separately. + /// [Theory] - // C# identifiers cannot start with numbers - [TestCase("123", ExpectedResult = "X123")] - [TestCase("123Hello", ExpectedResult = "X123Hello")] + [TestCase("123", ExpectedResult = "123")] + [TestCase("123Hello", ExpectedResult = "123Hello")] public string StartsWithNumber(string input, int longAcronymThreshold = 0) => new NamePrettifier(longAcronymThreshold).Prettify(input); [Theory] // Add x between numbers to maintain separation - [TestCase("123_123_123", ExpectedResult = "X123x123x123")] + [TestCase("123_123_123", ExpectedResult = "123x123x123")] [TestCase("Hello123_123_123", ExpectedResult = "Hello123x123x123")] + [TestCase("Hello123X123X123", ExpectedResult = "Hello123x123x123")] public string ConsecutiveNumbers(string input, int longAcronymThreshold = 0) => new NamePrettifier(longAcronymThreshold).Prettify(input); @@ -171,4 +175,18 @@ public void Lowercase_AfterNumber_IsPartOf_NewWord() Assert.That(nameTransformer.Prettify("MONO16f"), Is.EqualTo("Mono16F")); } } + + [Test] + public void EmptyInput_IsAllowed() + { + var nameTransformer = new NamePrettifier(4); + nameTransformer.Prettify(""); + } + + [Test] + public void EmptyOutput_IsAllowed() + { + var nameTransformer = new NamePrettifier(4); + nameTransformer.Prettify("_"); + } } diff --git a/tests/SilkTouch/SilkTouch/Naming/NameSplitterTests.cs b/tests/SilkTouch/SilkTouch/Naming/NameSplitterTests.cs index 2bf02680a8..a227ab2cd9 100644 --- a/tests/SilkTouch/SilkTouch/Naming/NameSplitterTests.cs +++ b/tests/SilkTouch/SilkTouch/Naming/NameSplitterTests.cs @@ -12,7 +12,7 @@ public void SplitByCasing() { using (Assert.EnterMultipleScope()) { - Assert.That(NameSplitter.BreakIntoWords("HelloWorld"), Is.EqualTo(["Hello", "World"])); + Assert.That(NameSplitter.SplitIntoWords("HelloWorld"), Is.EqualTo(["Hello", "World"])); } } @@ -21,9 +21,9 @@ public void SplitBySeparator() { using (Assert.EnterMultipleScope()) { - Assert.That(NameSplitter.BreakIntoWords("Hello_World"), Is.EqualTo(["Hello", "World"])); + Assert.That(NameSplitter.SplitIntoWords("Hello_World"), Is.EqualTo(["Hello", "World"])); Assert.That( - NameSplitter.BreakIntoWords("_Hello_World_"), + NameSplitter.SplitIntoWords("_Hello_World_"), Is.EqualTo(["Hello", "World"]) ); } @@ -34,12 +34,12 @@ public void PreserveAcronym() { using (Assert.EnterMultipleScope()) { - Assert.That(NameSplitter.BreakIntoWords("HelloUI"), Is.EqualTo(["Hello", "UI"])); - Assert.That(NameSplitter.BreakIntoWords("HelloGUI"), Is.EqualTo(["Hello", "GUI"])); - Assert.That(NameSplitter.BreakIntoWords("GUIHello"), Is.EqualTo(["GUI", "Hello"])); - Assert.That(NameSplitter.BreakIntoWords("GUI_Hello"), Is.EqualTo(["GUI", "Hello"])); + Assert.That(NameSplitter.SplitIntoWords("HelloUI"), Is.EqualTo(["Hello", "UI"])); + Assert.That(NameSplitter.SplitIntoWords("HelloGUI"), Is.EqualTo(["Hello", "GUI"])); + Assert.That(NameSplitter.SplitIntoWords("GUIHello"), Is.EqualTo(["GUI", "Hello"])); + Assert.That(NameSplitter.SplitIntoWords("GUI_Hello"), Is.EqualTo(["GUI", "Hello"])); Assert.That( - NameSplitter.BreakIntoWords("ABC_XYZ_Hello"), + NameSplitter.SplitIntoWords("ABC_XYZ_Hello"), Is.EqualTo(["ABC", "XYZ", "Hello"]) ); } @@ -50,9 +50,10 @@ public void SplitByNumber() { using (Assert.EnterMultipleScope()) { - Assert.That(NameSplitter.BreakIntoWords("123"), Is.EqualTo(["123"])); - Assert.That(NameSplitter.BreakIntoWords("A123A"), Is.EqualTo(["A", "123", "A"])); - Assert.That(NameSplitter.BreakIntoWords("a123a"), Is.EqualTo(["a", "123", "a"])); + Assert.That(NameSplitter.SplitIntoWords("Image2D"), Is.EqualTo(["Image", "2", "D"])); + Assert.That(NameSplitter.SplitIntoWords("123"), Is.EqualTo(["123"])); + Assert.That(NameSplitter.SplitIntoWords("A123A"), Is.EqualTo(["A", "123", "A"])); + Assert.That(NameSplitter.SplitIntoWords("a123a"), Is.EqualTo(["a", "123", "a"])); } } @@ -61,8 +62,8 @@ public void SplitNumberOtherNumberPattern() { using (Assert.EnterMultipleScope()) { - Assert.That(NameSplitter.BreakIntoWords("8x8"), Is.EqualTo(["8", "x", "8"])); - Assert.That(NameSplitter.BreakIntoWords("8X8"), Is.EqualTo(["8", "X", "8"])); + Assert.That(NameSplitter.SplitIntoWords("8x8"), Is.EqualTo(["8", "x", "8"])); + Assert.That(NameSplitter.SplitIntoWords("8X8"), Is.EqualTo(["8", "X", "8"])); } } @@ -72,7 +73,7 @@ public void ComplexCases() using (Assert.EnterMultipleScope()) { Assert.That( - NameSplitter.BreakIntoWords("SpvImageFormatR32ui"), + NameSplitter.SplitIntoWords("SpvImageFormatR32ui"), Is.EqualTo(["Spv", "Image", "Format", "R", "32", "ui"]) ); } diff --git a/tests/SilkTouch/SilkTouch/Naming/NameTrimmerTests.cs b/tests/SilkTouch/SilkTouch/Naming/NameTrimmerTests.cs deleted file mode 100644 index c2dcdae2f8..0000000000 --- a/tests/SilkTouch/SilkTouch/Naming/NameTrimmerTests.cs +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Silk.NET.SilkTouch.Mods; -using Silk.NET.SilkTouch.Naming; - -namespace Silk.NET.SilkTouch.UnitTests.Naming; - -public class NameTrimmerTests : NameTrimmer -{ - [Test, TestCase(null), TestCase("glfw")] - public void SimpleGlfwTestDetermination(string? hint) - { - var test = new Dictionary - { - { "GLFWallocator", new CandidateNames("GLFWallocator", []) }, - { "GLFWgammaramp", new CandidateNames("GLFWgammaramp", []) }, - { "GLFWgamepadstate", new CandidateNames("GLFWgamepadstate", []) }, - { "GLFWvidmode", new CandidateNames("GLFWvidmode", []) }, - { "GLFWimage", new CandidateNames("GLFWimage", []) }, - { "Glfw", new CandidateNames("Glfw", []) }, - { "GLFWcursor", new CandidateNames("GLFWcursor", []) }, - { "GLFWmonitor", new CandidateNames("GLFWmonitor", []) }, - { "GLFWwindow", new CandidateNames("GLFWwindow", []) }, - }; - Assert.That( - GetPrefix(null, hint, test, null, null, false, true)?.Prefix, - Is.EqualTo("GLFW") - ); - Trim( - new NameTrimmerContext - { - Configuration = new PrettifyNames.Configuration - { - GlobalPrefixHints = hint is null ? null : [hint], - }, - Names = test, - JobKey = "GLFW", - } - ); - var expected = new Dictionary - { - { "GLFWallocator", "Allocator" }, - { "GLFWgammaramp", "Gammaramp" }, - { "GLFWgamepadstate", "Gamepadstate" }, - { "GLFWvidmode", "Vidmode" }, - { "GLFWimage", "Image" }, - { "Glfw", "Glfw" }, - { "GLFWcursor", "Cursor" }, - { "GLFWmonitor", "Monitor" }, - { "GLFWwindow", "Window" }, - }; - foreach (var (key, (trimmed, _)) in test) - { - Assert.That(new NamePrettifier(4).Prettify(trimmed), Is.EqualTo(expected[key])); - } - } - - [Test] - public void RegressionFragmentShaderColorModMaskATI() - { - var test = new Dictionary - { - { "GL_2X_BIT_ATI", new CandidateNames("GL_2X_BIT_ATI", []) }, - { "GL_COMP_BIT_ATI", new CandidateNames("GL_COMP_BIT_ATI", []) }, - { "GL_NEGATE_BIT_ATI", new CandidateNames("GL_NEGATE_BIT_ATI", []) }, - { "GL_BIAS_BIT_ATI", new CandidateNames("GL_BIAS_BIT_ATI", []) }, - }; - Trim( - new NameTrimmerContext - { - Container = "FragmentShaderColorModMaskATI", - Configuration = new PrettifyNames.Configuration { GlobalPrefixHints = ["gl"] }, - Names = test, - JobKey = "OpenGL", - } - ); - var expected = new Dictionary - { - { "GL_2X_BIT_ATI", "X2XBitAti" }, - { "GL_COMP_BIT_ATI", "CompBitAti" }, - { "GL_NEGATE_BIT_ATI", "NegateBitAti" }, - { "GL_BIAS_BIT_ATI", "BiasBitAti" }, - }; - foreach (var (key, (trimmed, _)) in test) - { - Assert.That(new NamePrettifier(4).Prettify(trimmed), Is.EqualTo(expected[key])); - } - } - - [Test] - public void RegressionEvalTargetNV() - { - var test = new Dictionary - { - { "GL_EVAL_2D_NV", new CandidateNames("GL_EVAL_2D_NV", []) }, - { "GL_EVAL_TRIANGULAR_2D_NV", new CandidateNames("GL_EVAL_TRIANGULAR_2D_NV", []) }, - }; - Trim( - new NameTrimmerContext - { - Container = "EvalTargetNV", - Configuration = new PrettifyNames.Configuration { GlobalPrefixHints = ["gl"] }, - Names = test, - JobKey = "OpenGL", - } - ); - var expected = new Dictionary - { - { "GL_EVAL_2D_NV", "Eval2DNv" }, - { "GL_EVAL_TRIANGULAR_2D_NV", "EvalTriangular2DNv" }, - }; - foreach (var (key, (trimmed, _)) in test) - { - Assert.That(new NamePrettifier(4).Prettify(trimmed), Is.EqualTo(expected[key])); - } - } - - [Test] - public void RegressionSingleMemberEnumUsesGlobalPrefixHint() - { - var names = new Dictionary - { - { "GL_FILL_NV", new CandidateNames("GL_FILL_NV", []) }, - }; - var ctx = new NameTrimmerContext - { - Configuration = new PrettifyNames.Configuration { GlobalPrefixHints = ["gl"] }, - Container = "EvalMapsModeNV", - JobKey = "OpenGL", - Names = names, - }; - var uut = new NameTrimmer(); - uut.Trim(ctx); - Assert.That(names["GL_FILL_NV"].Primary, Is.EqualTo("FILL_NV")); - } - - [Test] - public void MultipleGlobalPrefixHints() - { - var names = new Dictionary - { - { "ALC_CONTEXT_DEBUG_BIT_EXT", new CandidateNames("ALC_CONTEXT_DEBUG_BIT_EXT", []) }, - }; - var ctx = new NameTrimmerContext - { - Configuration = new PrettifyNames.Configuration { GlobalPrefixHints = ["alc", "al"] }, - Container = "ContextFlagsEXT", - JobKey = "OpenAL", - Names = names, - }; - var uut = new NameTrimmer(); - uut.Trim(ctx); - Assert.That( - names["ALC_CONTEXT_DEBUG_BIT_EXT"].Primary, - Is.EqualTo("CONTEXT_DEBUG_BIT_EXT") - ); - } -} diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.ConflictsAreResolved_ForMethodsAndConstants.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.ConflictsAreResolved_ForMethodsAndConstants.verified.txt new file mode 100644 index 0000000000..82cbc8b186 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.ConflictsAreResolved_ForMethodsAndConstants.verified.txt @@ -0,0 +1,7 @@ +public class Sdl +{ + public static delegate* MainValue => &Main; + + [NameAffix("Prefix", "SharedPrefix", "SDL")] + public static extern int Main(int argc, sbyte** argv); +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_IncorrectSecondary_ChosenAsFallback.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.FallbackIsChosenCorrectly.verified.txt similarity index 70% rename from tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_IncorrectSecondary_ChosenAsFallback.verified.txt rename to tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.FallbackIsChosenCorrectly.verified.txt index 1dfd9680df..2fcf850618 100644 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_IncorrectSecondary_ChosenAsFallback.verified.txt +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.FallbackIsChosenCorrectly.verified.txt @@ -1,21 +1,17 @@ public class AL { + [NameAffix("Prefix", "SharedPrefix", "al")] [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] [NameAffix("Suffix", "KhronosVendor", "SOFT")] public void GetBufferPtrDirectSOFT() { } + [NameAffix("Prefix", "SharedPrefix", "al")] [NameAffix("Suffix", "KhronosFunctionDataType", "v")] [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] [NameAffix("Suffix", "KhronosVendor", "SOFT")] public void GetBufferPtrvDirectSOFT() { } - - // This is to ensure that prefix identification doesn't trim too much - [NameAffix("Suffix", "KhronosFunctionDataType", "i")] - public void Filter() - { - } } \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.FallbackIsChosenCorrectly_ReversedPriority.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.FallbackIsChosenCorrectly_ReversedPriority.verified.txt new file mode 100644 index 0000000000..dbf9e98f30 --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.FallbackIsChosenCorrectly_ReversedPriority.verified.txt @@ -0,0 +1,17 @@ +public class AL +{ + [NameAffix("Prefix", "SharedPrefix", "al")] + [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + public void GetBufferPtrDirectSOFT() + { + } + + [NameAffix("Prefix", "SharedPrefix", "al")] + [NameAffix("Suffix", "KhronosFunctionDataType", "v")] + [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + public void alGetBufferPtrDirectSOFT() + { + } +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared.verified.txt index ecb0d71c12..8721f7cebd 100644 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared.verified.txt +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared.verified.txt @@ -1,15 +1,19 @@ public enum GLEnum { + [NameAffix("Prefix", "SharedPrefix", "GL")] [NameAffix("Suffix", "KhronosVendor", "EXT")] Rgb16EXT = 32852, + [NameAffix("Prefix", "SharedPrefix", "GL")] [NameAffix("Suffix", "KhronosVendor", "EXT")] Rgb16FEXT = 34843, } public enum ALEnum { + [NameAffix("Prefix", "SharedPrefix", "AL")] [NameAffix("Suffix", "KhronosVendor", "SOFT")] Mono16SOFT = 4353, + [NameAffix("Prefix", "SharedPrefix", "AL")] [NameAffix("Suffix", "KhronosVendor", "SOFT")] Mono32FSOFT = 65552, } \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_UnexpectedCasingChangesInFormatEnums.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_UnexpectedCasingChangesInFormatEnums.verified.txt index 9d50423d57..a7cb359827 100644 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_UnexpectedCasingChangesInFormatEnums.verified.txt +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_UnexpectedCasingChangesInFormatEnums.verified.txt @@ -1,7 +1,9 @@ public enum InternalFormat { + [NameAffix("Prefix", "SharedPrefix", "GL")] [NameAffix("Suffix", "KhronosVendor", "ARB")] Rgba32FARB = 34836, + [NameAffix("Prefix", "SharedPrefix", "GL")] [NameAffix("Suffix", "KhronosVendor", "ARB")] Rgb32FARB = 34837, } \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.SuccessfullyUsesReferencedAffixes.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.SuccessfullyUsesReferencedAffixes.verified.txt new file mode 100644 index 0000000000..df3e0cb7be --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.SuccessfullyUsesReferencedAffixes.verified.txt @@ -0,0 +1,14 @@ +[NameAffix("Suffix", "Test", "ShouldBeInOutputName")] +public struct GamepadBindingShouldBeInOutputName +{ +} + +[NameAffix("Prefix", "NestedStructParent", nameof(GamepadBindingShouldBeInOutputName))] +public struct GamepadBindingShouldBeInOutputNameInput +{ +} + +[NameAffix("Prefix", "NestedStructParent", nameof(GamepadBindingShouldBeInOutputNameInput))] +public struct GamepadBindingShouldBeInOutputNameInputAxis +{ +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.SuccessfullyUsesReferencedAffixes_FromParentScope.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.SuccessfullyUsesReferencedAffixes_FromParentScope.verified.txt new file mode 100644 index 0000000000..7b445817ef --- /dev/null +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.SuccessfullyUsesReferencedAffixes_FromParentScope.verified.txt @@ -0,0 +1,6 @@ +[NameAffix("Suffix", "Test", "Suffix")] +public struct ASuffix +{ + [NameAffix("Suffix", "Test", nameof(ASuffix))] + public static int BASuffix; +} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsPrefix_WhenMatchingHint.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsPrefix_WhenMatchingHint.verified.txt deleted file mode 100644 index f1b60dc396..0000000000 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsPrefix_WhenMatchingHint.verified.txt +++ /dev/null @@ -1,3 +0,0 @@ -public enum PresentModeKhr -{ -} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix.verified.txt deleted file mode 100644 index 9dae8fbf05..0000000000 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix.verified.txt +++ /dev/null @@ -1,5 +0,0 @@ -public enum OcclusionQueryParameterNameNV -{ - Nv = 34918, - AvailableNv = 34919, -} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix2.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix2.verified.txt deleted file mode 100644 index 268d9a10e9..0000000000 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix2.verified.txt +++ /dev/null @@ -1,6 +0,0 @@ -public enum VocalMorpherPhoneme -{ - A = 0, - E = 1, - I = 2, -} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_ForTypes.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_ForTypes.verified.txt deleted file mode 100644 index 584ba3824f..0000000000 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_ForTypes.verified.txt +++ /dev/null @@ -1,7 +0,0 @@ -public enum ModeKhr -{ -} - -public enum IdKhr -{ -} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_WhenAffixesDeclared.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_WhenAffixesDeclared.verified.txt deleted file mode 100644 index 5bffc42913..0000000000 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_WhenAffixesDeclared.verified.txt +++ /dev/null @@ -1,7 +0,0 @@ -public enum OcclusionQueryParameterNameNV -{ - [NameAffix("Suffix", "KhronosVendor", "NV")] - CountNV = 34918, - [NameAffix("Suffix", "KhronosVendor", "NV")] - CountAvailableNV = 34919, -} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict.verified.txt deleted file mode 100644 index b4cf1ecbe0..0000000000 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.TrimsSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict.verified.txt +++ /dev/null @@ -1,8 +0,0 @@ -[NameAffix("Suffix", "KhronosVendor", "KHR")] -public enum VkPresentModeKHR -{ - [NameAffix("Suffix", "KhronosVendor", "KHR")] - ReadyKHR = 1000361000, - [NameAffix("Suffix", "KhronosVendor", "EXT")] - ReadyEXT = ReadyKHR, -} \ No newline at end of file diff --git a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.cs b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.cs index d4576a8c84..6f3d94d8ef 100644 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.cs +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.cs @@ -4,7 +4,6 @@ using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging.Abstractions; using Silk.NET.SilkTouch.Mods; -using Silk.NET.SilkTouch.Naming; namespace Silk.NET.SilkTouch.UnitTests.Naming; @@ -19,17 +18,22 @@ static PrettifyNamesTests() } [Test] - public async Task TrimsSharedPrefix() + public async Task Regression_UnexpectedCasingChangesInFormatEnums() { var project = TestUtils .CreateTestProject() .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", + "InternalFormat.gen.cs", """ - public enum OcclusionQueryParameterNameNV + public enum InternalFormat { - GL_PIXEL_COUNT_NV = 34918, - GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + [NameAffix("Prefix", "SharedPrefix", "GL")] + [NameAffix("Suffix", "KhronosVendor", "ARB")] + GL_RGBA32F_ARB = 34836, + + [NameAffix("Prefix", "SharedPrefix", "GL")] + [NameAffix("Suffix", "KhronosVendor", "ARB")] + GL_RGB32F_ARB = 34837, } """ ) @@ -39,62 +43,62 @@ public enum OcclusionQueryParameterNameNV var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions( + new PrettifyNames.Configuration() + { + LongAcronymThreshold = 3, + Affixes = + { + { + "SharedPrefix", + new PrettifyNames.NameAffixConfiguration() { Remove = true } + }, + }, + } + ) ); await prettifyNames.ExecuteAsync(context); - // The prefix shared by the member names should be trimmed - // The type name should not be modified + // This is to catch a bug revealed by changing NameTrimmer to be executed after affix removal by NameAffixerEarlyTrimmer + // The underlying reason is actually unrelated and was an issue that existed long before + // NameUtilsTests.Prettify_IsNotAffectedBy_TrailingUnderscore tests for the underlying issue + // + // While the core issue is already covered by another test, + // this test is kept because the format enums tend to be a bit sensitive to codebase changes var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); } [Test] - public async Task TrimsSharedPrefix2() + public async Task InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared() { var project = TestUtils .CreateTestProject() .AddDocument( - "VocalMorpherPhoneme.gen.cs", + "Test.gen.cs", """ - public enum VocalMorpherPhoneme + public enum GLEnum { - AL_VOCAL_MORPHER_PHONEME_A = 0, - AL_VOCAL_MORPHER_PHONEME_E = 1, - AL_VOCAL_MORPHER_PHONEME_I = 2, - } - """ - ) - .Project; - - var context = new DummyModContext() { SourceProject = project }; - - var prettifyNames = new PrettifyNames( - NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] - ); + [NameAffix("Prefix", "SharedPrefix", "GL")] + [NameAffix("Suffix", "KhronosVendor", "EXT")] + GL_RGB16_EXT = 32852, - await prettifyNames.ExecuteAsync(context); + [NameAffix("Prefix", "SharedPrefix", "GL")] + [NameAffix("Suffix", "KhronosVendor", "EXT")] + GL_RGB16F_EXT = 34843, + } - // The prefix shared by the member names should be trimmed - // The type name should not be modified - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); - } + public enum ALEnum + { + [NameAffix("Prefix", "SharedPrefix", "AL")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + AL_MONO16_SOFT = 4353, - [Test] - public async Task TrimsSharedPrefix_ForTypes() - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "Vk.gen.cs", - """ - public enum VkPresentModeKHR { } - public enum VkPresentIdKHR { } + [NameAffix("Prefix", "SharedPrefix", "AL")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + AL_MONO32F_SOFT = 65552, + } """ ) .Project; @@ -103,32 +107,52 @@ public enum VkPresentIdKHR { } var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions( + new PrettifyNames.Configuration() + { + LongAcronymThreshold = 4, + Affixes = + { + { + "SharedPrefix", + new PrettifyNames.NameAffixConfiguration() { Remove = true } + }, + }, + } + ) ); await prettifyNames.ExecuteAsync(context); - // The type names should be trimmed as ModeKHR and IdKHR + // This is to catch an inconsistency related to how letters following numbers are handled + // In both cases, MONO should be prettified as Mono + // NameUtilsTests.Prettify_Capital_AfterNumber_DoesNotAffect_PreviousWord tests for the underlying issue + // + // Note that the NameAffix attributes do affect the output var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); } [Test] - public async Task TrimsSharedPrefix_WhenAffixesDeclared() + public async Task FallbackIsChosenCorrectly() { var project = TestUtils .CreateTestProject() .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", + "AL.gen.cs", """ - public enum OcclusionQueryParameterNameNV + public class AL { - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_NV = 34918, + [NameAffix("Prefix", "SharedPrefix", "al")] + [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + public void alGetBufferPtrDirectSOFT() { } - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + [NameAffix("Prefix", "SharedPrefix", "al")] + [NameAffix("Suffix", "KhronosFunctionDataType", "v")] + [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + public void alGetBufferPtrvDirectSOFT() { } } """ ) @@ -138,186 +162,66 @@ public enum OcclusionQueryParameterNameNV var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions( + new PrettifyNames.Configuration() + { + LongAcronymThreshold = 4, + Affixes = + { + { + "SharedPrefix", + new PrettifyNames.NameAffixConfiguration() + { + DiscriminatorPriority = 0, + IsDiscriminator = true, + } + }, + { + "KhronosFunctionDataType", + new PrettifyNames.NameAffixConfiguration() + { + DiscriminatorPriority = 1, + IsDiscriminator = true, + } + }, + }, + } + ) ); await prettifyNames.ExecuteAsync(context); - // The declaration of the 2 NV member suffixes should make PrettifyNames trim less of the member name - // This is because NameTrimmer only sees the name without the suffixes - // The type name should remain unchanged except for the removal of the NV suffix + // This is to catch a regression where choosing the shortest secondary available is not always correct + // The second method (with the -v suffix) should not have the shared prefix restored + // Eg: We don't want AlGetBufferPtr // - // Note: When this test was first added, the names were not being trimmed at all. - // The fix was to ensure NameTrimmer.GetTrimmingName trimmed the trailing underscore. + // The expected output is: + // GetBufferPtrDirectSOFT + // GetBufferPtrvDirectSOFT var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); } [Test] - public async Task HintShouldNotAffectSharedPrefixTrimming() - { - string result1; - string result2; - - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", - """ - public enum OcclusionQueryParameterNameNV - { - GL_PIXEL_COUNT_NV = 34918, - GL_PIXEL_COUNT_AVAILABLE_NV = 34919, - } - """ - ) - .Project; - - var context = new DummyModContext() { SourceProject = project }; - - var prettifyNames = new PrettifyNames( - NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() { GlobalPrefixHints = ["gl"] } - ), - [new DummyJobDependency([new NameTrimmer()])] - ); - - await prettifyNames.ExecuteAsync(context); - - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - result1 = result!.NormalizeWhitespace().ToString(); - } - - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", - """ - public enum OcclusionQueryParameterNameNV - { - GL_PIXEL_COUNT_NV = 34918, - GL_PIXEL_COUNT_AVAILABLE_NV = 34919, - } - """ - ) - .Project; - - var context = new DummyModContext() { SourceProject = project }; - - var prettifyNames = new PrettifyNames( - NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] - ); - - await prettifyNames.ExecuteAsync(context); - - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - result2 = result!.NormalizeWhitespace().ToString(); - } - - // The two results should match because member names share prefixes in both cases, regardless of what the hint is - // The NameAffix attributes are also required to cause the regression back when this test was first added - Assert.That(result1, Is.EqualTo(result2)); - } - - [Test] - public async Task HintShouldNotAffectSharedPrefixTrimming_WhenAffixesDeclared() - { - string result1; - string result2; - - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", - """ - public enum OcclusionQueryParameterNameNV - { - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_NV = 34918, - - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_AVAILABLE_NV = 34919, - } - """ - ) - .Project; - - var context = new DummyModContext() { SourceProject = project }; - - var prettifyNames = new PrettifyNames( - NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() { GlobalPrefixHints = ["gl"] } - ), - [new DummyJobDependency([new NameTrimmer()])] - ); - - await prettifyNames.ExecuteAsync(context); - - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - result1 = result!.NormalizeWhitespace().ToString(); - } - - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", - """ - public enum OcclusionQueryParameterNameNV - { - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_NV = 34918, - - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_AVAILABLE_NV = 34919, - } - """ - ) - .Project; - - var context = new DummyModContext() { SourceProject = project }; - - var prettifyNames = new PrettifyNames( - NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] - ); - - await prettifyNames.ExecuteAsync(context); - - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - result2 = result!.NormalizeWhitespace().ToString(); - } - - // The two results should match because member names share prefixes in both cases, regardless of what the hint is - // The NameAffix attributes are also required to cause the regression back when this test was first added - Assert.That(result1, Is.EqualTo(result2)); - } - - [Test] - public async Task TrimsSharedPrefix_WhenAffixesDeclared_AndNamesWithoutAffixesConflict() + public async Task FallbackIsChosenCorrectly_ReversedPriority() { var project = TestUtils .CreateTestProject() .AddDocument( - "VkPresentModeKHR.gen.cs", + "AL.gen.cs", """ - [NameAffix("Suffix", "KhronosVendor", "KHR")] - public enum VkPresentModeKHR + public class AL { - [NameAffix("Suffix", "KhronosVendor", "KHR")] - VK_PRESENT_MODE_FIFO_LATEST_READY_KHR = 1000361000, + [NameAffix("Prefix", "SharedPrefix", "al")] + [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + public void alGetBufferPtrDirectSOFT() { } - [NameAffix("Suffix", "KhronosVendor", "EXT")] - VK_PRESENT_MODE_FIFO_LATEST_READY_EXT = VK_PRESENT_MODE_FIFO_LATEST_READY_KHR, + [NameAffix("Prefix", "SharedPrefix", "al")] + [NameAffix("Suffix", "KhronosFunctionDataType", "v")] + [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + public void alGetBufferPtrvDirectSOFT() { } } """ ) @@ -327,52 +231,92 @@ public enum VkPresentModeKHR var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions( + new PrettifyNames.Configuration() + { + LongAcronymThreshold = 4, + Affixes = + { + { + "SharedPrefix", + new PrettifyNames.NameAffixConfiguration() + { + DiscriminatorPriority = 1, + IsDiscriminator = true, + } + }, + { + "KhronosFunctionDataType", + new PrettifyNames.NameAffixConfiguration() + { + DiscriminatorPriority = 0, + IsDiscriminator = true, + } + }, + }, + } + ) ); await prettifyNames.ExecuteAsync(context); - // This test should run without erroring - // This is to catch a regression where NameTrimmer would error - // since the names with the affixes removed would conflict + // This ensures that the config is respected + // + // The expected output is: + // GetBufferPtrDirectSOFT + // alGetBufferPtrDirectSOFT (affixes are currently not prettified, so "al" is correct) var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); } [Test] - public async Task TrimsPrefix_WhenMatchingHint() + public async Task SuccessfullyUsesReferencedAffixes() { var project = TestUtils .CreateTestProject() - .AddDocument("VkPresentModeKHR.gen.cs", "public enum VkPresentModeKHR { }") + .AddDocument( + "SDL.gen.cs", + """ + [NameAffix("Suffix", "Test", "ShouldBeInOutputName")] + public struct GamepadBinding { } + + [NameAffix("Prefix", "NestedStructParent", nameof(GamepadBinding))] + public struct GamepadBindingInput { } + + [NameAffix("Prefix", "NestedStructParent", nameof(GamepadBindingInput))] + public struct GamepadBindingInputAxis { } + """ + ) .Project; var context = new DummyModContext() { SourceProject = project }; var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() { GlobalPrefixHints = ["vk"] } - ), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions(new PrettifyNames.Configuration()) ); await prettifyNames.ExecuteAsync(context); - // The type name should be trimmed as PresentModeKHR + // All names should start with GamepadBindingShouldBeInOutputName var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); } [Test] - public async Task DoesNotTrimTypeName_WhenNotMatchingHint_AndOnlyOneType() + public void CycleInReferencedAffixes_Throws() { var project = TestUtils .CreateTestProject() .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", - "public enum OcclusionQueryParameterNameNV { }" + "Test.gen.cs", + """ + [NameAffix("Suffix", "Test", nameof(B))] + public struct A { } + + [NameAffix("Suffix", "Test", nameof(A))] + public struct B { } + """ ) .Project; @@ -380,35 +324,25 @@ public async Task DoesNotTrimTypeName_WhenNotMatchingHint_AndOnlyOneType() var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() { GlobalPrefixHints = ["gl"] } - ), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions(new PrettifyNames.Configuration()) ); - await prettifyNames.ExecuteAsync(context); - - // The type name should remain as OcclusionQueryParameterNameNV - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); + Assert.ThrowsAsync(async () => + { + await prettifyNames.ExecuteAsync(context); + }); } [Test] - public async Task Regression_UnexpectedCasingChangesInFormatEnums() + public void MissingReferencedAffix_Throws() { var project = TestUtils .CreateTestProject() .AddDocument( - "InternalFormat.gen.cs", + "Test.gen.cs", """ - public enum InternalFormat - { - [NameAffix("Suffix", "KhronosVendor", "ARB")] - GL_RGBA32F_ARB = 34836, - - [NameAffix("Suffix", "KhronosVendor", "ARB")] - GL_RGB32F_ARB = 34837, - } + [NameAffix("Suffix", "Test", nameof(B))] + public struct A { } """ ) .Project; @@ -417,48 +351,30 @@ public enum InternalFormat var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() { LongAcronymThreshold = 3 } - ), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions(new PrettifyNames.Configuration()) ); - await prettifyNames.ExecuteAsync(context); - - // This is to catch a bug revealed by changing NameTrimmer to be executed after affix removal by NameAffixerEarlyTrimmer - // The underlying reason is actually unrelated and was an issue that existed long before - // NameUtilsTests.Prettify_IsNotAffectedBy_TrailingUnderscore tests for the underlying issue - // - // While the core issue is already covered by another test, - // this test is kept because the format enums tend to be a bit sensitive to codebase changes - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); + Assert.ThrowsAsync(async () => + { + await prettifyNames.ExecuteAsync(context); + }); } [Test] - public async Task InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared() + public async Task SuccessfullyUsesReferencedAffixes_FromParentScope() { + // Note that at time of writing, no nested scopes are supported + // This means that the only valid scope is the global scope var project = TestUtils .CreateTestProject() .AddDocument( "Test.gen.cs", """ - public enum GLEnum - { - [NameAffix("Suffix", "KhronosVendor", "EXT")] - GL_RGB16_EXT = 32852, - - [NameAffix("Suffix", "KhronosVendor", "EXT")] - GL_RGB16F_EXT = 34843, - } - - public enum ALEnum + [NameAffix("Suffix", "Test", "Suffix")] + public struct A { - [NameAffix("Suffix", "KhronosVendor", "SOFT")] - AL_MONO16_SOFT = 4353, - - [NameAffix("Suffix", "KhronosVendor", "SOFT")] - AL_MONO32F_SOFT = 65552, + [NameAffix("Suffix", "Test", nameof(A))] + public static int B; } """ ) @@ -468,45 +384,33 @@ public enum ALEnum var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() { LongAcronymThreshold = 4 } - ), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions(new PrettifyNames.Configuration()) ); await prettifyNames.ExecuteAsync(context); - // This is to catch an inconsistency related to how letters following numbers are handled - // In both cases, MONO should be prettified as Mono - // NameUtilsTests.Prettify_Capital_AfterNumber_DoesNotAffect_PreviousWord tests for the underlying issue - // - // Note that the NameAffix attributes do affect the output + // A should become ASuffix + // B should become BASuffix var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); } [Test] - public async Task Regression_IncorrectSecondary_ChosenAsFallback() + public async Task ConflictsAreResolved_ForMethodsAndConstants() { + // This test focuses on an edge case where method conflicts might be resolved while + // ignoring the fact that a constant also wants to have the same output name var project = TestUtils .CreateTestProject() .AddDocument( - "AL.gen.cs", + "Sdl.gen.cs", """ - public class AL + public class Sdl { - [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] - [NameAffix("Suffix", "KhronosVendor", "SOFT")] - public void alGetBufferPtrDirectSOFT() { } - - [NameAffix("Suffix", "KhronosFunctionDataType", "v")] - [NameAffix("Suffix", "KhronosNonVendorSuffix", "Direct")] - [NameAffix("Suffix", "KhronosVendor", "SOFT")] - public void alGetBufferPtrvDirectSOFT() { } + public static delegate* main => &SDL_main; - // This is to ensure that prefix identification doesn't trim too much - [NameAffix("Suffix", "KhronosFunctionDataType", "i")] - public void alFilteri() { } + [NameAffix("Prefix", "SharedPrefix", "SDL")] + public static extern int SDL_main(int argc, sbyte** argv); } """ ) @@ -516,59 +420,31 @@ public void alFilteri() { } var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() + new DummyOptions(new PrettifyNames.Configuration()) + { + Value = { - LongAcronymThreshold = 4, - GlobalPrefixHints = ["al"], Affixes = { { - "KhronosFunctionDataType", - new PrettifyNames.NameAffixConfiguration() { IsDiscriminator = true } + "SharedPrefix", + new PrettifyNames.NameAffixConfiguration() + { + DiscriminatorPriority = 0, + IsDiscriminator = true, + } }, }, - } - ), - [new DummyJobDependency([new NameTrimmer()])] - ); - - await prettifyNames.ExecuteAsync(context); - - // This is to catch a regression where choosing the shortest secondary available is not always correct - // The second method (with the -v suffix) should not have the global prefix restored - // Eg: We don't want AlGetBufferPtr - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); - } - - [Test] - public async Task PreserveKhronosNamespaceEnumPrefix() - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "GLEnum.gen.cs", - """ - [NameAffix("Prefix", "KhronosNamespaceEnum", "GL")] - public enum GLEnum { } - """ - ) - .Project; - - var context = new DummyModContext() { SourceProject = project }; - - var prettifyNames = new PrettifyNames( - NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() { GlobalPrefixHints = ["gl"] } - ), - [new DummyJobDependency([new NameTrimmer()])] + }, + } ); await prettifyNames.ExecuteAsync(context); - // The presence of the NameAffix attribute should prevent the GL- prefix of GLEnum from being removed + // The two members should not be output as the same name + // Expected: + // Property is named "MainValue" + // Method is named "Main" var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); }