diff --git a/docs/docs/integration/diagnostic/1007.md b/docs/docs/integration/diagnostic/1007.md index 891c8b651..c0f600224 100644 --- a/docs/docs/integration/diagnostic/1007.md +++ b/docs/docs/integration/diagnostic/1007.md @@ -2,6 +2,9 @@ - Title: Regular C# constructors on native classes will be removed in a future version. +> [!WARNING] +> This diagnostic message got obsolete with GirCore 0.9.0. If you see this message it is likely that you do not use a recent version of GirCore. + GirCore aims to provide a deep integration with GObject. It does not want to hide its specific semantics as this leads to possible corner cases or unexpected behavior from a user point of view. Instead, GirCore can be seen as a bridge between two different type systems (dotnet and GObject). One of the main differences between these type systems is the way instances are created. In dotnet, constructors are used to create instances of a class. In GObject, instances are created through factory methods. There is one native factory method available on the `GObject.Object` class named `NewWithProperties`. This factory methods takes a type of any `GObject` and creates an instance of it. This means it is integral to the GObject type system to be able to create an instance of any class without any parameters. diff --git a/docs/docs/integration/index.md b/docs/docs/integration/index.md index 6f7042a71..5244a41a2 100644 --- a/docs/docs/integration/index.md +++ b/docs/docs/integration/index.md @@ -3,12 +3,12 @@ Diagnostic messages are raised to assist with the usage of GirCore. ## GObject-2.0 diagnostics - [GirCore1001](diagnostic/1001.md) (Obsolete) -- [GirCore1002](diagnostic/1002.md) +- [GirCore1002](diagnostic/1002.md) TODO NOT RAISED ANYMORE - [GirCore1003](diagnostic/1003.md) (Obsolete) - [GirCore1004](diagnostic/1004.md) - [GirCore1005](diagnostic/1005.md) -- [GirCore1006](diagnostic/1006.md) -- [GirCore1007](diagnostic/1007.md) +- [GirCore1006](diagnostic/1006.md) TODO NOT RAISED ANYMORE +- [GirCore1007](diagnostic/1007.md) (Obsolete) - [GirCore1008](diagnostic/1008.md) - [GirCore1009](diagnostic/1009.md) diff --git a/src/Generation/Generator/Renderer/Public/Class/ClassFramework.cs b/src/Generation/Generator/Renderer/Public/Class/ClassFramework.cs index 4646eefb6..2f71a1ad5 100644 --- a/src/Generation/Generator/Renderer/Public/Class/ClassFramework.cs +++ b/src/Generation/Generator/Renderer/Public/Class/ClassFramework.cs @@ -29,11 +29,6 @@ namespace {Namespace.GetPublicName(cls.Namespace)}; {{ protected internal {cls.Name}({Class.GetFullyQualifiedInternalHandleName(cls)} handle) : base(handle) {{ }} - [ObsoleteAttribute(""Regular C# constructors on native classes will be removed in a future version. Please see the linked documentation for more details. It contains scenarios and possible solutions to prepare for the upcoming changes."", DiagnosticId = ""GirCore1007"", UrlFormat = ""https://gircore.github.io/docs/integration/diagnostic/1007.html"")] - public {cls.Name}(params GObject.ConstructArgument[] constructArguments) : this(CreateLegacy(constructArguments)) {{ }} - [ObsoleteAttribute(""This constructor is a workaround to keep legacy APIs alive. Do not use it."")] - protected {cls.Name}(GObject.CreationData data) : base(data) {{ }} - /// /// Creates a new {cls.Name} and sets the properties specified by the construct arguments. /// @@ -63,22 +58,6 @@ namespace {Namespace.GetPublicName(cls.Namespace)}; return obj; }} - - private static GObject.CreationData CreateLegacy(GObject.ConstructArgument[] arguments) - {{ - var ptr = GObject.Internal.Object.NewWithProperties(GetGType(), arguments); - var handle = new {Class.GetFullyQualifiedInternalHandleName(cls)}(ptr); - - return new GObject.CreationData - {{ - Handle = handle, - Setup = (obj) => - {{ - GObject.Internal.InstanceCache.AddToggleRef(obj); - {RenderUnrefLegacy(cls)} - }} - }}; - }} }}"; } diff --git a/src/Libs/GObject-2.0/Public/Object.cs b/src/Libs/GObject-2.0/Public/Object.cs index b44957f49..ae71539ac 100644 --- a/src/Libs/GObject-2.0/Public/Object.cs +++ b/src/Libs/GObject-2.0/Public/Object.cs @@ -21,14 +21,6 @@ protected Object(Internal.ObjectHandle handle) Handle.AddMemoryPressure(); } - [Obsolete("Regular C# constructors on native classes will be removed in a future version. Please see the linked documentation for more details. It contains scenarios and possible solutions to prepare for the upcoming changes.", DiagnosticId = "GirCore1007", UrlFormat = "https://gircore.github.io/docs/integration/diagnostic/1007.html")] - public Object(params ConstructArgument[] constructArguments) : this(CreateLegacy(constructArguments)) { { } } - [Obsolete("This constructor is for backwards compatibility only. Do not use it in new code.")] - protected Object(CreationData data) : this(data.Handle) - { - data.Setup(this); - } - /// /// Creates a new Object and sets the properties specified by the construct arguments. /// @@ -55,22 +47,4 @@ public virtual void Dispose() Debug.WriteLine($"Handle {Handle.DangerousGetHandle()}: Disposing object of type {GetType()}."); Handle.Dispose(); } - - private static CreationData CreateLegacy(ConstructArgument[] arguments) - { - { - var ptr = Internal.Object.NewWithProperties(GetGType(), arguments); - var handle = new Internal.ObjectHandle(ptr); - - return new CreationData - { - Handle = handle, - Setup = obj => - { - Internal.InstanceCache.AddToggleRef(obj); - Internal.Object.Unref(obj.Handle.DangerousGetHandle()); - } - }; - } - } }