Skip to content

Commit

Permalink
Adding local property initializers (#255)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Waddell <[email protected]>
  • Loading branch information
github-actions[bot] and mwaddell authored Oct 12, 2024
1 parent f9b26b3 commit 535490e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion salt2type
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PropDef:
""" Whether or not this is a rest parameter (None if unknown). """

is_static: Optional[bool] = None
""" Whether or not this method is static (None if unknown). """
""" Whether or not this property is static (None if unknown). """


@dataclass
Expand Down Expand Up @@ -628,6 +628,8 @@ def add_doc_info(defs: List[ClassDef], types: List[ClassDef]) -> None:
curr_prop.typ = prop.typ
curr_prop.desc = prop.desc
curr_prop.is_rest = prop.is_rest
elif not prop.name.startswith("this["):
curr_class.props.append(PropDef(to_local_prop(prop.name), None, prop.typ, prop.desc, prop.is_rest, False))

curr_class.links.extend(typ.links)

Expand Down Expand Up @@ -682,6 +684,16 @@ def copy_tpl(out_dir: str, asm_name: str, ns_name: str) -> None:
copy_file(src_file, dst_file, asm_name, ns_name)


def to_local_prop(name: str) -> str:
"""
Converts a C# local property to a S# name
"""
if name[:1] == name[:1].lower():
return "$" + name

return name[:1].lower() + name[1:]


def prop_to_string(prop: PropDef) -> str:
"""
Generates a stringified version of the property for typescript
Expand Down

0 comments on commit 535490e

Please sign in to comment.