agentleFS
aspose-diagramaspose-diagram/agentic-net-examples/working-with-text/agents.md

agentic-net-examples / working-with-text

AGENTS.md1 starsChanged 4 months agoMITView on GitHub

AI-generated, compiler-validated C# examples for the Aspose.Diagram for .NET API — Working With Text category. You are a C# developer specializing in Visio diagram processing using Aspose.Diagram for .NET. You are working in the Working With Text category. Your task is to write clean, compilable C# console examples that demonstrate Aspose.Diagram API usage for working with text operations. You always use explicit types (never var), include all required using directives, and follow the patterns established in this category. The dominant…

The file

Show its rules and text

We split this agents.md into the rules it gives an agent

14 rules. About 0 are common, 4 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    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
  1. Very specific:

    Use explicit types — Diagram diagram = new Diagram(...) not var diagram = ...

    line 38
  2. Very specific:

    Use SaveFileFormat enum in PascalCase: SaveFileFormat.Vsdx, SaveFileFormat.Pdf

    line 40
  3. Very specific:

    Use BOOL.True / BOOL.False for Aspose BOOL properties — never plain true/false

    line 41
  4. Very specific:

    Use var for any variable declaration

    line 53
  5. Very specific:

    Use using (Diagram diagram = ...) — Diagram does not implement IDisposable

    line 54
  6. Very specific:

    Use SaveFileFormat.VSDX or other ALL_CAPS enum values

    line 55
  7. Very specific:

    Use System.Windows.Forms — not available in net8.0 console project

    line 56
  8. Very specific:

    Use NUnit Assert — not available, use Console.WriteLine and manual checks

    line 57
  9. Distinctive:

    Use PowerShell syntax inside C# files

    line 58
  10. Distinctive:

    UPDATE SHAPE TEXT — Clear existing text and add new: shape.Text.Value.Clear().

    line 107
  11. Distinctive:

    Add character run markers with Cp(index) before each Txt: shape.Text.Value.Add(new Cp(0)).

    line 112
  12. Distinctive:

    Add matching Char objects to shape.Chars: shape.Chars.Add(new Aspose.Diagram.Char()).

    line 113
  13. Very specific:

    Only examples that pass both dotnet build and dotnet run are committed.

    line 282
  14. Very specific:

    Always check rules/rules.json for the latest API correction rules

    line 287

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
agents.md

Working With Text

AI-generated, compiler-validated C# examples for the Aspose.Diagram for .NET API — Working With Text category.

Statistics

MetricValue
Examples89
Pass Rate100.0%
Aspose.Diagram Version26.9.0
Target Frameworknet8.0
Last Updated2026-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 Text category. Your task is to write clean, compilable C# console examples that demonstrate Aspose.Diagram API usage for working with text 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(...) not var diagram = ...
  • Include using Aspose.Diagram; and using Aspose.Diagram.Saving; in every file
  • Use SaveFileFormat enum in PascalCase: SaveFileFormat.Vsdx, SaveFileFormat.Pdf
  • Use BOOL.True / BOOL.False for Aspose BOOL properties — never plain true/false
  • Wrap entry point in static void Main() inside class Program
  • Handle FileNotFoundException with 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 var for any variable declaration
  • Use using (Diagram diagram = ...) — Diagram does not implement IDisposable
  • Use SaveFileFormat.VSDX or other ALL_CAPS enum values
  • Use System.Windows.Forms — not available in net8.0 console project
  • Use NUnit Assert — not available, use Console.WriteLine and manual checks
  • Use PowerShell syntax inside C# files

Required Namespaces

NamespaceFilesPurpose
System89Console, Math, DateTime, Exception
Aspose.Diagram88Core diagram API
System.IO74File, Stream, Path, Directory operations
Aspose.Diagram.Saving45Save options (PDF, PNG, HTML, SVG, XPS)
System.Collections.Generic7List, Dictionary, HashSet
System.Linq5LINQ queries on collections
System.Text5StringBuilder
System.Text.RegularExpressions4Supporting utilities
Aspose.Drawing.Text1Font enumeration via InstalledFontCollection
System.Text.Json1JSON serialization

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);
    }
}

Domain Knowledge

