agentic-net-examples / working-with-diagrams
AGENTS.md1 starsChanged 4 months agoMITView on GitHub
AI-generated, compiler-validated C# examples for the Aspose.Diagram for .NET API — Working With Diagrams category. You are a C# developer specializing in Visio diagram processing using Aspose.Diagram for .NET. You are working in the Working With Diagrams category. Your task is to write clean, compilable C# console examples that demonstrate Aspose.Diagram API usage for working with diagrams operations. You always use explicit types (never var), include all required using directives, and follow the patterns established in this category. The dominant…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository32 other files it gives its agents.
- agents.mdAGENTS.md
- basic-operations/agents.mdAGENTS.md
- convert-visio-document/agents.mdAGENTS.md
- diagram-conversions/agents.mdAGENTS.md
- diagram-vba/agents.mdAGENTS.md
- document-properties/agents.mdAGENTS.md
- drawing/agents.mdAGENTS.md
- events-section-in-the-shapesheet/agents.mdAGENTS.md
- font-operations/agents.mdAGENTS.md
- ole-objects-in-visio-diagram/agents.mdAGENTS.md
- page-setup-features/agents.mdAGENTS.md
- visio-activex-controls/agents.mdAGENTS.md
- visio-shape-gradient/agents.mdAGENTS.md
- working-with-comments/agents.mdAGENTS.md
- working-with-external-data-sources/agents.mdAGENTS.md
- working-with-fields/agents.mdAGENTS.md
- working-with-geometry-section/agents.mdAGENTS.md
- working-with-headers-and-footers/agents.mdAGENTS.md
- working-with-hyperlinks/agents.mdAGENTS.md
- working-with-images/agents.mdAGENTS.md
- working-with-layers/agents.mdAGENTS.md
- working-with-masters/agents.mdAGENTS.md
- working-with-pages/agents.mdAGENTS.md
- working-with-protection/agents.mdAGENTS.md
- working-with-shapes/agents.mdAGENTS.md
- working-with-solutionxml-elements/agents.mdAGENTS.md
- working-with-text/agents.mdAGENTS.md
- working-with-text-boxes/agents.mdAGENTS.md
- working-with-themes/agents.mdAGENTS.md
- working-with-user-defined-cells/agents.mdAGENTS.md
- working-with-window-elements/agents.mdAGENTS.md
- llms.txtllms.txt
The file
We split this agents.md into the rules it gives an agent
11 rules. About 0 are common, 1 is distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
Use explicit types — Diagram diagram = new Diagram(...) not var diagram = ...
- Very specific: line 40
Use SaveFileFormat enum in PascalCase: SaveFileFormat.Vsdx, SaveFileFormat.Pdf
- Very specific: line 41
Use BOOL.True / BOOL.False for Aspose BOOL properties — never plain true/false
- Very specific: line 53
Use var for any variable declaration
- Very specific: line 54
Use using (Diagram diagram = ...) — Diagram does not implement IDisposable
- Very specific: line 55
Use SaveFileFormat.VSDX or other ALL_CAPS enum values
- Very specific: line 56
Use System.Windows.Forms — not available in net8.0 console project
- Very specific: line 57
Use NUnit Assert — not available, use Console.WriteLine and manual checks
- Distinctive: line 58
Use PowerShell syntax inside C# files
- Very specific: line 223
Only examples that pass both dotnet build and dotnet run are committed.
- Very specific: line 228
Always check rules/rules.json for the latest API correction rules
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Working With Diagrams
AI-generated, compiler-validated C# examples for the Aspose.Diagram for .NET API — Working With Diagrams category.
Statistics
| Metric | Value |
| Examples | 40 |
| Pass Rate | 100.0% |
| Aspose.Diagram Version | 26.9.0 |
| Target Framework | net8.0 |
| Last Updated | 2026-09-24 |
Persona
You are a C# developer specializing in Visio diagram processing using Aspose.Diagram for .NET. You are working in the Working With Diagrams category.
Your task is to write clean, compilable C# console examples that demonstrate Aspose.Diagram API usage for working with diagrams operations.
You always use explicit types (never var), include all required using directives, and follow the patterns established in this category.
Boundaries
Always
- Use explicit types —
Diagram diagram = new Diagram(...)notvar diagram = ... - Include
using Aspose.Diagram;andusing Aspose.Diagram.Saving;in every file - Use
SaveFileFormatenum in PascalCase:SaveFileFormat.Vsdx,SaveFileFormat.Pdf - Use
BOOL.True/BOOL.Falsefor Aspose BOOL properties — never plaintrue/false - Wrap entry point in
static void Main()insideclass Program - Handle
FileNotFoundExceptionwith try/catch when loading files
Ask First
- Multi-file projects or solutions
- External dependencies beyond Aspose.Diagram and Aspose.Drawing
- Platform-specific code (Windows Forms, WPF, ASP.NET)
Never
- Use
varfor any variable declaration - Use
using (Diagram diagram = ...)— Diagram does not implement IDisposable - Use
SaveFileFormat.VSDXor other ALL_CAPS enum values - Use
System.Windows.Forms— not available in net8.0 console project - Use NUnit
Assert— not available, useConsole.WriteLineand manual checks - Use PowerShell syntax inside C# files
Required Namespaces
| Namespace | Files | Purpose |
Aspose.Diagram | 40 | Core diagram API |
System | 40 | Console, Math, DateTime, Exception |
System.IO | 35 | File, Stream, Path, Directory operations |
Aspose.Diagram.Saving | 24 | Save options (PDF, PNG, HTML, SVG, XPS) |
System.Collections.Generic | 5 | List, Dictionary, HashSet |
System.Threading | 3 | Supporting utilities |
System.Linq | 2 | LINQ queries on collections |
System.Threading.Tasks | 2 | Supporting utilities |
System.Text | 1 | StringBuilder |
System.Text.RegularExpressions | 1 | Supporting utilities |
Aspose.Drawing.Text | 1 | Font enumeration via InstalledFontCollection |
Aspose.Diagram.Properties | 1 | Supporting utilities |
Aspose.Diagram.Manipulation | 1 | Supporting utilities |
System.Text.Json | 1 | JSON serialization |
System.Diagnostics | 1 | Supporting utilities |
Common Code Pattern
The dominant workflow in this category is: Load → Modify → Save
using System;
using Aspose.Diagram;
using Aspose.Diagram.Saving;
class Program
{
static void Main()
{
// 1. Load or create diagram
Diagram diagram = new Diagram("input.vsdx");
// 2. Perform category-specific operations
// ...
// 3. Save result
diagram.Save("output.vsdx", SaveFileFormat.Vsdx);
}
}Examples
| File | Key APIs | Task |
| add-a-digital-watermark-to-each-pdf-page-after-conversion-using-a-pdf-library.cs | Diagram, PdfSaveOptions, Save | Add a digital watermark to each pdf page after conversion using a pdf library |
| after-merging-diagrams-generate-a-thumbnail-image-of-the-first-page-and-save-as-png.cs | Diagram, ImageSaveOptions | After merging diagrams generate a thumbnail image of the first page and save as png |
| after-removing-hidden-data-compare-file-size-before-and-after-to-confirm-reduction.cs | Diagram, Save, diagram | After removing hidden data compare file size before and after to confirm reduction |
| apply-a-custom-page-background-color-before-exporting-the-diagram-to-pdf-for-branding.cs | Diagram, Page, Pages | Apply a custom page background color before exporting the diagram to pdf for branding |
| apply-a-global-line-color-change-to-all-connectors-to-match-corporate-palette-before-pdf-export.cs | Diagram, Pages, PdfSaveOptions | Apply a global line color change to all connectors to match corporate palette before pdf export |
| apply-a-uniform-line-thickness-to-all-connectors-before-exporting-the-diagram-to-pdf.cs | Diagram, Pages, PdfSaveOptions | Apply a uniform line thickness to all connectors before exporting the diagram to pdf |
| apply-auto-fit-layout-to-all-shapes-in-the-diagram-before-saving.cs | Diagram, Save, diagram | Apply auto fit layout to all shapes in the diagram before saving |
| batch-process-a-folder-of-vsdx-files-removing-hidden-info-and-converting-each-to-pdf.cs | Diagram, PdfSaveOptions, Save | Batch process a folder of vsdx files removing hidden info and converting each to pdf |
| combine-a-vsd-diagram-with-a-vsdx-diagram-preserving-page-order-from-the-first-file.cs | Diagram | Combine a vsd diagram with a vsdx diagram preserving page order from the first file |
| configure-diagram-interruptmonitor-with-a-five-second-timeout-before-starting-pdf-conversion.cs | Diagram, PdfSaveOptions, Save | Configure diagram interruptmonitor with a five second timeout before starting pdf conversion |
| configure-pdf-conversion-to-use-custom-page-margins-matching-corporate-standards.cs | Diagram, Pages, PdfSaveOptions | Configure pdf conversion to use custom page margins matching corporate standards |
| convert-the-diagram-to-html-and-embed-all-shape-images-as-base64-data-uris.cs | Diagram, HTMLSaveOptions, Save | Convert the diagram to html and embed all shape images as base64 data uris |
| convert-the-diagram-to-pdf-format-while-preserving-original-page-orientation.cs | Diagram, Save, diagram | Convert the diagram to pdf format while preserving original page orientation |
| convert-the-diagram-to-pdf-with-grayscale-color-mode-to-reduce-archival-file-size.cs | Diagram, PdfSaveOptions, Save | Convert the diagram to pdf with grayscale color mode to reduce archival file size |
| create-a-pipeline-that-loads-a-diagram-merges-it-with-a-template-and-outputs-html-with-embedded-css.cs | Diagram, HTMLSaveOptions | Create a pipeline that loads a diagram merges it with a template and outputs html with embedded css |
| create-a-utility-that-removes-hidden-information-from-diagrams-and-logs-amount-of-data-removed.cs | Diagram, Pages, Save | Create a utility that removes hidden information from diagrams and logs amount of data removed |
| embed-fonts-during-pdf-conversion-and-verify-that-all-fonts-are-embedded-in-the-output.cs | Diagram, Fonts, PdfSaveOptions | Embed fonts during pdf conversion and verify that all fonts are embedded in the output |
| embed-pdf-metadata-such-as-author-and-creation-date-using-diagram-properties-after-conversion.cs | Diagram, PdfSaveOptions, Save | Embed pdf metadata such as author and creation date using diagram properties after conversion |
| export-connector-routing-information-and-generate-a-visual-diagram-of-connections-using-a-third-party-graph-library.cs | Diagram, ImageSaveOptions, Page | Export connector routing information and generate a visual diagram of connections using a third party graph library |
| export-connector-start-and-end-points-from-the-diagram-to-a-json-file-for-external-analysis.cs | Diagram, Pages, Shapes | Export connector start and end points from the diagram to a json file for external analysis |
| extract-font-names-used-in-a-vsd-diagram-and-compare-them-against-a-corporate-whitelist.cs | Diagram, Fonts, diagram | Extract font names used in a vsd diagram and compare them against a corporate whitelist |
| flatten-all-groups-into-individual-shapes-after-merging-to-simplify-further-processing.cs | Diagram, Pages, Save | Flatten all groups into individual shapes after merging to simplify further processing |
| generate-a-summary-report-listing-page-counts-and-shape-totals-for-each-source-diagram-after-merging.cs | Diagram, Pages, Shapes | Generate a summary report listing page counts and shape totals for each source diagram after merging |
| implement-error-handling-that-catches-interruptmonitor-exceptions-and-logs-the-aborted-operation.cs | Diagram, PdfSaveOptions, Save | Implement error handling that catches interruptmonitor exceptions and logs the aborted operation |
| load-a-vsd-file-with-custom-loadoptions-enabling-interruptmonitor-for-cancellation.cs | Diagram | Load a vsd file with custom loadoptions enabling interruptmonitor for cancellation |
| load-a-vsdx-file-into-a-diagram-object-using-default-load-options.cs | Diagram, Pages, diagram | Load a vsdx file into a diagram object using default load options |
| load-multiple-diagrams-concurrently-using-asynchronous-tasks-then-combine-them-into-a-single-output-file.cs | Diagram | Load multiple diagrams concurrently using asynchronous tasks then combine them into a single output file |
| measure-conversion-time-for-pdf-output-with-and-without-interruptmonitor-to-assess-performance-impact.cs | Diagram | Measure conversion time for pdf output with and without interruptmonitor to assess performance impact |
| merge-two-vsdx-diagrams-into-a-single-diagram-automatically-resolving-duplicate-shape-ids.cs | Diagram | Merge two vsdx diagrams into a single diagram automatically resolving duplicate shape ids |
| protect-the-pdf-with-a-password-and-verify-that-opening-without-password-fails.cs | AddShape, Diagram, Pages | Protect the pdf with a password and verify that opening without password fails |
| remove-hidden-information-from-the-diagram-and-verify-that-hidden-layers-are-absent.cs | Diagram, Pages, Save | Remove hidden information from the diagram and verify that hidden layers are absent |
| rename-all-pages-sequentially-after-merging-to-avoid-naming-conflicts.cs | Diagram, Pages, Save | Rename all pages sequentially after merging to avoid naming conflicts |
| retrieve-and-log-the-font-size-of-each-text-shape-for-accessibility-auditing.cs | Diagram, Pages, Shapes | Retrieve and log the font size of each text shape for accessibility auditing |
| retrieve-connector-information-from-the-loaded-diagram-and-export-it-to-a-csv-report.cs | Diagram, Pages, Shapes | Retrieve connector information from the loaded diagram and export it to a csv report |
| save-the-converted-pdf-to-a-memory-stream-for-immediate-network-transmission.cs | Diagram, Save, diagram | Save the converted pdf to a memory stream for immediate network transmission |
| set-loadoptions-interruptmonitor-to-abort-loading-after-ten-seconds-for-large-diagrams.cs | Diagram | Set loadoptions interruptmonitor to abort loading after ten seconds for large diagrams |
| strip-hidden-metadata-from-a-vsdx-file-then-save-the-cleaned-diagram-back-to-vsdx.cs | Diagram, Save, diagram | Strip hidden metadata from a vsdx file then save the cleaned diagram back to vsdx |
| update-shape-text-in-the-diagram-to-include-a-timestamp-before-pdf-conversion.cs | Diagram, Pages, PdfSaveOptions | Update shape text in the diagram to include a timestamp before pdf conversion |
| validate-that-no-hidden-comments-remain-after-calling-removehiddeninfo-by-inspecting-diagram-metadata.cs | Diagram, Pages, Save | Validate that no hidden comments remain after calling removehiddeninfo by inspecting diagram metadata |
| validate-that-the-pdf-conversion-respects-page-orientation-by-checking-width-to-height-ratios.cs | Diagram, Pages, PdfSaveOptions | Validate that the pdf conversion respects page orientation by checking width to height ratios |
Command Reference
# Build the warmup project
cd compiler/CSharpRunner/_warmup
dotnet build
# Run a specific example (copy .cs content to Program.cs first)
dotnet run
# Build with verbose output
dotnet build --verbosity detailed.csproj Template
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<NoWarn>MSB3277</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="Aspose.Diagram">
<HintPath>..\..\libs\Aspose.Diagram.dll</HintPath>
</Reference>
</ItemGroup>
</Project>Testing Guide
Build Verification
dotnet build # Must exit with rc=0, zero compiler errorsRun Verification
dotnet run # rc=0 = pass, rc!=0 with unhandled exception = failExpected Output Patterns
| Pattern | Meaning |
rc=0 | ✅ Pass — example compiled and ran successfully |
rc=1 compiler errors | ❌ Fail — CS error codes indicate API misuse |
rc!=0 runtime | ⚠️ Check — may be acceptable (missing input file) |
| TIMEOUT | ✅ Pass — Console.ReadLine() treated as successful completion |
Common CS Error Codes
| Code | Meaning | Fix |
| CS1061 | Member does not exist | Check correct property/method name |
| CS0200 | Property is read-only | Access via .Value instead of assignment |
| CS0029 | Cannot convert type | Use correct enum type (BOOL not bool) |
| CS0117 | Name does not exist in type | Check enum member name casing |
| CS0234 | Namespace not found | Add correct using directive |
Pipeline
| Attempt | Strategy | Trigger |
| 1 | MCP direct retrieval + code assembly | Always |
| 2 | MCP retrieval with injected rules | Attempt 1 fails |
| 3 | LLM repair with compiler errors + rules | Attempt 2 fails |
Only examples that pass both dotnet build and dotnet run are committed.
General Tips
- See root agents.md for repository-wide boundaries, anti-patterns, domain knowledge, and testing guidelines
- Always check
rules/rules.jsonfor the latest API correction rules - SaveFileFormat enum must always be PascalCase:
Vsdx,Pdf,Png,Jpeg,Svg,Html— never ALL_CAPS - Diagram class does NOT implement IDisposable — never use
using (Diagram ...)
Key API Surface
AddShapeDiagramFontsHTMLSaveOptionsImageSaveOptionsPagePagesPdfSaveOptionsSaveShapesdiagrampageshape
Real-World Use Cases
Common scenarios where Aspose.Diagram for .NET working with diagrams capabilities are applied in production applications:
- Merging multiple Visio files into a single consolidated diagram
- Inspecting and reporting on diagram structure and properties
- Automating diagram cleanup and normalization operations
Developer Q&A
Frequently asked questions about Working With Diagrams in Aspose.Diagram for .NET:
Q: How do I get started with Working With Diagrams in Aspose.Diagram for .NET?
A: Add a reference to Aspose.Diagram.dll (v26.9.0), include using Aspose.Diagram; and using Aspose.Diagram.Saving;, then use Diagram diagram = new Diagram("input.vsdx"); to load a file. All examples in this category target net8.0.
Q: Why do I get CS1674 when using using (Diagram diagram = ...)?
A: Diagram does not implement IDisposable in Aspose.Diagram for .NET. Remove the using statement and declare the variable normally: Diagram diagram = new Diagram("input.vsdx");
Q: Why does my code fail with CS0117 on SaveFileFormat.VSDX?
A: SaveFileFormat enum members use PascalCase in Aspose.Diagram for .NET. Use SaveFileFormat.Vsdx (not VSDX). The same applies to all formats: SaveFileFormat.Pdf, SaveFileFormat.Png, SaveFileFormat.Svg.
Q: Why do I get CS0029 when assigning true to a BOOL property?
A: Aspose.Diagram uses its own BOOL enumeration type, not C# bool. Use BOOL.True and BOOL.False instead of plain true/false for all Aspose.Diagram BOOL properties.
Q: How do I connect two shapes with a connector?
A: Add a connector shape: Shape connector = new Shape(); long connId = diagram.AddShape(connector, "Dynamic connector", pageIndex); then call page.ConnectShapesViaConnector(shape1Id, ConnectionPointPlace.Right, shape2Id, ConnectionPointPlace.Bottom, connId);
Related Categories
- Basic Operations — loading, saving, and basic diagram operations
- Working With Pages — page management and navigation
- Working With Masters — master shapes and stencils
Category Statistics
- Total examples: 40
- Failed: 0
- Pass rate: 100.0%
Failed Tasks
All tasks passed ✅
Updated: 2026-09-24 | Examples: 40 | Pass Rate: 100.0% | ↑ Root agents.md | Aspose.Diagram for .NET
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

