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..7377e8bc8e 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,27 @@ } ] }, + "IdentifySharedPrefixes": { + "GlobalPrefixHints": ["alc", "al"] + }, "PrettifyNames": { - "GlobalPrefixHints": ["alc", "al"], "NameOverrides": { "ALContext": "ALContext", "EFXEAXREVERBPROPERTIES": "EfxEaxReverbProperties", - "EFXEAXREVERBPROPERTIES_flReflectionsPan": "EfxEaxReverbPropertiesFlReflectionsPan", - "EFXEAXREVERBPROPERTIES_flLateReverbPan": "EfxEaxReverbPropertiesFlLateReverbPan", + "EFXEAXREVERBPROPERTIESflReflectionsPan": "EfxEaxReverbPropertiesFlReflectionsPan", + "EFXEAXREVERBPROPERTIESflLateReverbPan": "EfxEaxReverbPropertiesFlLateReverbPan", "ALCcontextHandle": "ContextHandle", "ALCdeviceHandle": "DeviceHandle", "ALBUFFERCALLBACKTYPESOFT": "BufferCallbackSOFT", - "ALBUFFERCALLBACKTYPESOFTDelegate": "BufferCallbackDelegateSOFT", + "ALBUFFERCALLBACKTYPESOFTDelegate": "BufferCallbackSOFTDelegate", "ALCEVENTPROCTYPESOFT": "ContextEventProcSOFT", - "ALCEVENTPROCTYPESOFTDelegate": "ContextEventProcDelegateSOFT", + "ALCEVENTPROCTYPESOFTDelegate": "ContextEventProcSOFTDelegate", "ALEVENTPROCSOFT": "EventProcSOFT", - "ALEVENTPROCSOFTDelegate": "EventProcDelegateSOFT", + "ALEVENTPROCSOFTDelegate": "EventProcSOFTDelegate", "ALDEBUGPROCEXT": "DebugProcEXT", - "ALDEBUGPROCEXTDelegate": "DebugProcDelegateEXT", + "ALDEBUGPROCEXTDelegate": "DebugProcEXTDelegate", "LPALFOLDBACKCALLBACK": "FoldbackCallback", - "LPALFOLDBACKCALLBACKDelegate": "FoldbackCallbackDelegate", - "EAXSetDirect": "EAXSetDirect", - "EAXGetDirect": "EAXGetDirect", - "EAXGetBufferModeDirect": "EAXGetBufferModeDirect", - "EAXSetBufferModeDirect": "EAXSetBufferModeDirect" + "LPALFOLDBACKCALLBACKDelegate": "FoldbackCallbackDelegate" }, "Affixes": { "HandleType": { @@ -336,6 +351,9 @@ }, "KhronosNonExclusiveVendor": { "Remove": true + }, + "SharedPrefix": { + "Remove": true } } }, @@ -351,8 +369,7 @@ "BenefitOfTheDoubtArrayTransformation": true }, "TransformHandles": { - "AssumeMissingTypesOpaque": true, - "UseDSL": true + "UseDsl": true }, "StripAttributes": { "Remove": [ @@ -370,6 +387,7 @@ "AddIncludes", "ClangScraper", "MarkNativeNames", + "ExtractHandles", "ExtractNestedTyping", "TransformHandles", "MixKhronosData", @@ -377,6 +395,7 @@ "InterceptNativeFunctions", "TransformFunctions", "TransformProperties", + "IdentifySharedPrefixes", "PrettifyNames", "TransformEnums", "AddVTables", @@ -423,15 +442,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 +470,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/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..ad20dfb096 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 . /// 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..0bb959b92e --- /dev/null +++ b/sources/SilkTouch/SilkTouch/Mods/IdentifySharedPrefixes.cs @@ -0,0 +1,732 @@ +// 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 (scope is not null && 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 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.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 is null, + 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 version of the name as it exists in source code. + /// The original name with affixes stripped. + private readonly record struct MemberName(string OriginalName, string UnaffixedName); + + /// The version of 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( + SyntaxList memberAttributeLists, + SyntaxToken memberIdentifier + ) + { + 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)); + } + + private void TryReportNonDeterminant( + SyntaxList memberAttributeLists, + SyntaxToken memberIdentifier + ) { } + + // ----- Types ----- + + public override void VisitClassDeclaration(ClassDeclarationSyntax node) + { + ReportName(node.AttributeLists, node.Identifier); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; + } + + public override void VisitStructDeclaration(StructDeclarationSyntax node) + { + ReportName(node.AttributeLists, node.Identifier); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; + } + + public override void VisitEnumDeclaration(EnumDeclarationSyntax node) + { + ReportName(node.AttributeLists, node.Identifier); + + var previousScope = _scope; + _scope = node; + foreach (var member in node.Members) + { + Visit(member); + } + _scope = previousScope; + } + + public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node) => + ReportName(node.AttributeLists, node.Identifier); + + // ----- Members ----- + + public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node) => + ReportName(node.AttributeLists, node.Identifier); + + // 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(node.AttributeLists, firstVariable.Identifier); + TryReportNonDeterminant(node.AttributeLists, firstVariable.Identifier); + } + + 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.AttributeLists, node.Identifier); + } + + 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.AttributeLists, node.Identifier); + } + } + + /// Scope -> (Member -> 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..e7a3ed86a7 100644 --- a/sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs +++ b/sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs @@ -12,36 +12,22 @@ 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. [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. @@ -52,11 +38,6 @@ IEnumerable> trimmerProviders /// public int LongAcronymThreshold { get; init; } = 2; - /// - /// Multiple candidate name prefixes that may apply across all of the bindings generated. - /// - public IReadOnlyList? GlobalPrefixHints { get; init; } - /// /// The configuration for each category of name affixes. /// The key specifies the category name. @@ -106,20 +87,14 @@ 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 Visitor(); foreach (var doc in ctx.SourceProject.Documents) { visitor.Visit(await doc.GetSyntaxRootAsync(ct)); @@ -128,64 +103,19 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) // 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) + // Process the names { - // Only prettify the trimmable names - foreach (var (name, (nonFunctions, functions)) in visitor.TrimmableTypes) + var nameAffixer = new PrettifyNamesAffixer(visitor.AffixTypes, cfg.Affixes); + var namePrettifier = new NamePrettifier(cfg.LongAcronymThreshold); + + // Define name processors + var nameProcessors = new INameProcessor[] { - 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 - { - // 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(); + new StripAffixesProcessor(nameAffixer), + new PrettifyProcessor(namePrettifier), + new ReapplyAffixesProcessor(nameAffixer), + new PrefixIfStartsWithNumberProcessor(), + }; // Create a type name dictionary to trim the type names. var typeNames = visitor.TrimmableTypes.ToDictionary( @@ -193,23 +123,11 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) 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 - ); - } - + ProcessNames( + new NameProcessorContext { Scope = "", Names = typeNames }, + nameProcessors, + cfg.NameOverrides + ); // Now rename everything within each type. foreach (var (typeName, (newTypeName, _)) in typeNames) { @@ -220,16 +138,10 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) 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 + ProcessNames( + new NameProcessorContext { Scope = typeName, Names = constNames }, + nameProcessors, + cfg.NameOverrides ); // Rename the functions. More often that not functions have different nomenclature to constants, so we @@ -245,16 +157,10 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) ); // Trim the functions. - Trim( - new NameTrimmerContext - { - Container = typeName, - Names = functionNames, - Configuration = cfg, - JobKey = ctx.JobKey, - NonDeterminant = visitor.NonDeterminant, - }, - trimmers, + ProcessNames( + new NameProcessorContext { Scope = typeName, Names = functionNames }, + nameProcessors, + cfg.NameOverrides, functionSyntax ); @@ -267,38 +173,6 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default) } } - // 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 - ), - [], - [] - ); - } - - foreach (var memberName in memberNames) - { - renamedType.NonFunctions[memberName] = ApplyPrettifyOnlyPipeline( - typeName, - memberName, - cfg.NameOverrides, - nameAffixer, - namePrettifier - ); - } - - newNames[typeName] = renamedType; - } - if (logger.IsEnabled(LogLevel.Debug)) { foreach (var (name, (newName, nonFunctions, functions)) in newNames) @@ -453,81 +327,23 @@ 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 - ) - { - // Check for overrides - foreach (var (nativeName, overriddenName) in nameOverrides) - { - if (nativeName.Contains('.')) - { - // 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; - } - } - else if (nativeName == name) - { - return overriddenName; - } - } - - // 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; - } - - private void Trim( - NameTrimmerContext context, - IEnumerable trimmers, + private void ProcessNames( + NameProcessorContext context, + IEnumerable nameProcessors, + Dictionary nameOverrides, // TODO: Move to a separate name processor Dictionary>? functionSyntax = null ) { // 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 namesToProcess = context.Names; + foreach (var (nativeName, overriddenName) in 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) + if (context.Scope is null) { continue; } @@ -537,7 +353,7 @@ private void Trim( var containerSpan = span[..span.IndexOf('.')]; if ( containerSpan.Equals("*", StringComparison.Ordinal) - || containerSpan.Equals(context.Container, StringComparison.Ordinal) + || containerSpan.Equals(context.Scope, StringComparison.Ordinal) ) { nameToAdd = span[(span.IndexOf('.') + 1)..].ToString(); @@ -548,21 +364,21 @@ private void Trim( } } - if (!namesToTrim.TryGetValue(nameToAdd, out var v)) + if (!namesToProcess.TryGetValue(nameToAdd, out var v)) { continue; } // 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) + // they are recombined following name processing. + if (namesToProcess == context.Names) { - namesToTrim = namesToTrim.ToDictionary(); + namesToProcess = namesToProcess.ToDictionary(); } - // Don't let the trimmers see the overridden native name. - namesToTrim.Remove(nameToAdd); + // Don't let the name processors see the overridden native name. + namesToProcess.Remove(nameToAdd); // Apply the name override to the dictionary we actually use. context.Names[nameToAdd] = new CandidateNames( @@ -571,16 +387,16 @@ private void Trim( ); } - // Run each trimmer - foreach (var trimmer in trimmers) + // Run each name processor + foreach (var nameProcessor in nameProcessors) { - trimmer.Trim(context with { Names = namesToTrim }); + nameProcessor.ProcessNames(context with { Names = namesToProcess }); } // Apply changes - if (namesToTrim != context.Names) + if (namesToProcess != context.Names) { - foreach (var (evalName, result) in namesToTrim) + foreach (var (evalName, result) in namesToProcess) { context.Names[evalName] = result; } @@ -887,12 +703,6 @@ private class Visitor : CSharpSyntaxWalker /// 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. @@ -900,15 +710,6 @@ private class Visitor : CSharpSyntaxWalker /// 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. /// @@ -1006,11 +807,6 @@ public override void VisitClassDeclaration(ClassDeclarationSyntax node) } var identifier = node.Identifier.ToString(); - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) - { - NonDeterminant.Add(identifier); - } - ReportTypeAffixData(identifier, node.AttributeLists); // Recurse into members. @@ -1042,11 +838,6 @@ public override void VisitStructDeclaration(StructDeclarationSyntax node) } var identifier = node.Identifier.ToString(); - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) - { - NonDeterminant.Add(identifier); - } - ReportTypeAffixData(identifier, node.AttributeLists); // Recurse into members @@ -1078,11 +869,6 @@ public override void VisitEnumDeclaration(EnumDeclarationSyntax node) } var identifier = node.Identifier.ToString(); - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) - { - NonDeterminant.Add(identifier); - } - ReportTypeAffixData(identifier, node.AttributeLists); // Recurse into members @@ -1113,11 +899,6 @@ public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node) return; } - if (node.AttributeLists.ContainsAttribute("Silk.NET.Core.Transformed")) - { - NonDeterminant.Add(identifier); - } - ReportTypeAffixData(identifier, node.AttributeLists); TrimmableTypes.Add(identifier, new TypeData([], [])); } @@ -1138,12 +919,6 @@ public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node 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(); @@ -1152,20 +927,7 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) var memberIdentifier = variable.Identifier.ToString(); ReportMemberAffixData(typeIdentifier, memberIdentifier, node.AttributeLists); - if (prettifyOnly) - { - if (!PrettifyOnlyTypes.TryGetValue(typeIdentifier, out var typeData)) - { - typeData = []; - PrettifyOnlyTypes.Add(typeIdentifier, typeData); - } - - typeData.Add(memberIdentifier); - } - else - { - _typeInProgress.Value.NonFunctions.Add(memberIdentifier); - } + _typeInProgress.Value.NonFunctions.Add(memberIdentifier); } } } @@ -1177,25 +939,8 @@ public override void VisitMethodDeclaration(MethodDeclarationSyntax node) var typeIdentifier = _typeInProgress!.Value.Type.Identifier.ToString(); var memberIdentifier = node.Identifier.ToString(); - 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)) - { - typeData = []; - PrettifyOnlyTypes.Add(typeIdentifier, typeData); - } - - typeData.Add(memberIdentifier); - } - else - { - // Trim + Prettify - ReportMemberAffixData(typeIdentifier, memberIdentifier, node.AttributeLists); - - _typeInProgress!.Value.Functions.Add(new FunctionData(memberIdentifier, node)); - } + ReportMemberAffixData(typeIdentifier, memberIdentifier, node.AttributeLists); + _typeInProgress!.Value.Functions.Add(new FunctionData(memberIdentifier, node)); } } @@ -1207,26 +952,7 @@ public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) 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) - { - if (!PrettifyOnlyTypes.TryGetValue(typeIdentifier, out var typeData)) - { - typeData = []; - PrettifyOnlyTypes.Add(typeIdentifier, typeData); - } - - typeData.Add(memberIdentifier); - } - else - { - _typeInProgress!.Value.NonFunctions.Add(memberIdentifier); - } + _typeInProgress!.Value.NonFunctions.Add(memberIdentifier); } } } @@ -1252,18 +978,18 @@ Dictionary config /// 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 . + /// Designed to be used by . /// /// 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 list of secondary names. /// The new primary name. public string RemoveAffixes( string primary, string? container, string originalName, - List? secondary + List secondary ) { var affixes = GetAffixes(container, originalName); @@ -1275,7 +1001,7 @@ public string RemoveAffixes( var stripped = NameAffixer.StripAffixes(primary, affixes); if (stripped != primary) { - secondary?.Add(primary); + secondary.Add(primary); } return stripped; @@ -1285,18 +1011,20 @@ public string RemoveAffixes( /// Applies affixes to the specified primary name and adds fallbacks to the secondary list if provided. /// /// - /// Designed to be used by either or . + /// Designed to be used by . /// /// 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 list of secondary names. + /// The context containing the current names for the current container. /// The new primary name. public string ApplyAffixes( string primary, string? container, string originalName, - List? secondary + List secondary, + NameProcessorContext? context // TODO: Handle this better. Exposing the entire context is excessive. ) { var affixes = GetAffixes(container, originalName); @@ -1351,10 +1079,6 @@ public string ApplyAffixes( hasProcessedNonDiscriminator = true; currentPriority = GetConfiguration(affix).DiscriminatorPriority; CreateName(primary, affixes.AsSpan()[..affixI]); - if (secondary == null) - { - return newPrimary!; - } } } @@ -1384,15 +1108,28 @@ void CreateName(string name, Span currentAffixes) foreach (var affix in currentAffixes) { + var affixValue = affix.Affix; + if ( + affix.IsReference + && context.HasValue + && context.Value.Names.TryGetValue( + affixValue, + out var referencedCandidateNames + ) + ) + { + affixValue = referencedCandidateNames.Primary; + } + if (!GetConfiguration(affix).Remove) { if (affix.Type == NameAffixType.Prefix) { - name = affix.Affix + name; + name = affixValue + name; } else { - name += affix.Affix; + name += affixValue; } } } @@ -1403,7 +1140,7 @@ void CreateName(string name, Span currentAffixes) } else { - secondary?.Add(name); + secondary.Add(name); } } } @@ -1414,7 +1151,7 @@ void CreateName(string name, Span currentAffixes) /// 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) + public NameAffix[] GetAffixes(string? container, string originalName) { TypeAffixData typeAffixData; if (container == null) @@ -1448,109 +1185,211 @@ private NameAffixConfiguration GetConfiguration(string category) => } /// - /// Removes identified affixes so that other trimmers can process the base name separately. - /// These affixes should be reapplied by . + /// Removes identified affixes so that other name processors can process the base name separately. + /// These affixes should be reapplied by . /// - private class NameAffixerEarlyTrimmer(PrettifyNamesAffixer affixer) : INameTrimmer + private class StripAffixesProcessor(PrettifyNamesAffixer affixer) : INameProcessor { - /// - public Version Version => new(0, 0, 0); - - /// - public int Order => (int)TrimmerOrder.NameAffixerEarlyTrimmer; - - public void Trim(NameTrimmerContext context) + public void ProcessNames(NameProcessorContext context) { - if (context.Container == null) - { - foreach (var (original, (primary, secondary)) in context.Names) - { - var secondaries = secondary; - var newPrimary = affixer.RemoveAffixes(primary, null, original, secondaries); - context.Names[original] = new CandidateNames(newPrimary, secondaries); - } - - return; - } - foreach (var (original, (primary, secondary)) in context.Names) { var secondaries = secondary; var newPrimary = affixer.RemoveAffixes( primary, - context.Container, + context.Scope, original, secondaries ); + context.Names[original] = new CandidateNames(newPrimary, secondaries); } } } + private class PrettifyProcessor(NamePrettifier namePrettifier) : INameProcessor + { + public void ProcessNames(NameProcessorContext context) + { + // Be lenient about caps for type names (e.g. GL) + var allowAllCaps = context.Scope == null; + + foreach (var (original, (primary, secondary)) in context.Names) + { + for (var i = 0; i < secondary.Count; i++) + { + secondary[i] = namePrettifier.Prettify(secondary[i], allowAllCaps); + } + + context.Names[original] = new CandidateNames( + namePrettifier.Prettify(primary, allowAllCaps), + secondary + ); + } + } + } + /// /// Reapplies and transforms identified affixes based on . /// - private class NameAffixerLateTrimmer(PrettifyNamesAffixer affixer) : INameTrimmer + private class ReapplyAffixesProcessor(PrettifyNamesAffixer affixer) : INameProcessor { - /// - public Version Version => new(0, 0, 0); - - /// - public int Order => (int)TrimmerOrder.NameAffixerLateTrimmer; - - public void Trim(NameTrimmerContext context) + public void ProcessNames(NameProcessorContext context) { - if (context.Container == null) + // Calculate processing order using topological sort + var processingOrderByKey = new List(); { - foreach (var (original, (primary, secondary)) in context.Names) + var ready = new Queue(); + var dependencyCountByKey = new Dictionary(); + var notifyDependantByKey = new Dictionary>(); + + // Build dependency graph + foreach (var key in context.Names.Keys) + { + var dependencyCount = 0; + + var affixes = affixer.GetAffixes(context.Scope, key); + foreach (var affix in affixes) + { + if (!affix.IsReference) + { + continue; + } + + // Add as dependency + if (!notifyDependantByKey.TryGetValue(affix.Affix, out var dependants)) + { + notifyDependantByKey[affix.Affix] = dependants = []; + } + + dependants.Add(key); + dependencyCount++; + } + + if (dependencyCount == 0) + { + // No dependencies + ready.Enqueue(key); + continue; + } + + // Store dependency count + dependencyCountByKey.Add(key, dependencyCount); + } + + // Output final order + while (ready.TryDequeue(out var key)) { - var secondaries = secondary; - var newPrimary = affixer.ApplyAffixes(primary, null, original, secondaries); - context.Names[original] = new CandidateNames(newPrimary, secondaries); + processingOrderByKey.Add(key); + if (notifyDependantByKey.TryGetValue(key, out var dependants)) + { + foreach (var dependant in dependants) + { + if ( + dependencyCountByKey.TryGetValue(dependant, out var dependencyCount) + ) + { + dependencyCount--; + if (dependencyCount == 0) + { + ready.Enqueue(dependant); + dependencyCountByKey.Remove(dependant); + continue; + } + + dependencyCountByKey[dependant] = dependencyCount; + } + } + } } - return; + // Check for unfulfilled dependencies + if (dependencyCountByKey.Count != 0) + { + // Check for missing dependencies + foreach (var key in dependencyCountByKey.Keys) + { + if (!context.Names.ContainsKey(key)) + { + // This is because we currently can only resolve names that are given by the NameProcessorContext + // Please update this message if this limitation changes + throw new InvalidOperationException( + $"A name affix for '{key}' references a name that does not exist or is part of a different name container. " + + $"Referencing names from other containers is currently not supported" + ); + } + } + + // Remaining must be a cycle + throw new InvalidOperationException( + $"Detected cycle in referenced affixes. Names that are part of the cycle: {string.Join(", ", dependencyCountByKey)}" + ); + } } - foreach (var (original, (primary, secondary)) in context.Names) + foreach (var original in processingOrderByKey) { + var (primary, secondary) = context.Names[original]; + var secondaries = secondary; var newPrimary = affixer.ApplyAffixes( primary, - context.Container, + context.Scope, original, - secondaries + secondaries, + context ); + context.Names[original] = new CandidateNames(newPrimary, secondaries); } } } - private class PrettifyNamesTrimmer(NamePrettifier namePrettifier) : INameTrimmer + private class PrefixIfStartsWithNumberProcessor : INameProcessor { - /// - public Version Version => new(0, 0, 0); - - /// - public int Order => (int)TrimmerOrder.PrettifyNamesTrimmer; - - public void Trim(NameTrimmerContext context) + public void ProcessNames(NameProcessorContext context) { foreach (var (original, (primary, secondary)) in context.Names) { - // Be lenient about caps for type names (e.g. GL) - var allowAllCaps = context.Container == null; - for (var i = 0; i < secondary.Count; i++) { - secondary[i] = namePrettifier.Prettify(secondary[i], allowAllCaps); + secondary[i] = NameUtils.PrefixIfStartsWithNumber(secondary[i]); } context.Names[original] = new CandidateNames( - namePrettifier.Prettify(primary, allowAllCaps), + NameUtils.PrefixIfStartsWithNumber(primary), secondary ); } } } + + /// + /// Represents a name processor. + /// + private interface INameProcessor + { + /// + /// Process and transform the names within the given container. + /// + public void ProcessNames(NameProcessorContext context); + } + + /// + /// State made available to implementations. + /// + private readonly struct NameProcessorContext + { + /// + /// Gets the name of the "container" (e.g. a type name) of the APIs in . + /// + public string Scope { 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; } + } } 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/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..3c9753a73b 100644 --- a/sources/SilkTouch/SilkTouch/Naming/NamePrettifier.cs +++ b/sources/SilkTouch/SilkTouch/Naming/NamePrettifier.cs @@ -31,12 +31,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 +45,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 +165,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.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_IncorrectSecondary_ChosenAsFallback.verified.txt b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_IncorrectSecondary_ChosenAsFallback.verified.txt index 1dfd9680df..2fcf850618 100644 --- a/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_IncorrectSecondary_ChosenAsFallback.verified.txt +++ b/tests/SilkTouch/SilkTouch/Naming/PrettifyNamesTests.Regression_IncorrectSecondary_ChosenAsFallback.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.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.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..20ed9ce30d 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,96 +43,61 @@ public enum OcclusionQueryParameterNameNV var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions(new PrettifyNames.Configuration()), - [new DummyJobDependency([new NameTrimmer()])] - ); - - await prettifyNames.ExecuteAsync(context); - - // 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()); - } - - [Test] - public async Task TrimsSharedPrefix2() - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "VocalMorpherPhoneme.gen.cs", - """ - public enum VocalMorpherPhoneme + new DummyOptions( + new PrettifyNames.Configuration() { - AL_VOCAL_MORPHER_PHONEME_A = 0, - AL_VOCAL_MORPHER_PHONEME_E = 1, - AL_VOCAL_MORPHER_PHONEME_I = 2, + LongAcronymThreshold = 3, + Affixes = + { + { + "SharedPrefix", + new PrettifyNames.NameAffixConfiguration() { Remove = true } + }, + }, } - """ ) - .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); - // 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 TrimsSharedPrefix_ForTypes() + public async Task InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared() { var project = TestUtils .CreateTestProject() .AddDocument( - "Vk.gen.cs", - """ - public enum VkPresentModeKHR { } - public enum VkPresentIdKHR { } + "Test.gen.cs", """ - ) - .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); + public enum GLEnum + { + [NameAffix("Prefix", "SharedPrefix", "GL")] + [NameAffix("Suffix", "KhronosVendor", "EXT")] + GL_RGB16_EXT = 32852, - // The type names should be trimmed as ModeKHR and IdKHR - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); - } + [NameAffix("Prefix", "SharedPrefix", "GL")] + [NameAffix("Suffix", "KhronosVendor", "EXT")] + GL_RGB16F_EXT = 34843, + } - [Test] - public async Task TrimsSharedPrefix_WhenAffixesDeclared() - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", - """ - public enum OcclusionQueryParameterNameNV + public enum ALEnum { - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_NV = 34918, + [NameAffix("Prefix", "SharedPrefix", "AL")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + AL_MONO16_SOFT = 4353, - [NameAffix("Suffix", "KhronosVendor", "NV")] - GL_PIXEL_COUNT_AVAILABLE_NV = 34919, + [NameAffix("Prefix", "SharedPrefix", "AL")] + [NameAffix("Suffix", "KhronosVendor", "SOFT")] + AL_MONO32F_SOFT = 65552, } """ ) @@ -138,186 +107,52 @@ 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() { Remove = 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 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: 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. + // 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 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 Regression_IncorrectSecondary_ChosenAsFallback() { 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() { } } """ ) @@ -325,90 +160,60 @@ public enum VkPresentModeKHR 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); - - // 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 - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); - } - - [Test] - public async Task TrimsPrefix_WhenMatchingHint() - { - var project = TestUtils - .CreateTestProject() - .AddDocument("VkPresentModeKHR.gen.cs", "public enum VkPresentModeKHR { }") - .Project; - - var context = new DummyModContext() { SourceProject = project }; - var prettifyNames = new PrettifyNames( NullLogger.Instance, new DummyOptions( - new PrettifyNames.Configuration() { GlobalPrefixHints = ["vk"] } - ), - [new DummyJobDependency([new NameTrimmer()])] - ); - - await prettifyNames.ExecuteAsync(context); - - // The type name should be trimmed as PresentModeKHR - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); - } - - [Test] - public async Task DoesNotTrimTypeName_WhenNotMatchingHint_AndOnlyOneType() - { - var project = TestUtils - .CreateTestProject() - .AddDocument( - "OcclusionQueryParameterNameNV.gen.cs", - "public enum OcclusionQueryParameterNameNV { }" + new PrettifyNames.Configuration() + { + LongAcronymThreshold = 4, + Affixes = + { + { + "SharedPrefix", + new PrettifyNames.NameAffixConfiguration() + { + DiscriminatorPriority = 0, + IsDiscriminator = true, + } + }, + { + "KhronosFunctionDataType", + new PrettifyNames.NameAffixConfiguration() + { + DiscriminatorPriority = 1, + IsDiscriminator = true, + } + }, + }, + } ) - .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 type name should remain as OcclusionQueryParameterNameNV + // 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 Regression_UnexpectedCasingChangesInFormatEnums() + public async Task SuccessfullyUsesReferencedAffixes() { var project = TestUtils .CreateTestProject() .AddDocument( - "InternalFormat.gen.cs", + "SDL.gen.cs", """ - public enum InternalFormat - { - [NameAffix("Suffix", "KhronosVendor", "ARB")] - GL_RGBA32F_ARB = 34836, + [NameAffix("Suffix", "Test", "ShouldBeInOutputName")] + public struct GamepadBinding { } - [NameAffix("Suffix", "KhronosVendor", "ARB")] - GL_RGB32F_ARB = 34837, - } + [NameAffix("Prefix", "NestedStructParent", nameof(GamepadBinding))] + public struct GamepadBindingInput { } + + [NameAffix("Prefix", "NestedStructParent", nameof(GamepadBindingInput))] + public struct GamepadBindingInputAxis { } """ ) .Project; @@ -417,49 +222,29 @@ 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 + // All names should start with GamepadBindingShouldBeInOutputName var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); await Verify(result!.NormalizeWhitespace().ToString()); } [Test] - public async Task InconsistentCasing_LettersFollowingNumbers_WhenAffixesDeclared() + public void CycleInReferencedAffixes_Throws() { 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", "KhronosVendor", "SOFT")] - AL_MONO16_SOFT = 4353, + [NameAffix("Suffix", "Test", nameof(B))] + public struct A { } - [NameAffix("Suffix", "KhronosVendor", "SOFT")] - AL_MONO32F_SOFT = 65552, - } + [NameAffix("Suffix", "Test", nameof(A))] + public struct B { } """ ) .Project; @@ -468,46 +253,25 @@ 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 - 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_IncorrectSecondary_ChosenAsFallback() + public void MissingReferencedAffix_Throws() { var project = TestUtils .CreateTestProject() .AddDocument( - "AL.gen.cs", + "Test.gen.cs", """ - public class AL - { - [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() { } - - // This is to ensure that prefix identification doesn't trim too much - [NameAffix("Suffix", "KhronosFunctionDataType", "i")] - public void alFilteri() { } - } + [NameAffix("Suffix", "Test", nameof(B))] + public struct A { } """ ) .Project; @@ -516,42 +280,29 @@ public void alFilteri() { } var prettifyNames = new PrettifyNames( NullLogger.Instance, - new DummyOptions( - new PrettifyNames.Configuration() - { - LongAcronymThreshold = 4, - GlobalPrefixHints = ["al"], - Affixes = - { - { - "KhronosFunctionDataType", - new PrettifyNames.NameAffixConfiguration() { IsDiscriminator = true } - }, - }, - } - ), - [new DummyJobDependency([new NameTrimmer()])] + new DummyOptions(new PrettifyNames.Configuration()) ); - 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()); + Assert.ThrowsAsync(async () => + { + await prettifyNames.ExecuteAsync(context); + }); } [Test] - public async Task PreserveKhronosNamespaceEnumPrefix() + public void ReferencedAffixExists_ButInDifferentContainer_Throws() { + // This test is here because referencing names in different containers is currently not supported var project = TestUtils .CreateTestProject() .AddDocument( - "GLEnum.gen.cs", + "Test.gen.cs", """ - [NameAffix("Prefix", "KhronosNamespaceEnum", "GL")] - public enum GLEnum { } + public struct A + { + [NameAffix("Suffix", "Test", nameof(A))] + public static int B; + } """ ) .Project; @@ -560,16 +311,12 @@ public enum GLEnum { } 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 presence of the NameAffix attribute should prevent the GL- prefix of GLEnum from being removed - var result = await context.SourceProject.Documents.First().GetSyntaxRootAsync(); - await Verify(result!.NormalizeWhitespace().ToString()); + Assert.ThrowsAsync(async () => + { + await prettifyNames.ExecuteAsync(context); + }); } }