Mint the node for one C# constructor and own it from its type. The id is the one a method named after the type would get, so the first declared constructor keeps it and each other signature is salted like a method overload (#4584). A member spelled like the type in a
(type_nid: str, type_name: str, decl, params,
line: int, static: bool)
| 9703 | csharp_ctor_records: list[dict] = [] |
| 9704 | |
| 9705 | def csharp_add_constructor(type_nid: str, type_name: str, decl, params, |
| 9706 | line: int, static: bool) -> str: |
| 9707 | """Mint the node for one C# constructor and own it from its type. |
| 9708 | |
| 9709 | The id is the one a method named after the type would get, so the |
| 9710 | first declared constructor keeps it and each other signature is salted |
| 9711 | like a method overload (#4584). A member spelled like the type in |
| 9712 | another case (`Foo` / `foo()`) already owns that id: the constructor, |
| 9713 | never the existing member, takes a salted one. A static constructor |
| 9714 | has no parameters and is never what `new` runs, so it is its own |
| 9715 | signature. |
| 9716 | """ |
| 9717 | signature, meta = _csharp_method_signature(decl, source, params) |
| 9718 | if static: |
| 9719 | signature, meta = "static", {"arity": 0} |
| 9720 | ctor_nid = _make_id(type_nid, type_name) |
| 9721 | if ctor_nid in csharp_member_ids: |
| 9722 | ctor_nid = _make_id(ctor_nid, hashlib.sha1( |
| 9723 | b".ctor", usedforsecurity=False).hexdigest()[:6]) |
| 9724 | group = csharp_ctor_overloads.setdefault(ctor_nid, {}) |
| 9725 | if group and signature not in group: |
| 9726 | ctor_nid = _make_id(ctor_nid, hashlib.sha1( |
| 9727 | signature.encode("utf-8"), usedforsecurity=False).hexdigest()[:6]) |
| 9728 | add_node(ctor_nid, f".{type_name}()", line, |
| 9729 | metadata={**meta, "signature": signature, "kind": "constructor"}) |
| 9730 | if signature not in group and nodes and nodes[-1]["id"] == ctor_nid: |
| 9731 | group[signature] = nodes[-1] |
| 9732 | add_edge(type_nid, ctor_nid, "method", line) |
| 9733 | return ctor_nid |
| 9734 | |
| 9735 | def csharp_queue_member_bodies(member_nid: str, decl, class_nid: str) -> None: |
| 9736 | """Walk a C# property's or indexer's accessor bodies as its calls. |
no test coverage detected