Category-specific API rules and gotchas:

  • INSERT TEXT SHAPE — Use page.AddText(pinX, pinY, width, height, text) to add a standalone text shape to a page. Returns a Shape object. Example: diagram.Pages[0].AddText(1, 1, 1, 1, "Test text");
  • WATERMARK — Use the overloaded page.AddText(pinX, pinY, width, height, text, fontName, fontColor, fontSize) to add a watermark. Calculate center position using page.PageSheet.PageProps.PageWidth.Value / 2 and PageHeight.Value / 2. Example: page.AddText(pinx, piny, width, height, "Watermark", "Calibri", "#a5a5a5", 0.25);
  • WATERMARK FULL PAGE — Set width and height to the full page dimensions: double width = page.PageSheet.PageProps.PageWidth.Value; double height = page.PageSheet.PageProps.PageHeight.Value; then call page.AddText(pinx, piny, width, height, text, fontName, fontColor, fontSize);
  • UPDATE SHAPE TEXT — Clear existing text and add new: shape.Text.Value.Clear(); shape.Text.Value.Add(new Txt("New Text"));
  • FIND SHAPE FOR TEXT UPDATE — Iterate page.Shapes and match by shape.NameU.ToLower() == "process" && shape.ID == 1 or by shape.Name == "targetName".
  • APPLY STYLESHEET — Set shape.TextStyle, shape.FillStyle, shape.LineStyle to a StyleSheet object found by iterating diagram.StyleSheets and matching by styleSheet.Name == "Basic".
  • Example: foreach (StyleSheet ss in diagram.StyleSheets) { if (ss.Name == "Basic") { shape.TextStyle = ss; shape.FillStyle = ss; shape.LineStyle = ss; break; } }
  • MULTIPLE TEXT RUNS WITH DIFFERENT STYLES — Clear shape text and chars first: shape.Text.Value.Clear(); shape.Chars.Clear();
  • Add character run markers with Cp(index) before each Txt: shape.Text.Value.Add(new Cp(0)); shape.Text.Value.Add(new Txt("Regular text\n")); shape.Text.Value.Add(new Cp(1)); shape.Text.Value.Add(new Txt("Bold text\n"));
  • Add matching Char objects to shape.Chars: shape.Chars.Add(new Aspose.Diagram.Char()); — one per Cp index.

Examples

