import os def count_cs_lines(root_dir: str): total = 0 for dirpath, _, filenames in os.walk(root_dir): for filename in filenames: if filename.endswith(".cs"): filepath = os.path.join(dirpath, filename) with open(filepath, "r", encoding="utf-8", errors="ignore") as f: lines = [ line for line in f if line.strip() and not line.strip().startswith("//") ] total += len(lines) print(f"Total non-empty lines in .cs files: {total}") if __name__ == "__main__": os.chdir(os.path.dirname(os.path.abspath(__file__))) count_cs_lines(".")