# C Sharp Scripting

Writing and executing C# scripts and macros against Power BI semantic models using...

- Repository: https://github.com/data-goblin/power-bi-agentic-development (1079 stars)
- Category: Writing
- License: GPL-3.0
- Last updated: 2026-10-30
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add data-goblin/power-bi-agentic-development --skill c-sharp-scripting -g -a claude-code -y`
Codex: `npx skills add data-goblin/power-bi-agentic-development --skill c-sharp-scripting -g -a codex -y`
Cursor: `npx skills add data-goblin/power-bi-agentic-development --skill c-sharp-scripting -g -a cursor -y`
Gemini CLI: `npx skills add data-goblin/power-bi-agentic-development --skill c-sharp-scripting -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add data-goblin/power-bi-agentic-development`

## Description

Writing and executing C# scripts and macros against Power BI semantic models using Tabular Editor 2/3. Automatically invoke when the user mentions "C# script", "Tabular Editor script", "TOM scripting", "MacroActions.json", "XMLA", or asks to "automate model changes", "bulk update measures", "create calculation groups", "write a macro", "format DAX expressions", "manage model metadata".

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# C# Scripting for Tabular Editor

Expert guidance for writing and executing C# scripts to manipulate Power BI semantic model metadata using Tabular Editor 2/3 CLI or the Tabular Editor IDE.


## When to Use This Skill

Activate automatically when tasks involve:

- Writing C# scripts for Tabular Editor
- Bulk operations on model objects (measures, columns, tables)
- Creating or modifying calculation groups
- Managing model security (roles, RLS, OLS)
- Formatting DAX expressions
- Automating repetitive model changes
- Querying model metadata via TOM API
- Building interactive scripts with user input dialogs


## Critical

- Every statement must end with `;` (semicolon required by C#)
- Use double quotes `"` for strings and escape with `\` when needed
- Use forward slashes `/` in DisplayFolder paths (auto-converted to `\`)
- Always add `Info()` statements for debugging - script stops at error point
- Test scripts on non-production models first
- Changes are undoable with Ctrl+Z in the Tabular Editor UI


## C# Version Support

| Environment | C# Version | Notes |
|-------------|------------|-------|
| **Tabular Editor 2** | Default compiler | Older C# syntax |
| **Tabular Editor 3** | Roslyn | Supports up to C# 12 with VS2022 |
| **TE2 with Roslyn** | Configurable | Set in File > Preferences > General |

To use newer C# features in TE2, configure Roslyn compiler path in preferences.


## Default Imports and Assemblies

### Auto-Imported Namespaces

Scripts automatically have these `using` statements applied:

```csharp
using System;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
using TabularEditor.TOMWrapper;
using TabularEditor.TOMWrapper.Utils;
using TabularEditor.UI;
```

### Pre-Loaded Assemblies

These .NET assemblies are loaded by default:

The rest: https://github.com/data-goblin/power-bi-agentic-development/blob/HEAD/plugins/tabular-editor/skills/c-sharp-scripting/SKILL.md