FileKey APIsTask
add-a-footer-text-watermark-that-includes-document-title-and-version-number.csDiagram, Save, diagramAdd a footer text watermark that includes document title and version number
add-a-timestamp-watermark-that-updates-each-time-the-file-is-saved.csDiagram, Pages, PdfSaveOptionsAdd a timestamp watermark that updates each time the file is saved
adjust-watermark-opacity-to-a-configurable-value-between-10-and-90.csDiagram, Pages, SaveAdjust watermark opacity to a configurable value between 10 and 90
allow-users-to-specify-watermark-rotation-angle-in-degrees-via-configuration.csDiagram, Pages, SaveAllow users to specify watermark rotation angle in degrees via configuration
apply-a-custom-color-to-the-watermark-text-based-on-user-defined-palette.csDiagram, Pages, SaveApply a custom color to the watermark text based on user defined palette
apply-a-custom-stylesheet-that-changes-text-color-based-on-shape-type-then-validate-color-assignments.csDiagram, Pages, SaveApply a custom stylesheet that changes text color based on shape type then validate color assignments
apply-a-custom-stylesheet-that-defines-paragraph-spacing-then-verify-spacing-changes-on-target-shapes.csAddShape, Diagram, PagesApply a custom stylesheet that defines paragraph spacing then verify spacing changes on target shapes
apply-a-custom-stylesheet-that-defines-text-alignment-then-align-all-paragraph-texts-to-center-on-page-two.csDiagram, Pages, SaveApply a custom stylesheet that defines text alignment then align all paragraph texts to center on page two
apply-a-custom-stylesheet-that-defines-underline-style-then-underline-all-headings-in-the-diagram.csDiagram, Pages, SaveApply a custom stylesheet that defines underline style then underline all headings in the diagram
apply-a-custom-stylesheet-that-sets-line-height-then-verify-line-spacing-on-multi-line-text-shapes.csDiagram, Pages, SaveApply a custom stylesheet that sets line height then verify line spacing on multi line text shapes
apply-a-custom-stylesheet-to-all-shapes-containing-the-word-important-to-highlight-them-visually.csDiagram, Pages, SaveApply a custom stylesheet to all shapes containing the word important to highlight them visually
apply-a-custom-stylesheet-with-specific-font-and-size-to-all-title-shapes-across-the-diagram.csDiagram, Pages, SaveApply a custom stylesheet with specific font and size to all title shapes across the diagram
apply-built-in-caption-style-to-all-shapes-on-page-five-to-ensure-consistent-footnote-formatting.csDiagram, Pages, SaveApply built in caption style to all shapes on page five to ensure consistent footnote formatting
apply-built-in-caption-style-to-shapes-whose-text-length-is-less-than-ten-characters-for-uniform-captions.csDiagram, Pages, SaveApply built in caption style to shapes whose text length is less than ten characters for uniform captions
apply-built-in-emphasis-style-to-all-bullet-list-shapes-to-enhance-readability-in-presentations.csDiagram, Pages, SaveApply built in emphasis style to all bullet list shapes to enhance readability in presentations
apply-built-in-emphasis-style-to-shapes-containing-the-word-alert-to-highlight-critical-information.csDiagram, Pages, SaveApply built in emphasis style to shapes containing the word alert to highlight critical information
apply-built-in-subtitle-style-to-shapes-whose-text-starts-with-a-numeric-prefix-for-consistency.csDiagram, Pages, SaveApply built in subtitle style to shapes whose text starts with a numeric prefix for consistency
apply-built-in-title-style-to-shapes-whose-text-length-exceeds-twenty-characters-for-consistency.csDiagram, Pages, SaveApply built in title style to shapes whose text length exceeds twenty characters for consistency
apply-built-in-title-style-to-shapes-whose-text-matches-a-regular-expression-pattern-for-dates.csDiagram, Pages, SaveApply built in title style to shapes whose text matches a regular expression pattern for dates
apply-the-built-in-heading-1-stylesheet-to-shape-id-10-for-standardized-title-formatting.csDiagram, Pages, SaveApply the built in heading 1 stylesheet to shape id 10 for standardized title formatting
apply-the-watermark-to-all-pages-in-the-loaded-visio-document.csDiagram, Pages, SaveApply the watermark to all pages in the loaded visio document
change-watermark-font-style-and-size-according-to-user-preferences.csDiagram, Pages, SaveChange watermark font style and size according to user preferences
create-a-batch-job-that-loads-diagrams-updates-footer-text-with-the-current-timestamp-and-saves-them.csDiagram, Save, diagramCreate a batch job that loads diagrams updates footer text with the current timestamp and saves them
create-a-batch-operation-that-loads-diagrams-rotates-all-title-shape-texts-by-180-degrees-and-saves.csDiagram, Pages, SaveCreate a batch operation that loads diagrams rotates all title shape texts by 180 degrees and saves
create-a-batch-process-that-adds-numbered-text-shapes-to-each-page-using-the-page-index-as-label.csDiagram, Pages, SaveCreate a batch process that adds numbered text shapes to each page using the page index as label
create-a-batch-script-that-loads-diagrams-applies-a-custom-stylesheet-and-saves-them-as-updated-files.csDiagram, Pages, SaveCreate a batch script that loads diagrams applies a custom stylesheet and saves them as updated files
create-a-function-that-adds-a-caption-text-shape-below-each-image-using-the-image-name-as-text.csDiagram, Pages, SaveCreate a function that adds a caption text shape below each image using the image name as text
create-a-macro-that-iterates-through-pages-and-appends-the-configured-watermark.csDiagram, Pages, SaveCreate a macro that iterates through pages and appends the configured watermark
create-a-new-diagram-and-add-a-text-shape-at-coordinates-2-3-with-specified-dimensions-and-content.csDiagram, Pages, SaveCreate a new diagram and add a text shape at coordinates 2 3 with specified dimensions and content
create-a-script-that-adds-a-footer-text-shape-to-every-page-displaying-the-page-number-dynamically.csDiagram, Save, diagramCreate a script that adds a footer text shape to every page displaying the page number dynamically
create-a-semi-transparent-text-watermark-layer-for-the-current-page.csDiagram, Pages, SaveCreate a semi transparent text watermark layer for the current page
create-a-utility-that-adds-a-legend-text-shape-describing-color-codes-used-in-styled-shapes.csDiagram, Pages, SaveCreate a utility that adds a legend text shape describing color codes used in styled shapes
create-a-utility-that-adds-a-watermark-text-shape-diagonally-across-each-page-with-thirty-percent-opacity.csDiagram, Pages, SaveCreate a utility that adds a watermark text shape diagonally across each page with thirty percent opacity
document-the-watermark-addition-workflow-with-code-examples-and-usage-guidelines.csDiagram, Pages, PdfSaveOptionsDocument the watermark addition workflow with code examples and usage guidelines
ensure-the-watermark-does-not-obscure-shape-text-by-setting-appropriate-layering.csDiagram, Pages, SaveEnsure the watermark does not obscure shape text by setting appropriate layering
ensure-the-watermark-respects-page-margins-and-does-not-extend-beyond-printable-area.csDiagram, Pages, SaveEnsure the watermark respects page margins and does not extend beyond printable area
export-the-modified-diagram-to-a-new-vsdx-file-preserving-original-content.csPages, Save, diagramExport the modified diagram to a new vsdx file preserving original content
extract-plain-text-from-a-diagram-count-total-word-occurrences-and-generate-a-frequency-report.csDiagram, Pages, ShapesExtract plain text from a diagram count total word occurrences and generate a frequency report
extract-plain-text-from-a-diagram-filter-out-numeric-strings-and-save-the-cleaned-content.csDiagram, Pages, ShapesExtract plain text from a diagram filter out numeric strings and save the cleaned content
extract-plain-text-from-a-diagram-filter-out-stopwords-and-generate-a-concise-summary-paragraph.csDiagram, Pages, ShapesExtract plain text from a diagram filter out stopwords and generate a concise summary paragraph
extract-plain-text-from-a-diagram-remove-all-punctuation-and-save-the-sanitized-text-to-a-log-file.csDiagram, Pages, ShapesExtract plain text from a diagram remove all punctuation and save the sanitized text to a log file
extract-plain-text-from-each-page-concatenate-the-results-and-generate-a-summary-report-file.csDiagram, Pages, ShapesExtract plain text from each page concatenate the results and generate a summary report file
extract-plain-text-from-each-page-create-a-csv-file-with-page-number-and-text-content-for-analysis.csDiagram, Pages, ShapesExtract plain text from each page create a csv file with page number and text content for analysis
extract-plain-text-from-each-shape-compute-character-count-and-annotate-each-shape-with-its-length.csDiagram, Pages, SaveExtract plain text from each shape compute character count and annotate each shape with its length
extract-plain-text-from-each-shape-sort-the-texts-alphabetically-and-output-the-ordered-list-to-a-file.csDiagram, Pages, ShapesExtract plain text from each shape sort the texts alphabetically and output the ordered list to a file
extract-plain-text-from-page-one-of-the-loaded-diagram-and-write-it-to-a-utf-8-encoded-file.csDiagram, Pages, ShapesExtract plain text from page one of the loaded diagram and write it to a utf 8 encoded file
find-and-replace-the-phrase-draft-with-final-across-all-shapes-on-page-two-of-the-diagram.csDiagram, Pages, SaveFind and replace the phrase draft with final across all shapes on page two of the diagram
find-and-replace-the-placeholder-date-with-the-current-system-date-in-all-shapes-on-page-three.csDiagram, Pages, SaveFind and replace the placeholder date with the current system date in all shapes on page three
find-and-replace-the-string-v1-0-with-v2-0-in-shapes-that-have-a-custom-property-version-set.csDiagram, Pages, SaveFind and replace the string v1 0 with v2 0 in shapes that have a custom property version set
find-and-replace-the-string-version-1-0-with-version-2-0-only-on-shapes-on-the-first-page.csDiagram, Pages, SaveFind and replace the string version 1 0 with version 2 0 only on shapes on the first page
find-shapes-containing-the-word-confidential-and-replace-it-with-public-while-preserving-other-text.csDiagram, Pages, SaveFind shapes containing the word confidential and replace it with public while preserving other text
find-shapes-with-empty-text-fields-and-automatically-populate-them-with-a-generated-unique-identifier.csDiagram, Pages, SaveFind shapes with empty text fields and automatically populate them with a generated unique identifier
generate-a-preview-image-of-each-page-with-the-watermark-overlay-for-verification.csDiagram, ImageSaveOptions, PagesGenerate a preview image of each page with the watermark overlay for verification
handle-missing-font-exceptions-when-rendering-watermark-text-on-loaded-diagrams.csDiagram, Pages, PdfSaveOptionsHandle missing font exceptions when rendering watermark text on loaded diagrams
implement-batch-processing-to-add-watermarks-to-all-vsdx-files-in-a-folder.csDiagram, Pages, SaveImplement batch processing to add watermarks to all vsdx files in a folder
insert-an-image-watermark-behind-existing-shapes-on-each-page.csAddShape, Diagram, PagesInsert an image watermark behind existing shapes on each page
iterate-through-characters-of-a-shape-s-text-change-font-size-for-numeric-characters-and-keep-others-unchanged.csDiagram, Pages, SaveIterate through characters of a shape s text change font size for numeric characters and keep others unchanged
iterate-through-characters-of-a-shape-s-text-underline-vowels-and-leave-consonants-unchanged.csDiagram, Pages, SaveIterate through characters of a shape s text underline vowels and leave consonants unchanged
iterate-through-each-character-in-shape-id-7-assigning-bold-formatting-to-the-first-three-characters.csDiagram, Pages, SaveIterate through each character in shape id 7 assigning bold formatting to the first three characters
load-a-custom-vss-file-and-apply-the-customstyle-stylesheet-to-shape-id-12-for-unique-appearance.csDiagram, Pages, SaveLoad a custom vss file and apply the customstyle stylesheet to shape id 12 for unique appearance
load-a-diagram-find-shapes-with-empty-text-and-populate-them-with-default-placeholder-values.csDiagram, Pages, SaveLoad a diagram find shapes with empty text and populate them with default placeholder values
load-a-diagram-find-shapes-with-text-longer-than-one-hundred-characters-and-truncate-them-with-ellipsis.csDiagram, Pages, SaveLoad a diagram find shapes with text longer than one hundred characters and truncate them with ellipsis
load-a-visio-diagram-from-a-vsdx-file-into-memory.csDiagram, Pages, diagramLoad a visio diagram from a vsdx file into memory
load-an-existing-vdx-file-retrieve-shape-id-5-and-replace-its-text-with-a-dynamic-string.csDiagram, Pages, SaveLoad an existing vdx file retrieve shape id 5 and replace its text with a dynamic string
load-multiple-vdx-files-from-a-directory-update-their-header-shapes-with-the-current-date-and-save-changes.csDiagram, Save, diagramLoad multiple vdx files from a directory update their header shapes with the current date and save changes
log-the-success-or-failure-of-watermark-addition-for-each-processed-file.csDiagram, Pages, SaveLog the success or failure of watermark addition for each processed file
optimize-watermark-rendering-performance-for-large-diagrams-with-many-pages.csDiagram, Pages, SaveOptimize watermark rendering performance for large diagrams with many pages
position-the-watermark-at-the-center-of-each-page-with-a-45-degree-rotation.csDiagram, Pages, SavePosition the watermark at the center of each page with a 45 degree rotation
provide-an-api-method-to-retrieve-current-watermark-settings-from-a-diagram.csDiagram, Pages, ShapesProvide an api method to retrieve current watermark settings from a diagram
provide-an-option-to-remove-existing-watermarks-from-a-diagram-before-adding-new-ones.csDiagram, Pages, SaveProvide an option to remove existing watermarks from a diagram before adding new ones
read-watermark-text-and-opacity-settings-from-a-configuration-file.csDiagram, Pages, SaveRead watermark text and opacity settings from a configuration file
replace-all-occurrences-of-the-ampersand-character-with-the-word-and-in-every-shape-s-text.csDiagram, Pages, SaveReplace all occurrences of the ampersand character with the word and in every shape s text
replace-all-occurrences-of-the-trademark-symbol-with-the-word-trademark-in-the-diagram.csDiagram, Pages, SaveReplace all occurrences of the trademark symbol with the word trademark in the diagram
replace-all-occurrences-of-the-word-confidential-with-public-only-in-shapes-tagged-as-review.csDiagram, Pages, SaveReplace all occurrences of the word confidential with public only in shapes tagged as review
replace-all-occurrences-of-todo-with-an-empty-string-and-log-affected-shape-ids.csDiagram, Pages, SaveReplace all occurrences of todo with an empty string and log affected shape ids
replace-double-spaces-in-shape-texts-with-single-spaces-to-improve-text-compactness-across-the-diagram.csDiagram, Pages, SaveReplace double spaces in shape texts with single spaces to improve text compactness across the diagram
replace-line-breaks-in-shape-text-with-spaces-to-ensure-single-line-display-in-exported-reports.csDiagram, Pages, SaveReplace line breaks in shape text with spaces to ensure single line display in exported reports
replace-placeholder-text-name-with-actual-user-names-in-every-shape-on-the-diagram-page.csDiagram, Pages, SaveReplace placeholder text name with actual user names in every shape on the diagram page
rotate-text-of-all-footer-shapes-by-one-hundred-eighty-degrees-to-display-upside-down-information-on-printed-pages.csDiagram, Pages, SaveRotate text of all footer shapes by one hundred eighty degrees to display upside down information on printed pages
rotate-text-of-shapes-on-page-five-by-minus-thirty-degrees-to-match-diagonal-layout-of-associated-graphics.csDiagram, Pages, SaveRotate text of shapes on page five by minus thirty degrees to match diagonal layout of associated graphics
rotate-the-text-of-shape-id-3-by-45-degrees-to-align-with-a-slanted-connector-line.csDiagram, Pages, SaveRotate the text of shape id 3 by 45 degrees to align with a slanted connector line
save-a-backup-copy-of-the-original-diagram-before-applying-any-watermark-changes.csDiagram, Pages, SaveSave a backup copy of the original diagram before applying any watermark changes
set-text-rotation-to-270-degrees-for-all-side-label-shapes-and-verify-orientation.csDiagram, Pages, SaveSet text rotation to 270 degrees for all side label shapes and verify orientation
set-text-rotation-to-90-degrees-for-all-shapes-on-page-three-to-create-vertical-labels.csDiagram, Pages, SaveSet text rotation to 90 degrees for all shapes on page three to create vertical labels
set-watermark-transparency-to-match-corporate-branding-guidelines-for-consistent-appearance.csDiagram, Pages, SaveSet watermark transparency to match corporate branding guidelines for consistent appearance
update-the-watermark-text-dynamically-based-on-metadata-stored-in-the-diagram.csDiagram, Pages, SaveUpdate the watermark text dynamically based on metadata stored in the diagram
use-a-diagonal-watermark-pattern-that-repeats-across-the-page-background.csDiagram, Page, PagesUse a diagonal watermark pattern that repeats across the page background
validate-that-the-watermark-appears-correctly-on-every-page-after-saving.csDiagram, Pages, SaveValidate that the watermark appears correctly on every page after saving
verify-that-the-watermark-does-not-increase-file-size-beyond-a-specified-limit.csDiagram, Pages, SaveVerify that the watermark does not increase file size beyond a specified limit

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 errors

