Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/docs/integration/diagnostic/1007.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/integration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 0 additions & 21 deletions src/Generation/Generator/Renderer/Public/Class/ClassFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {{ }}

/// <summary>
/// Creates a new {cls.Name} and sets the properties specified by the construct arguments.
/// </summary>
Expand Down Expand Up @@ -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)}
}}
}};
}}
}}";
}

Expand Down
26 changes: 0 additions & 26 deletions src/Libs/GObject-2.0/Public/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
/// Creates a new Object and sets the properties specified by the construct arguments.
/// </summary>
Expand All @@ -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());
}
};
}
}
}
Loading