agentic-net-examples / security-and-protection
AGENTS.md4 starsChanged 3 months agoMITView on GitHub
Verified C# examples for security-and-protection scenarios in Aspose.Words for .NET
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,773 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 repository29 other files it gives its agents.
- aspose-words-examplesAGENTS.md
- barcode-imageAGENTS.md
- chartsAGENTS.md
- commentsAGENTS.md
- comparisonAGENTS.md
- content-controlAGENTS.md
- conversionAGENTS.md
- extractionAGENTS.md
- find-and-replaceAGENTS.md
- fontsAGENTS.md
- form-fieldsAGENTS.md
- hyphenationAGENTS.md
- imagesAGENTS.md
- join-documentsAGENTS.md
- linq-reportingAGENTS.md
- listsAGENTS.md
- mail-mergeAGENTS.md
- officemathAGENTS.md
- ole-objectsAGENTS.md
- paragraphsAGENTS.md
- programming-with-documentsAGENTS.md
- rangeAGENTS.md
- renderingAGENTS.md
- shapesAGENTS.md
- split-documentAGENTS.md
- track-changesAGENTS.md
- vba-macrosAGENTS.md
- watermarkAGENTS.md
- working-with-tableAGENTS.md
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Always use documented Aspose.Words APIs directly.
- Distinctive: line 18
Always create local sample source documents when a task refers to an existing file, folder, stream, template, or input asset.
- Very specific: line 19
Prefer Document.Protect, Document.Unprotect, LoadOptions, and documented format-specific save options.
- Distinctive: line 20
Keep validation narrow and task-specific.
- Distinctive: line 21
Do not invent encryption, permission, or protection helper APIs.
- Distinctive: line 27
Use the simplest workflow that satisfies the task.
- Distinctive: line 240
When replacing a file, prefer the latest verified publish-ready version rather than a merely compiling draft.
- Distinctive: line 241
Keep examples standalone, bootstrap missing inputs locally, and prefer documented Aspose APIs over speculative shortcuts.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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
AGENTS.md - Security and Protection
Purpose
This folder is a live, curated example set for security-and-protection scenarios. Treat every .cs file as a standalone console application. The goal is correct, warning-free examples that use documented Aspose APIs and match the original task intent.
Non-negotiable conventions
- Always use documented Aspose.Words APIs directly.
- Always create local sample source documents when a task refers to an existing file, folder, stream, template, or input asset.
- Prefer
Document.Protect,Document.Unprotect,LoadOptions, and documented format-specific save options. - Keep validation narrow and task-specific.
- Do not invent encryption, permission, or protection helper APIs.
Recommended workflow selection
- Security Workflow workflow: 30 examples
Use the simplest workflow that satisfies the task.
Validation priorities
- The code must compile and run without manual input.
- API usage must be supported by the configured package versions.
- Exported outputs must actually be written by the example.
- Validation scenarios must inspect only the behavior requested by the task.
- Examples that depend on files, folders, streams, images, or data should bootstrap those inputs locally during the example run.
File-to-task reference
create-a-cancellationtokensource-and-pass-its-token-to-document-load-to-enable-interruptio.cs- Task: Create a CancellationTokenSource and pass its token to Document.Load to enable interruption.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
attach-a-callback-to-documentloadingargs-throwifcancellationrequested-during-loading-to-en.cs- Task: Attach a callback to DocumentLoadingArgs.ThrowIfCancellationRequested during loading to ensure proper response.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
use-token-throwifcancellationrequested-inside-a-field-update-loop-to-abort-long-running-op.cs- Task: Use token.ThrowIfCancellationRequested inside a field update loop to abort long-running operations efficiently.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
implement-a-low-code-ui-button-that-calls-cancellationtokensource-cancel-to-stop-processin.cs- Task: Implement a low-code UI button that calls CancellationTokenSource.Cancel to stop processing immediately.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
combine-a-cancellationtoken-with-document-saveasync-to-allow-asynchronous-saving-cancellat.cs- Task: Combine a CancellationToken with Document.SaveAsync to allow asynchronous saving cancellation by checking token status.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
monitor-token-iscancellationrequested-during-layout-building-and-exit-the-layout-routine-p.cs- Task: Monitor token.IsCancellationRequested during layout building and exit the layout routine promptly if needed.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
handle-operationcanceledexception-after-a-cancelled-document-load-to-perform-necessary-cle.cs- Task: Handle OperationCanceledException after a cancelled Document.Load to perform necessary cleanup properly.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
log-cancellation-events-with-timestamps-to-an-audit-file-for-compliance-tracking.cs- Task: Log cancellation events with timestamps to an audit file for compliance tracking.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
pass-the-same-cancellationtoken-to-both-loading-and-saving-methods-for-consistent-interrup.cs- Task: Pass the same CancellationToken to both loading and saving methods for consistent interruption control.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
use-token-iscancellationrequested-in-a-custom-linq-reporting-engine-query-to-abort-large-r.cs- Task: Use token.IsCancellationRequested in a custom LINQ Reporting Engine query to abort large reports.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
wrap-a-batch-of-document-load-calls-in-a-foreach-loop-that-checks-token-cancellation-befor.cs- Task: Wrap a batch of Document.Load calls in a foreach loop that checks token cancellation before each load.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
configure-documentloadingargs-to-invoke-a-user-defined-method-when-cancellation-is-request.cs- Task: Configure DocumentLoadingArgs to invoke a user-defined method when cancellation is requested during loading.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
integrate-cancellationtoken-into-a-background-worker-that-processes-documents-without-bloc.cs- Task: Integrate CancellationToken into a background worker that processes documents without blocking the UI.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
validate-that-long-running-field-updates-respect-the-token-by-inserting-periodic-cancellat.cs- Task: Validate that long-running field updates respect the token by inserting periodic cancellation checks.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
create-a-reusable-helper-method-accepting-a-cancellationtoken-to-perform-safe-document-pro.cs- Task: Create a reusable helper method accepting a CancellationToken to perform safe document processing.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
ensure-resource-leaks-are-prevented-by-disposing-the-document-object-after-catching-operat.cs- Task: Ensure resource leaks are prevented by disposing the Document object after catching OperationCanceledException.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
use-token-throwifcancellationrequested-inside-a-custom-image-extraction-routine-to-stop-ea.cs- Task: Use token.ThrowIfCancellationRequested inside a custom image extraction routine to stop early if needed.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
combine-token-monitoring-with-progress-reporting-to-inform-users-when-cancellation-occurs.cs- Task: Combine token monitoring with progress reporting to inform users when cancellation occurs during processing.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
implement-a-timeout-mechanism-that-triggers-cancellationtokensource-cancel-after-a-predefi.cs- Task: Implement a timeout mechanism that triggers CancellationTokenSource.Cancel after a predefined duration automatically.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
pass-the-token-to-documentbuilder-operations-to-allow-interruption-while-constructing-comp.cs- Task: Pass the token to DocumentBuilder operations to allow interruption while constructing complex documents.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
test-cancellation-behavior-by-simulating-user-aborts-during-document-layout-generation-in.cs- Task: Test cancellation behavior by simulating user aborts during document layout generation in unit tests.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
document-the-required-net-version-for-cancellationtoken-support-in-the-project-s-readme-fi.cs- Task: Document the required .NET version for CancellationToken support in the project's README file.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
use-token-iscancellationrequested-within-a-while-loop-processing-document-nodes-to-enable.cs- Task: Use token.IsCancellationRequested within a while loop processing document nodes to enable graceful exit.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
provide-a-configuration-setting-that-enables-or-disables-cancellation-support-for-specific.cs- Task: Provide a configuration setting that enables or disables cancellation support for specific processing stages.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
capture-and-log-the-stack-trace-when-operationcanceledexception-is-thrown-for-debugging-pu.cs- Task: Capture and log the stack trace when OperationCanceledException is thrown for debugging purposes.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
apply-token-checks-before-invoking-external-resource-retrieval-to-avoid-unnecessary-networ.cs- Task: Apply token checks before invoking external resource retrieval to avoid unnecessary network calls.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
create-an-extension-method-that-adds-cancellation-support-to-existing-synchronous-document.cs- Task: Create an extension method that adds cancellation support to existing synchronous Document.Save calls.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
ensure-that-the-cancellationtokensource-is-disposed-after-processing-completes-to-free-sys.cs- Task: Ensure that the CancellationTokenSource is disposed after processing completes to free system resources.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
demonstrate-chaining-multiple-cancellationtokens-using-cancellationtokensource-createlinke.cs- Task: Demonstrate chaining multiple CancellationTokens using CancellationTokenSource.CreateLinkedTokenSource for complex workflows in applications.
- Workflow: security-workflow
- Outputs: docx
- Selected engine: mcp
verify-that-document-processing-pipelines-respect-cancellation-when-integrated-with-third.cs- Task: Verify that document processing pipelines respect cancellation when integrated with third-party reporting tools.
- Workflow: security-workflow
- Outputs: doc
- Selected engine: mcp
Common failure patterns and preferred agent fixes
- Unsupported API invention
- Symptom: Generated code references members that do not exist in the selected package version.
- Preferred fix: Replace invented members with documented Aspose.Words APIs already proven in this category.
- Missing local bootstrap inputs
- Symptom: The example assumes source files, folders, images, or data already exist.
- Preferred fix: Create deterministic local inputs before loading, processing, or validating them.
- Over-broad validation
- Symptom: The example fails at runtime while checking unrelated document internals.
- Preferred fix: Validate only the requested behavior and the existence of expected outputs.
Build and run contract
- Target framework:
net8.0 - Package:
Aspose.Words26.9.0
Command reference
Create a temporary console project
dotnet new console -n ExampleProject --framework net8.0
cd ExampleProjectAdd required packages
dotnet add package Aspose.Words --version 26.9.0Copy a category example into the temp project
Copy-Item ..\security-and-protection\<example-file>.cs .\Program.csBuild and run
dotnet build --configuration Release --verbosity minimal
dotnet run --configuration Release --no-buildCategory update guidance
- Preserve file-to-task traceability. Any future update should keep the original task text associated with the file in metadata.
- When replacing a file, prefer the latest verified publish-ready version rather than a merely compiling draft.
- Keep examples standalone, bootstrap missing inputs locally, and prefer documented Aspose APIs over speculative shortcuts.
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.