Run Verification

dotnet run    # rc=0 = pass, rc!=0 with unhandled exception = fail

Expected Output Patterns

PatternMeaning
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

CodeMeaningFix
CS1061Member does not existCheck correct property/method name
CS0200Property is read-onlyAccess via .Value instead of assignment
CS0029Cannot convert typeUse correct enum type (BOOL not bool)
CS0117Name does not exist in typeCheck enum member name casing
CS0234Namespace not foundAdd correct using directive

Pipeline

AttemptStrategyTrigger
1MCP direct retrieval + code assemblyAlways
2MCP retrieval with injected rulesAttempt 1 fails
3LLM repair with compiler errors + rulesAttempt 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.json for 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

  • AddShape
  • Diagram
  • ImageSaveOptions
  • Page
  • Pages
  • PdfSaveOptions
  • Save
  • Shapes
  • StyleSheet
  • StyleSheets
  • diagram
  • page

Real-World Use Cases

Common scenarios where Aspose.Diagram for .NET working with text capabilities are applied in production applications:

  • Updating diagram labels from live data feeds or databases
  • Localizing diagram text for multi-language documentation
  • Searching and replacing text across large batches of Visio files

Developer Q&A

Frequently asked questions about Working With Text in Aspose.Diagram for .NET:

Q: How do I get started with Working With Text 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 get the plain text content of a shape?

A: Use shape.Text.Value.ToString() which concatenates all text runs. Never use shape.IsTextEmpty — it does not exist. Check emptiness with string.IsNullOrWhiteSpace(shape.Text.Value.ToString()).

Related Categories

Category Statistics

  • Total examples: 89
  • Failed: 0
  • Pass rate: 100.0%

Failed Tasks

All tasks passed ✅


Updated: 2026-09-24 | Examples: 89 | Pass Rate: 100.0% | ↑ Root agents.md | Aspose.Diagram for .NET

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.