fix: Restrict commutativity in C# #375

Merged
wetneb merged 1 commit from wetneb/mergiraf:224-csharp-children-groups into main 2025-05-10 14:17:26 +02:00

View file

@ -0,0 +1,20 @@
// Copyright header
using System;
namespace MyNamespace;
public partial class MyClass : IMyInterface
{
/// <summary>
/// Ctor docs
/// </summary>
/// <param name="ctorArg">Param docs</param>
public MyClass(IThing1 thing1, IThing2 thing2)
{
_thing1 = thing1;
_thing2 = thing2;
}
private record MyPrivateRecord(bool Foo);
}

View file

@ -0,0 +1,34 @@
// Copyright header
using System;
namespace MyNamespace;
public partial class MyClass : IMyInterface
{
/// <summary>
/// Ctor docs
/// </summary>
/// <param name="ctorArg">Param docs</param>
public MyClass(IThing1 thing1, IThing2 thing2)
{
_thing1 = thing1;
_thing2 = thing2;
}
<<<<<<< LEFT
/// <summary>
/// Record docs
/// </summary>
/// <param name="Foo">Bool arg docs</param>
||||||| BASE
=======
/// <summary>
/// Prop docs
/// </summary>
[MyCustomAttribute]
public string? MyProp { get; set; }
>>>>>>> RIGHT
private record MyPrivateRecord(bool Foo);
}

View file

@ -0,0 +1,30 @@
// Copyright header
using System;
namespace MyNamespace;
public partial class MyClass : IMyInterface
{
/// <summary>
/// Ctor docs
/// </summary>
/// <param name="ctorArg">Param docs</param>
public MyClass(IThing1 thing1, IThing2 thing2)
{
_thing1 = thing1;
_thing2 = thing2;
}
/// <summary>
/// Prop docs
/// </summary>
[MyCustomAttribute]
public string? MyProp { get; set; }
/// <summary>
/// Record docs
/// </summary>
/// <param name="Foo">Bool arg docs</param>
private record MyPrivateRecord(bool Foo);
}

View file

@ -0,0 +1,24 @@
// Copyright header
using System;
namespace MyNamespace;
public partial class MyClass : IMyInterface
{
/// <summary>
/// Ctor docs
/// </summary>
/// <param name="ctorArg">Param docs</param>
public MyClass(IThing1 thing1, IThing2 thing2)
{
_thing1 = thing1;
_thing2 = thing2;
}
/// <summary>
/// Record docs
/// </summary>
/// <param name="Foo">Bool arg docs</param>
private record MyPrivateRecord(bool Foo);
}

View file

@ -0,0 +1,3 @@
Commutativity is restricted because comments are involved.
See https://codeberg.org/mergiraf/mergiraf/issues/224,
https://codeberg.org/mergiraf/mergiraf/issues/322.

View file

@ -0,0 +1,26 @@
// Copyright header
using System;
namespace MyNamespace;
public partial class MyClass : IMyInterface
{
/// <summary>
/// Ctor docs
/// </summary>
/// <param name="ctorArg">Param docs</param>
public MyClass(IThing1 thing1, IThing2 thing2)
{
_thing1 = thing1;
_thing2 = thing2;
}
/// <summary>
/// Prop docs
/// </summary>
[MyCustomAttribute]
public string? MyProp { get; set; }
private record MyPrivateRecord(bool Foo);
}

View file

@ -473,7 +473,30 @@ pub static SUPPORTED_LANGUAGES: LazyLock<Vec<LangProfile>> = LazyLock::new(|| {
atomic_nodes: vec![],
commutative_parents: vec![
CommutativeParent::without_delimiters("compilation_unit", "\n"),
CommutativeParent::new("declaration_list", "{", "\n", "}"),
CommutativeParent::new("declaration_list", "{", "\n", "}").restricted_to_groups(&[
&["using_directive"],
&[
"field_declaration",
"property_declaration",
"event_declaration",
"event_field_declaration",
],
&[
"class_declaration",
"struct_declaration",
"enum_declaration",
"delegate_declaration",
"method_declaration",
"record_declaration",
"constructor_declaration",
"destructor_declaration",
"indexer_declaration",
"interface_declaration",
"namespace_declaration",
"operator_declaration",
"conversion_operator_declaration",
],
]),
CommutativeParent::new("enum_member_declaration_list", "{", ",\n", "}"),
],
signatures: vec![