diff --git a/README.md b/README.md index 14c38df..77b3825 100644 --- a/README.md +++ b/README.md @@ -15,28 +15,45 @@ How it works: Supported AssemblyDefinition locations: -------- -1. Assets folder -2. Embedded Packages - everything that is located in Packages/ folder of your project. +1. Project - everything that is located in `Assets/` folder of your project. +2. Embedded Packages - everything that is located in `Packages/` folder of your project. 3. Local Packages - everything that is located anywhere on your pc with specified path with `file:` prefix in manifest. -How to Install: ---------------- +> [!WARNING] +> **DON'T** put `.asmdef` with its `csc.rsp` at the root of the project (`Assets/`). +> Unity in that case will apply the specified C# version to everything, that may cause compile errors (e.g. `field` keyword is used as a name in some third party library). +> Place it in any subfolder (usually Scripts, but doesn't matter, just not at the root) + + > [!NOTE] -> OS support: Mac/Linux/Windows. +> OS support: Mac / Linux / Windows. > You can backup your editor just in case, but should be fine. > > Patch will modify the Editor installation, so all the projects that are using it will be affected (default for unity C# version will be used for compilation, but from newer (patched) dotnet sdk) +> +> Tested on target platforms: Mac / Windows / Linux / iOS / Android / WebGL +> +> Tested in IDEs: +> +> Rider `2025.1` with integration package `com.unity.ide.rider@3.0.36` +> +> VSCode `1.99.3` with integration package `com.unity.ide.visualstudio@2.0.23` + +How to Install: +--------------- 1. Add the package via git url ``https://github.com/kandreyc/unity-csharp-patch.git#v1.3.0`` 2. Ensure Unity Editor is closed. -3. Ensure latest stable dotnet sdk is installed. [Download Page](https://dotnet.microsoft.com/en-us/download) +3. Ensure latest dotnet sdk is installed. [Download Page](https://dotnet.microsoft.com/en-us/download) 4. Open terminal at folder ``EditorPatch~`` inside the added package. 5. Patch the editor (administrative privileges are required): ``` -$ dotnet UnityEditorPatch.dll apply --editor '/Applications/Unity/Hub/Editor/2022.3.21f1' +$ dotnet UnityEditorPatch.dll apply --editor '/Applications/Unity/Hub/Editor/2022.3.21f1' --allow-prerelease ``` where ``--editor`` - path to the unity editor +where ``--allow-prerelease`` - (optional) allows to use prerelease dotnet sdk + In case if you want to revert the patch: ``` $ dotnet UnityEditorPatch.dll revert --editor '/Applications/Unity/Hub/Editor/2022.3.21f1' @@ -58,10 +75,22 @@ where: Language Support ---------------- + +> [!NOTE] +> `preview` features support of .net 10 in Rider is still in development. +> Code will compile and work, but you may suffer from errors in IDE. +> Currently only VSCode supports all new features + C# | Feature | Support -|-|:-----: -preview | [The `field` keyword](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#the-field-keyword) | Yes -13 | [params collections](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#params-collections) | Yes +preview | [`field` keyword](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#the-field-keyword) | Yes +preview | [`partial` events and instance constructors](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#more-partial-members) | Yes +preview | [`nameof` unbound generic types support for](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#unbound-generic-types-and-nameof) | Yes +preview | [Extension members](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#extension-members) | Yes +preview | [Null conditional assignment](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#null-conditional-assignment) | Yes +preview | [Simple lambda parameters](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#simple-lambda-parameters-with-modifiers) | Yes +preview | [Implicit span conversions](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14#implicit-span-conversions) | Yes +13 | [`params` collections](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#params-collections) | Yes 13 | [New lock type and semantics](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#new-lock-object) | No 13 | [New escape sequence - \\e](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#new-escape-sequence) | Yes 13 | [Method group natural type improvements](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#method-group-natural-type) | Yes diff --git a/UnityCSharpPatch/Assets/Scene.unity b/UnityCSharpPatch/Assets/Scene.unity new file mode 100644 index 0000000..26b054b --- /dev/null +++ b/UnityCSharpPatch/Assets/Scene.unity @@ -0,0 +1,767 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &83502837 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 83502841} + - component: {fileID: 83502840} + - component: {fileID: 83502839} + - component: {fileID: 83502838} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &83502838 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 83502837} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &83502839 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 83502837} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1080, y: 1920} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!223 &83502840 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 83502837} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 + m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &83502841 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 83502837} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 605357146} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &438930283 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 438930286} + - component: {fileID: 438930285} + - component: {fileID: 438930287} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!20 &438930285 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 438930283} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.3018868, g: 0.3018868, b: 0.3018868, a: 1} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0 + far clip plane: 1 + field of view: 60 + orthographic: 1 + orthographic size: 1 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &438930286 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 438930283} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &438930287 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 438930283} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 77036910f02c4bc59877e1a9b6b26603, type: 3} + m_Name: + m_EditorClassIdentifier: + _text: {fileID: 1277855983} +--- !u!1 &560130992 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 560130995} + - component: {fileID: 560130994} + - component: {fileID: 560130993} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &560130993 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 560130992} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &560130994 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 560130992} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &560130995 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 560130992} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &605357145 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 605357146} + - component: {fileID: 605357149} + - component: {fileID: 605357148} + - component: {fileID: 605357147} + m_Layer: 5 + m_Name: Scroll View + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &605357146 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 605357145} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 736999110} + m_Father: {fileID: 83502841} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &605357147 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 605357145} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Content: {fileID: 1491675941} + m_Horizontal: 0 + m_Vertical: 1 + m_MovementType: 1 + m_Elasticity: 0.1 + m_Inertia: 1 + m_DecelerationRate: 0.135 + m_ScrollSensitivity: 1 + m_Viewport: {fileID: 736999110} + m_HorizontalScrollbar: {fileID: 0} + m_VerticalScrollbar: {fileID: 0} + m_HorizontalScrollbarVisibility: 2 + m_VerticalScrollbarVisibility: 2 + m_HorizontalScrollbarSpacing: -3 + m_VerticalScrollbarSpacing: -3 + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &605357148 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 605357145} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &605357149 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 605357145} + m_CullTransparentMesh: 1 +--- !u!1 &736999109 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 736999110} + - component: {fileID: 736999113} + - component: {fileID: 736999112} + - component: {fileID: 736999111} + m_Layer: 5 + m_Name: Viewport + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &736999110 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 736999109} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1491675941} + m_Father: {fileID: 605357146} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -17, y: 0} + m_Pivot: {x: 0, y: 1} +--- !u!114 &736999111 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 736999109} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ShowMaskGraphic: 0 +--- !u!114 &736999112 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 736999109} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &736999113 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 736999109} + m_CullTransparentMesh: 1 +--- !u!1 &1277855980 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1277855981} + - component: {fileID: 1277855984} + - component: {fileID: 1277855983} + - component: {fileID: 1277855982} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1277855981 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1277855980} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1491675941} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 570, y: -52.148438} + m_SizeDelta: {x: 1080, y: 44.296875} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1277855982 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1277855980} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalFit: 0 + m_VerticalFit: 2 +--- !u!114 &1277855983 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1277855980} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.7924528, g: 0.7924528, b: 0.7924528, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 40 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 4 + m_MaxSize: 70 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &1277855984 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1277855980} + m_CullTransparentMesh: 1 +--- !u!1 &1491675940 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1491675941} + - component: {fileID: 1491675943} + - component: {fileID: 1491675942} + m_Layer: 5 + m_Name: Content + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1491675941 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1491675940} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1277855981} + m_Father: {fileID: 736999110} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0.000031294992, y: 0} + m_SizeDelta: {x: -23.958084, y: 0} + m_Pivot: {x: 0, y: 1} +--- !u!114 &1491675942 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1491675940} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalFit: 0 + m_VerticalFit: 2 +--- !u!114 &1491675943 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1491675940} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 30 + m_Right: 0 + m_Top: 30 + m_Bottom: 0 + m_ChildAlignment: 0 + m_Spacing: 0 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 1 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 + m_ReverseArrangement: 0 +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 438930286} + - {fileID: 83502841} + - {fileID: 560130995} diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureB/Tests.meta b/UnityCSharpPatch/Assets/Scene.unity.meta similarity index 67% rename from UnityCSharpPatch/Assets/Scripts/FeatureB/Tests.meta rename to UnityCSharpPatch/Assets/Scene.unity.meta index 91c4ba4..b5b3f8e 100644 --- a/UnityCSharpPatch/Assets/Scripts/FeatureB/Tests.meta +++ b/UnityCSharpPatch/Assets/Scene.unity.meta @@ -1,6 +1,5 @@ fileFormatVersion: 2 -guid: 13a2842df9b0f462fb7a0395b880da8f -folderAsset: yes +guid: 56ef2c2d96cd042288056bc28f725b14 DefaultImporter: externalObjects: {} userData: diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests.meta b/UnityCSharpPatch/Assets/Scripts/Custom.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/Tests.meta rename to UnityCSharpPatch/Assets/Scripts/Custom.meta diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Custom.asmdef b/UnityCSharpPatch/Assets/Scripts/Custom/Custom.asmdef new file mode 100644 index 0000000..9fbadbe --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Custom.asmdef @@ -0,0 +1,14 @@ +{ + "name": "Custom", + "rootNamespace": "", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/FeatureA.asmdef.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Custom.asmdef.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/FeatureA.asmdef.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/Custom.asmdef.meta diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features.meta similarity index 77% rename from UnityCSharpPatch/Assets/Scripts/FeatureA.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/Features.meta index e285102..627684a 100644 --- a/UnityCSharpPatch/Assets/Scripts/FeatureA.meta +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 43b05a37642bd42ea932f1ffa673f444 +guid: 318dc524dbe78437690130319fdbfcd4 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/Constructor.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/Constructor.cs new file mode 100644 index 0000000..0c781a5 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/Constructor.cs @@ -0,0 +1,19 @@ +namespace Custom.Features; + +public class Constructor : ITest +{ + public void Run() + { + var test = new Test(42, "42"); + + Assert.AreEqual(42, test.A); + Assert.AreEqual("42", test.B); + } + + private class Test(int a, string b) + { + public int A => a; + public string B => b; + } +} + diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestCtor.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/Constructor.cs.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestCtor.cs.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/Features/Constructor.cs.meta diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/EmptyTypeDeclaration.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/EmptyTypeDeclaration.cs new file mode 100644 index 0000000..f95419a --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/EmptyTypeDeclaration.cs @@ -0,0 +1,11 @@ +namespace Custom.Features; + +public class EmptyTypeDeclaration : ITest +{ + public void Run() + { + Assert.AreNotEqual(null, new Test()); + } + + private class Test; +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/Test.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/EmptyTypeDeclaration.cs.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/Test.cs.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/Features/EmptyTypeDeclaration.cs.meta diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/ExtensionBlock.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ExtensionBlock.cs new file mode 100644 index 0000000..6ca3835 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ExtensionBlock.cs @@ -0,0 +1,17 @@ +namespace Custom.Features; + +public class ExtensionBlock : ITest +{ + public void Run() + { + Assert.AreEqual(42, this.Count); + } +} + +public static class TestExtensionBlockExtensions +{ + extension(ExtensionBlock block) + { + public int Count => 42; + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/ExtensionBlock.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ExtensionBlock.cs.meta new file mode 100644 index 0000000..8bc3417 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ExtensionBlock.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 540ebfd3419041a5b325c913f891b081 +timeCreated: 1745270453 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/FieldKeyword.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/FieldKeyword.cs new file mode 100644 index 0000000..8c176f7 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/FieldKeyword.cs @@ -0,0 +1,17 @@ +namespace Custom.Features; + +public class FieldKeyword : ITest +{ + public int Property + { + get => field; + set => field = Mathf.Clamp(value, 0, 100); + } + + public void Run() + { + Property = 142; + + Assert.AreEqual(Property, 100); + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestFieldKeyword.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/FieldKeyword.cs.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestFieldKeyword.cs.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/Features/FieldKeyword.cs.meta diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/ImplicitSpanConversions.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ImplicitSpanConversions.cs new file mode 100644 index 0000000..aa31cbb --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ImplicitSpanConversions.cs @@ -0,0 +1,19 @@ +namespace Custom.Features; + +public class ImplicitSpanConversions : ITest +{ + public void Run() + { + int[] arr = [42]; + + Assert.AreEqual(42, arr.First()); + } +} + +public static class ImplicitSpanConversionsExtensions +{ + public static T First(this ReadOnlySpan span) + { + return span[0]; + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/ImplicitSpanConversions.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ImplicitSpanConversions.cs.meta new file mode 100644 index 0000000..71e9de2 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/ImplicitSpanConversions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5c214f957d8c4551a781adf335b05409 +timeCreated: 1745274129 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/NullConditionalAssignment.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/NullConditionalAssignment.cs new file mode 100644 index 0000000..96bd983 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/NullConditionalAssignment.cs @@ -0,0 +1,20 @@ +namespace Custom.Features; + +public class NullConditionalAssignment : ITest +{ + private Test? _test; + + public void Run() + { + _test?.Property = 100; + _test = new Test { Property = 0 }; + _test.Property += 25; + + Assert.AreEqual(25, _test.Property); + } + + private class Test + { + public int Property { get; set; } + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/NullConditionalAssignment.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/NullConditionalAssignment.cs.meta new file mode 100644 index 0000000..e6052ac --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/NullConditionalAssignment.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c95531f33e8e42c8b207a264dbd95beb +timeCreated: 1745272042 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialConstructor.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialConstructor.cs new file mode 100644 index 0000000..796af16 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialConstructor.cs @@ -0,0 +1,24 @@ +namespace Custom.Features; + +public class PartialConstructor : ITest +{ + public void Run() + { + Assert.AreEqual(42, new Test(42).Value); + } + + private partial class Test + { + public partial Test(int value); + } + + private partial class Test + { + public int Value { get; } + + public partial Test(int value) + { + Value = value; + } + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialConstructor.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialConstructor.cs.meta new file mode 100644 index 0000000..2a85ff3 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialConstructor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 129cb1ad4d08401b864c163bb1ff2fca +timeCreated: 1745274808 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialEvent.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialEvent.cs new file mode 100644 index 0000000..022abd7 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialEvent.cs @@ -0,0 +1,32 @@ +namespace Custom.Features; + +public partial class PartialEvent : ITest +{ + public partial event Action TestEvent; + + public void Run() + { + var calledTimes = 0; + TestEvent += () => calledTimes++; + + InvokeTestEvent(); + + Assert.AreEqual(1, calledTimes); + } +} + +public partial class PartialEvent +{ + private Action? _actions = delegate { }; + + public partial event Action TestEvent + { + add => _actions += value; + remove => _actions -= value; + } + + public void InvokeTestEvent() + { + _actions?.Invoke(); + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialEvent.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialEvent.cs.meta new file mode 100644 index 0000000..c1844de --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 722f1c1a9a8e46d59600a791b6f799e8 +timeCreated: 1745270771 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialProperty.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialProperty.cs new file mode 100644 index 0000000..cf8cc3b --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialProperty.cs @@ -0,0 +1,22 @@ +namespace Custom.Features; + +public partial class PartialProperty : ITest +{ + partial int Property { get; set; } + + public void Run() + { + Property = 142; + + Assert.AreEqual(100, Property); + } +} + +public partial class PartialProperty +{ + partial int Property + { + get; + set => field = Mathf.Clamp(value, 0, 100); + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestPartialPropertyField.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialProperty.cs.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestPartialPropertyField.cs.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/Features/PartialProperty.cs.meta diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/SimpleLambdaParameters.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/SimpleLambdaParameters.cs new file mode 100644 index 0000000..2cbeba8 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/SimpleLambdaParameters.cs @@ -0,0 +1,14 @@ +namespace Custom.Features; + +public class SimpleLambdaParameters : ITest +{ + private delegate bool TryParse(string text, out T result); + + public void Run() + { + TryParse parser = (text, out result) => int.TryParse(text, out result); + + Assert.AreEqual(true, parser("42", out var value)); + Assert.AreEqual(42, value); + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/SimpleLambdaParameters.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/SimpleLambdaParameters.cs.meta new file mode 100644 index 0000000..29731d6 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/SimpleLambdaParameters.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1ac0fdcf43da4ba8b1b7c346b30a2bf7 +timeCreated: 1745274490 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/UnboundGenericTypeNameOf.cs b/UnityCSharpPatch/Assets/Scripts/Custom/Features/UnboundGenericTypeNameOf.cs new file mode 100644 index 0000000..fb18325 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/UnboundGenericTypeNameOf.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Custom.Features; + +public class UnboundGenericTypeNameOf : ITest +{ + public void Run() + { + Assert.AreEqual("List", nameof(List<>)); + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/Features/UnboundGenericTypeNameOf.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/Features/UnboundGenericTypeNameOf.cs.meta new file mode 100644 index 0000000..f087760 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/Features/UnboundGenericTypeNameOf.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: eb714e1110474adfa3cd559a5a8aae7a +timeCreated: 1745273037 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/GlobalUsings.cs b/UnityCSharpPatch/Assets/Scripts/Custom/GlobalUsings.cs new file mode 100644 index 0000000..fa3ce97 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/GlobalUsings.cs @@ -0,0 +1,5 @@ +global using System; +global using System.Collections; + +global using UnityEngine; +global using UnityEngine.Assertions; \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/GlobalUsings.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/GlobalUsings.cs.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/GlobalUsings.cs.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/GlobalUsings.cs.meta diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/ITest.cs b/UnityCSharpPatch/Assets/Scripts/Custom/ITest.cs new file mode 100644 index 0000000..30805c6 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/ITest.cs @@ -0,0 +1,6 @@ +namespace Custom; + +public interface ITest +{ + void Run(); +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/ITest.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/ITest.cs.meta new file mode 100644 index 0000000..59d5342 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/ITest.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8fe820bf4504beeb6578d4772434751 +timeCreated: 1745275478 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/TestRunner.cs b/UnityCSharpPatch/Assets/Scripts/Custom/TestRunner.cs new file mode 100644 index 0000000..0c739c2 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/TestRunner.cs @@ -0,0 +1,47 @@ +using Custom.Features; +using UnityEngine.UI; + +namespace Custom; + +public class TestRunner : MonoBehaviour +{ + [SerializeField] private Text? _text; + + private readonly Type[] _tests = + [ + typeof(Constructor), + typeof(EmptyTypeDeclaration), + typeof(ExtensionBlock), + typeof(FieldKeyword), + typeof(ImplicitSpanConversions), + typeof(NullConditionalAssignment), + typeof(PartialConstructor), + typeof(PartialEvent), + typeof(PartialProperty), + typeof(SimpleLambdaParameters), + typeof(UnboundGenericTypeNameOf) + ]; + + private IEnumerator Start() + { + _text!.text = string.Empty; + + for (var index = 0; index < _tests.Length; index++) + { + var testType = _tests[index]; + _text.text += $"[{index + 1}/{_tests.Length}] Start test {testType.Name}\n"; + + var test = (ITest)Activator.CreateInstance(testType); + test.Run(); + + var str = $"[{index + 1}/{_tests.Length}] Test {testType.Name} passed"; + + _text.text += $"{str}\n\n"; + Debug.Log(str); + + yield return null; + } + + _text.text += "All tests passed"; + } +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/Custom/TestRunner.cs.meta b/UnityCSharpPatch/Assets/Scripts/Custom/TestRunner.cs.meta new file mode 100644 index 0000000..ed7ade2 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Custom/TestRunner.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 77036910f02c4bc59877e1a9b6b26603 +timeCreated: 1745275209 \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/csc.rsp b/UnityCSharpPatch/Assets/Scripts/Custom/csc.rsp similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/csc.rsp rename to UnityCSharpPatch/Assets/Scripts/Custom/csc.rsp diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/csc.rsp.meta b/UnityCSharpPatch/Assets/Scripts/Custom/csc.rsp.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureA/csc.rsp.meta rename to UnityCSharpPatch/Assets/Scripts/Custom/csc.rsp.meta diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureB.meta b/UnityCSharpPatch/Assets/Scripts/Default.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureB.meta rename to UnityCSharpPatch/Assets/Scripts/Default.meta diff --git a/UnityCSharpPatch/Assets/Scripts/Default/Default.asmdef b/UnityCSharpPatch/Assets/Scripts/Default/Default.asmdef new file mode 100644 index 0000000..e3ee340 --- /dev/null +++ b/UnityCSharpPatch/Assets/Scripts/Default/Default.asmdef @@ -0,0 +1,14 @@ +{ + "name": "Default", + "rootNamespace": "", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureB/FeatureB.asmdef.meta b/UnityCSharpPatch/Assets/Scripts/Default/Default.asmdef.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureB/FeatureB.asmdef.meta rename to UnityCSharpPatch/Assets/Scripts/Default/Default.asmdef.meta diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureB/Tests/Test.cs b/UnityCSharpPatch/Assets/Scripts/Default/KeywordAsTypeName.cs similarity index 86% rename from UnityCSharpPatch/Assets/Scripts/FeatureB/Tests/Test.cs rename to UnityCSharpPatch/Assets/Scripts/Default/KeywordAsTypeName.cs index 975d026..deef2cb 100644 --- a/UnityCSharpPatch/Assets/Scripts/FeatureB/Tests/Test.cs +++ b/UnityCSharpPatch/Assets/Scripts/Default/KeywordAsTypeName.cs @@ -1,4 +1,4 @@ -namespace FeatureB.Tests +namespace Default { // ReSharper disable once InconsistentNaming public class scoped // in newer c# this class name will lead to compile error diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureB/Tests/Test.cs.meta b/UnityCSharpPatch/Assets/Scripts/Default/KeywordAsTypeName.cs.meta similarity index 100% rename from UnityCSharpPatch/Assets/Scripts/FeatureB/Tests/Test.cs.meta rename to UnityCSharpPatch/Assets/Scripts/Default/KeywordAsTypeName.cs.meta diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/FeatureA.asmdef b/UnityCSharpPatch/Assets/Scripts/FeatureA/FeatureA.asmdef deleted file mode 100644 index c1114d2..0000000 --- a/UnityCSharpPatch/Assets/Scripts/FeatureA/FeatureA.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "FeatureA", - "rootNamespace": "", - "references": [], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/GlobalUsings.cs b/UnityCSharpPatch/Assets/Scripts/FeatureA/GlobalUsings.cs deleted file mode 100644 index 01543e3..0000000 --- a/UnityCSharpPatch/Assets/Scripts/FeatureA/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using UnityEngine; \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/Test.cs b/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/Test.cs deleted file mode 100644 index b6af78c..0000000 --- a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/Test.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace FeatureA.Tests; - -public class Test; \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestCtor.cs b/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestCtor.cs deleted file mode 100644 index 21d263a..0000000 --- a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestCtor.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace FeatureA.Tests; - -public class TestCtor(ILogger a, string b) -{ - public void Method() - { - a.Log(b); - } -} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestFieldKeyword.cs b/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestFieldKeyword.cs deleted file mode 100644 index d4b67eb..0000000 --- a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestFieldKeyword.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace FeatureA.Tests; - -public class TestFieldKeyword -{ - public int NewProperty - { - get => field; - set => field = Mathf.Clamp(value, 0, 100); - } -} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestPartialPropertyField.cs b/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestPartialPropertyField.cs deleted file mode 100644 index 6e97531..0000000 --- a/UnityCSharpPatch/Assets/Scripts/FeatureA/Tests/TestPartialPropertyField.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace FeatureA.Tests; - -public partial class TestPartialPropertyField -{ - partial int Property { get; set; } -} - -public partial class TestPartialPropertyField -{ - partial int Property - { - get => 0; - set { } - } -} \ No newline at end of file diff --git a/UnityCSharpPatch/Assets/Scripts/FeatureB/FeatureB.asmdef b/UnityCSharpPatch/Assets/Scripts/FeatureB/FeatureB.asmdef deleted file mode 100644 index e160c14..0000000 --- a/UnityCSharpPatch/Assets/Scripts/FeatureB/FeatureB.asmdef +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "FeatureB" -} diff --git a/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/Csc/CscParser.cs b/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/Csc/CscParser.cs index 31047e3..b24a635 100644 --- a/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/Csc/CscParser.cs +++ b/UnityCSharpPatch/Packages/com.kandreyc.unity-csharp-patch/Editor/Csc/CscParser.cs @@ -12,7 +12,7 @@ public static class CscParser { "11", "11"}, { "12", "12"}, { "13", "13"}, - { "preview", "14"} + { "preview", "preview"} }; public static bool TryParse(string csc, out Dictionary info) diff --git a/UnityCSharpPatch/ProjectSettings/EditorBuildSettings.asset b/UnityCSharpPatch/ProjectSettings/EditorBuildSettings.asset index 0147887..bcfce5b 100644 --- a/UnityCSharpPatch/ProjectSettings/EditorBuildSettings.asset +++ b/UnityCSharpPatch/ProjectSettings/EditorBuildSettings.asset @@ -4,5 +4,8 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 - m_Scenes: [] + m_Scenes: + - enabled: 1 + path: Assets/Scene.unity + guid: 56ef2c2d96cd042288056bc28f725b14 m_configObjects: {} diff --git a/UnityCSharpPatch/ProjectSettings/ProjectSettings.asset b/UnityCSharpPatch/ProjectSettings/ProjectSettings.asset index 8a7483e..a80a24d 100644 --- a/UnityCSharpPatch/ProjectSettings/ProjectSettings.asset +++ b/UnityCSharpPatch/ProjectSettings/ProjectSettings.asset @@ -162,7 +162,9 @@ PlayerSettings: androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 applicationIdentifier: + Android: com.DefaultCompany.UnityCSharpPatch Standalone: com.DefaultCompany.UnityCSharpPatch + iPhone: com.DefaultCompany.UnityCSharpPatch buildNumber: Standalone: 0 VisionOS: 0 @@ -260,7 +262,7 @@ PlayerSettings: useCustomGradlePropertiesTemplate: 0 useCustomGradleSettingsTemplate: 0 useCustomProguardFile: 0 - AndroidTargetArchitectures: 1 + AndroidTargetArchitectures: 2 AndroidTargetDevices: 0 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} @@ -758,7 +760,9 @@ PlayerSettings: scriptingDefineSymbols: {} additionalCompilerArguments: {} platformArchitecture: {} - scriptingBackend: {} + scriptingBackend: + Android: 1 + Standalone: 0 il2cppCompilerConfiguration: {} il2cppCodeGeneration: {} managedStrippingLevel: {} diff --git a/UnityCSharpPatch/ProjectSettings/SceneTemplateSettings.json b/UnityCSharpPatch/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 0000000..5e97f83 --- /dev/null +++ b/UnityCSharpPatch/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,121 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicMaterial", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "defaultInstantiationMode": 0 + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "defaultInstantiationMode": 1 + }, + "newSceneOverride": 0 +} \ No newline at end of file diff --git a/UnityEditorPatch/InfoProviders/Sdk/SDKInfo.cs b/UnityEditorPatch/InfoProviders/Sdk/SDKInfo.cs index eb72d7a..2ece188 100644 --- a/UnityEditorPatch/InfoProviders/Sdk/SDKInfo.cs +++ b/UnityEditorPatch/InfoProviders/Sdk/SDKInfo.cs @@ -10,7 +10,7 @@ public class SDKInfo public string SDKLocation { get; init; } public string RoslynLocation { get; init; } - public SemanticVersion Version { get; init; } + public NuGetVersion Version { get; init; } public string LatestCSharpVersion { get; init; } } diff --git a/UnityEditorPatch/InfoProviders/Sdk/SDKInfoProvider.cs b/UnityEditorPatch/InfoProviders/Sdk/SDKInfoProvider.cs index e64702e..1afa4b2 100644 --- a/UnityEditorPatch/InfoProviders/Sdk/SDKInfoProvider.cs +++ b/UnityEditorPatch/InfoProviders/Sdk/SDKInfoProvider.cs @@ -1,23 +1,23 @@ -using System.Runtime.Loader; -using System.Text.RegularExpressions; using NuGet.Versioning; +using System.Runtime.Loader; using UnityEditorPatch.Utilities; +using System.Text.RegularExpressions; namespace UnityEditorPatch.InfoProviders.Sdk; public static partial class SDKInfoProvider { - [GeneratedRegex(@"(\d+\.\d+\.\d+)[\s]\[(.+)\]", RegexOptions.Multiline)] + [GeneratedRegex(@"(\d+\.\d+\.\d+(?:-[\w\.]+)?)[\s]\[(.+)\]", RegexOptions.Multiline)] private static partial Regex SDKInfoRegex(); - public static bool TryGet(out SDKInfo info) + public static bool TryGet(out SDKInfo info, bool allowPrerelease) { // this version is used by unity var minVersion = SemanticVersion.Parse("6.0.21"); - if (!TryGetSdks(out var sdks)) + if (!TryGetSdks(out var sdks, allowPrerelease)) { - info = default!; + info = null!; return false; } @@ -37,17 +37,17 @@ public static bool TryGet(out SDKInfo info) return true; } - info = default!; + info = null!; return false; } - private static bool TryGetSdks(out IReadOnlyCollection sdks) + private static bool TryGetSdks(out IReadOnlyCollection sdks, bool allowPrerelease) { - sdks = GetSdks().OrderBy(sdk => sdk.Version.ToString()).ToArray(); + sdks = GetSdks(allowPrerelease).OrderBy(sdk => sdk.Version).ToArray(); return sdks.Count > 0; } - private static IEnumerable GetSdks() + private static IEnumerable GetSdks(bool allowPrerelease) { var listSdks = ProcessUtility.ReadOutputFrom(command: "dotnet", withArgument: "--list-sdks"); @@ -59,14 +59,15 @@ private static IEnumerable GetSdks() var dotnetLocation = Path.GetDirectoryName(path); var roslynLocation = Path.Combine(sdkLocation, "Roslyn", "bincore"); - if (!SemanticVersion.TryParse(version, out var semanticVersion)) continue; + if (!NuGetVersion.TryParse(version, out var nugetVersion)) continue; + if (!allowPrerelease && nugetVersion.IsPrerelease) continue; if (!Directory.Exists(path) || !Directory.Exists(sdkLocation) || !Directory.Exists(dotnetLocation)) continue; yield return new SDKInfo { + Version = nugetVersion, SDKLocation = sdkLocation, Location = dotnetLocation, - Version = semanticVersion, RoslynLocation = roslynLocation, LatestCSharpVersion = GetLatestCSharpVersion(roslynLocation) }; @@ -75,7 +76,7 @@ private static IEnumerable GetSdks() private static string GetLatestCSharpVersion(string roslynLocation) { - AssemblyLoadContext context = default!; + AssemblyLoadContext context = null!; try { @@ -94,7 +95,7 @@ private static string GetLatestCSharpVersion(string roslynLocation) version = facts.GetMethod("MapSpecifiedToEffectiveVersion")!.Invoke(null, [version]); // Map the version to a LangVersion string. - return (string)facts.GetMethod("ToDisplayString")!.Invoke(null, new[] { version })!; + return (string)facts.GetMethod("ToDisplayString")!.Invoke(null, [version])!; } catch (Exception) { diff --git a/UnityEditorPatch/Input/ApplyPatchOptions.cs b/UnityEditorPatch/Input/ApplyPatchOptions.cs index f3e236f..c732e38 100644 --- a/UnityEditorPatch/Input/ApplyPatchOptions.cs +++ b/UnityEditorPatch/Input/ApplyPatchOptions.cs @@ -9,6 +9,9 @@ public class ApplyPatchOptions { [Option("editor", Required = true, HelpText = "Path to the Unity Editor.")] public string EditorPath { get; set; } + + [Option("allow-prerelease", HelpText = "Allow prerelease versions of SDKs.")] + public bool AllowPrerelease { get; set; } } #pragma warning restore CS8618 \ No newline at end of file diff --git a/UnityEditorPatch/Interactors/PatchApplier.cs b/UnityEditorPatch/Interactors/PatchApplier.cs index 1e9378b..91553e8 100644 --- a/UnityEditorPatch/Interactors/PatchApplier.cs +++ b/UnityEditorPatch/Interactors/PatchApplier.cs @@ -5,9 +5,9 @@ namespace UnityEditorPatch.Interactors; public static class PatchApplier { - public static Result Perform(string editorPath) + public static Result Perform(string editorPath, bool allowPrerelease) { - if (!SDKInfoProvider.TryGet(out var sdkInfo)) + if (!SDKInfoProvider.TryGet(out var sdkInfo, allowPrerelease)) { return Result.Error("Failed to select dotnet sdk."); } diff --git a/UnityEditorPatch/Program.cs b/UnityEditorPatch/Program.cs index 2bd7baf..d7ad9f8 100644 --- a/UnityEditorPatch/Program.cs +++ b/UnityEditorPatch/Program.cs @@ -8,8 +8,9 @@ .MapResult ( options => PatchReverter.Perform(options.EditorPath), - options => PatchApplier.Perform(options.EditorPath), + options => PatchApplier.Perform(options.EditorPath, options.AllowPrerelease), errors => Result.Error(errors.Select(e => e.ToString()).ToArray()!) ); +Console.WriteLine(); Console.WriteLine(result); \ No newline at end of file