<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ProofCloak Engineering]]></title><description><![CDATA[ProofCloak Engineering]]></description><link>https://proofcloak.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 15:07:24 GMT</lastBuildDate><atom:link href="https://proofcloak.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[What your .NET release looks like to everyone else, and how to change that without breaking it]]></title><description><![CDATA[Build a small .NET app in Release and open the DLL in ILSpy. You get your class names, your string constants and your license check back as C#. This post…]]></description><link>https://proofcloak.hashnode.dev/what-your-net-release-looks-like-to-everyone-else-and-how-to-change-that-without-breaking-it</link><guid isPermaLink="true">https://proofcloak.hashnode.dev/what-your-net-release-looks-like-to-everyone-else-and-how-to-change-that-without-breaking-it</guid><category><![CDATA[dotnet]]></category><category><![CDATA[C#]]></category><dc:creator><![CDATA[ProofCloak]]></dc:creator><pubDate>Sat, 14 Nov 2026 08:47:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aebcaf45e601a8bb634d509/30d2abeb-d07f-4046-b5cf-dd01b0a8522d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/ty1uise5b10alh9d6hh5.png" alt="The same InvoiceDesk method in ILSpy before and after protection" /></p>
<p>Build a small .NET app in Release and open the DLL in ILSpy. You get your class names, your string constants and your license check back as C#. This post shows that on a sample, protects the sample, and then checks what changed and what didn't.</p>
<h2>What ships today</h2>
<p>The sample is <a href="https://github.com/ProofCloak-Inc/sample-invoicedesk">InvoiceDesk</a>, an 11 KB console app with three things most commercial products have: a license check, a pricing rule, and a settings class it reads with <code>System.Text.Json</code>. Everything in it is <code>internal</code>, the way application code usually is.</p>
<p>Here is the license validator from the Release DLL, as printed by <code>ilspycmd</code> (ILSpy's command-line build):</p>
<pre><code class="language-csharp">internal static class LicenseValidator
{
    private static readonly string ProductSalt = "invoicedesk-pro-2026";

    internal static bool IsValid(string customerEmail, string licenseKey)
    {
        if (string.IsNullOrWhiteSpace(licenseKey) || licenseKey.Length != 29)
        {
            return false;
        }
        string s = ComputeKey(customerEmail);
        return CryptographicOperations.FixedTimeEquals(Encoding.ASCII.GetBytes(s), Encoding.ASCII.GetBytes(licenseKey.ToUpperInvariant()));
    }

    internal static string ComputeKey(string customerEmail)
    {
        string s = customerEmail.Trim().ToLowerInvariant() + ":" + ProductSalt;
        byte[] inArray = SHA256.HashData(Encoding.UTF8.GetBytes(s));
        string hex = Convert.ToHexString(inArray).Substring(0, 25);
        return string.Join("-", from i in Enumerable.Range(0, 5)
            select hex.Substring(i * 5, 5));
    }
}
</code></pre>
<p>The comments and a couple of local names are gone. Everything else is there, salt included. Anyone with the installer can write a key generator from this in a few minutes.</p>
<h2>Why it looks like that</h2>
<p>A managed assembly is IL plus metadata, and the metadata describes every type, member and signature so the runtime can load it without header files. Microsoft's docs call this <a href="https://learn.microsoft.com/en-us/dotnet/standard/metadata-and-self-describing-components">self-describing</a>. <a href="https://github.com/icsharpcode/ILSpy">ILSpy</a> reads the same metadata and turns the IL back into C#. A private repository protects your source. It has no effect on the binary you hand to customers.</p>
<p>Obfuscation raises the cost of reading and patching that binary. It doesn't make a secret in client code safe, and a determined analyst with a debugger still gets there.</p>
<h2>The trap: names are sometimes a file format</h2>
<p>The reason many teams give up on obfuscation is in the third class of the sample:</p>
<pre><code class="language-csharp">internal sealed class AppSettings
{
    public string CompanyName { get; set; } = "Example Ltd";
    public string DefaultCurrency { get; set; } = "EUR";
    public int PaymentTermDays { get; set; } = 30;

    public string ToJson() =&gt; JsonSerializer.Serialize(this);
    public static AppSettings FromJson(string json) =&gt;
        JsonSerializer.Deserialize&lt;AppSettings&gt;(json) ?? new();
}
</code></pre>
<p>A customer's settings file looks like <code>{"CompanyName":"Contoso Kft","DefaultCurrency":"HUF","PaymentTermDays":45}</code>. The property names are the file format. Rename <code>CompanyName</code> to <code>a</code> and the app compiles, starts, and reads every existing settings file as defaults. Nothing throws. Contoso's invoices go out under "Example Ltd" and you find out from a support ticket.</p>
<p>Reflection by name, convention-based dependency injection, XAML bindings and plugin interfaces fail the same way. The build stays green in all of them.</p>
<p>Two things protect you here, and you need both.</p>
<p><strong>Check before you protect.</strong> In the ProofCloak workspace, the profile is checked against the uploaded file before a job exists. Each requested protection gets its own verdict. In the November 8 precheck on an earlier build of InvoiceDesk, the selected profile asked for a protection the input did not qualify for.</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/y1pcrg00rch6bitq3fqq.png" alt="Precheck result: Not supported for this profile and route" /></p>
<p>The profile went no further. It did not run with that protection quietly dropped. With the protection removed, the same screen read "Supported for this profile and route" and listed each requested protection as allowed.</p>
<p>A precheck does not find every place your app depends on a name. Keep your own list of what you serialize, reflect over and load dynamically.</p>
<p><strong>Run the protected file, not the build.</strong> InvoiceDesk reads a settings file written by an "earlier release" and prints what it found. Before and after protection:</p>
<pre><code class="language-text">License valid: True
Total (HU): 1567.73
Settings file: Contoso Kft, HUF, 45 days
Settings saved: {"CompanyName":"Contoso Kft","DefaultCurrency":"HUF","PaymentTermDays":45}
</code></pre>
<p>In this run, both builds read the same settings and printed the same serialized JSON. Four lines is a toy test. The point is that it ran against the protected DLL.</p>
<h2>The same class, protected</h2>
<p>The profile was renaming, string protection, control-flow rewriting and anti-tamper checks. This is <code>ilspycmd</code> on the output:</p>
<pre><code class="language-csharp">internal static class AvaebCaldbbwcdbJbgbCd
{
    [CompilerGenerated]
    private sealed class ApaVbWdscRaaecaAebbwb
    {
        public string hex;

        internal string AQaYaUdzdmeAebaqeIava(int i)
        {
            return hex.Substring(i * 5, 5);
        }
    }

    private static readonly string ADaPdreGapeTbUcMbXcNc = ArcJaBddbgbibiajaZbLd.AqdhbaagckcPaIcAaybCa(608177074, 145956453, -2074505810, 392448148, cacheResult: true);

    internal static bool AueLdCaUcecNbAaIdYbDe(string customerEmail, string licenseKey)
    {
        int num = -231558403;
        while (true)
        {
            switch ((num - 2000301672) ^ 0x7AF88495)
            {
            case 2:
                return false;
            case 3:
            {
                string s = ACaxbydBdpeMcHbmbhcFe(customerEmail);
                return CryptographicOperations.FixedTimeEquals(Encoding.ASCII.GetBytes(s), Encoding.ASCII.GetBytes(licenseKey.ToUpperInvariant()));
            }
            default:
                num = (string.IsNullOrWhiteSpace(licenseKey) ? (-231558401) : (-231558404));
                break;
            case 1:
                num = ((licenseKey.Length == 29) ? (-231558402) : (-231558401));
                break;
            }
        }
    }

    internal static string ACaxbydBdpeMcHbmbhcFe(string customerEmail)
    {
        string s = customerEmail.Trim().ToLowerInvariant() + ":" + ADaPdreGapeTbUcMbXcNc;
        byte[] inArray = SHA256.HashData(Encoding.UTF8.GetBytes(s));
        string hex = Convert.ToHexString(inArray).Substring(0, 25);
        return string.Join("-", from i in Enumerable.Range(0, 5)
            select hex.Substring(i * 5, 5));
    }
}
</code></pre>
<p>What changed:</p>
<ul>
<li>The class, both methods and the field have generated names. Nothing says "license" any more.</li>
<li>The salt is gone from the file. The field is filled by a decryptor call, and a search for <code>invoicedesk-pro-2026</code> in the DLL finds nothing.</li>
<li>The branch in <code>IsValid</code> is a state machine driven by an opaque integer.</li>
</ul>
<p>What didn't, and you should know this before you rely on it:</p>
<ul>
<li>Framework calls are still visible. You can see that something is hashed with SHA-256 and compared in fixed time. This profile doesn't hide call targets.</li>
<li>Parameter names (<code>customerEmail</code>, <code>licenseKey</code>) are still there.</li>
<li>In <code>AppSettings</code>, the class name and the backing fields were renamed, and the public properties <code>CompanyName</code>, <code>DefaultCurrency</code> and <code>PaymentTermDays</code> were not. That is deliberate: public properties are treated as a possible data contract, and it is why the settings file above still loads.</li>
</ul>
<p>One more thing we learned the hard way. The first version of this sample declared the salt as a <code>const</code>. The compiler stores a <code>const</code> as a literal in metadata, and the profile we used doesn't encrypt constant fields, so the salt was still readable in the protected file. For this demonstration we changed the sample value to <code>static readonly</code> and inspected the protected output again. We only caught it because we opened the protected file, which is the argument for the next section.</p>
<h2>Every protected build explains itself</h2>
<p>The job page compares the input and the output with the same inspection schema, and the job ends with an execution receipt:</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/sa0s42opjj74k4ai41u9.png" alt="Job page before/after panel and receipt excerpt" /></p>
<table>
<thead>
<tr>
<th></th>
<th>Input</th>
<th>Protected</th>
</tr>
</thead>
<tbody><tr>
<td>Size</td>
<td>11,264 bytes</td>
<td>19,968 bytes</td>
</tr>
<tr>
<td>Types</td>
<td>7</td>
<td>10</td>
</tr>
<tr>
<td>Methods</td>
<td>40</td>
<td>62</td>
</tr>
<tr>
<td>Fields</td>
<td>11</td>
<td>25</td>
</tr>
<tr>
<td>String literals encrypted</td>
<td></td>
<td>17</td>
</tr>
<tr>
<td>Methods with rewritten control flow</td>
<td></td>
<td>8</td>
</tr>
<tr>
<td>Method bodies encrypted</td>
<td></td>
<td>0 (not requested)</td>
</tr>
</tbody></table>
<p>The receipt records the engine version (<code>0.1.0-alpha.333</code>), the SHA-256 of the input and of every output, the attempt number and the measured CPU time (2.24 s here). It is signed by the broker that ran the job.</p>
<p>The hashes matter more than they look. Protection is not deterministic: an earlier build of this sample went through the same profile three times and came out with three different hashes. If someone asks which protected file went into release 4.2, "the one from Tuesday" is not an answer. The receipt is.</p>
<p>These counts are not a security score. They tell you what the engine did, so that a zero where you expected seventeen is visible before you ship.</p>
<h2>A short checklist</h2>
<ol>
<li>Open your current release in ILSpy. Decide what in it is worth protecting.</li>
<li>List the names that are contracts: JSON and XML models, reflection targets, plugin interfaces, anything bound from XAML or config.</li>
<li>Protect a build and run your real tests against the protected files. We wrote more about that in <a href="https://proofcloak.hashnode.dev/a-green-build-is-not-a-release-check-test-the-net-package-you-ship">A Green Build Is Not a Release Check</a>.</li>
<li>Open the protected file too. Keep the receipt with the release.</li>
</ol>
<h2>Try it</h2>
<p>ProofCloak is free during the open beta: one project and five protection jobs a month. You need to sign up, and no payment is taken. It targets .NET 10 managed DLL and EXE files. Try it on a sample first:</p>
<p><a href="https://proofcloak.com/en?utm_source=dev&amp;utm_medium=referral&amp;utm_campaign=launch-v2&amp;utm_content=p2-article">Protect your first .NET build free</a></p>
<p>If the after-listing above still looks too readable to you, tell us in the comments what you would expect to see instead. That feedback is why this is a beta.</p>
<p><em>This article was drafted with AI using ProofCloak’s InvoiceDesk sample. The listings and measurements come from the sample run described above.</em></p>
]]></content:encoded></item><item><title><![CDATA[Why .NET Code Obfuscation Still Matters — and Where It Stops Helping]]></title><description><![CDATA[Where .NET obfuscation helps, where it stops, and how to protect implementation details without breaking compatibility or overclaiming security.]]></description><link>https://proofcloak.hashnode.dev/why-net-code-obfuscation-still-matters-and-where-it-stops-helping</link><guid isPermaLink="true">https://proofcloak.hashnode.dev/why-net-code-obfuscation-still-matters-and-where-it-stops-helping</guid><category><![CDATA[dotnet]]></category><dc:creator><![CDATA[ProofCloak]]></dc:creator><pubDate>Thu, 05 Nov 2026 00:33:08 GMT</pubDate><content:encoded><![CDATA[<p>Protecting a source repository and protecting a distributed application are different problems. Once you ship software to a machine you do not control, its owner can examine the files, observe execution, and study what the application does. A private repository does not make the released implementation private.</p>
<p>Preparation disclosure: this article was drafted with AI assistance and checked against the primary sources linked below. The author is affiliated with ProofCloak, an open-beta .NET code protection project. This is an engineering discussion, not a benchmark or a claim that a particular application is supported by the service.</p>
<p>That distribution problem is why obfuscation remains relevant. It can make selected implementation details less convenient to understand and modify. Its value depends on what you ship, what you are trying to protect, and the costs it introduces. A responsible decision starts with those questions rather than a promise to make code impossible to reverse engineer.</p>
<h2>The release contains information you no longer control</h2>
<p>In a conventional managed .NET assembly, intermediate language and metadata describe the program. Type identities, members, attributes, and relationships help the runtime and tools work with it. Microsoft's metadata documentation explains this self-describing format. It is useful infrastructure, and it also gives an analyst structure to inspect.</p>
<p>Decompilers are not hypothetical. The open-source ILSpy project provides .NET decompilation and metadata inspection. A reconstructed program need not reproduce the exact source text to explain a valuable algorithm, reveal an integration contract, or show where a local decision is made.</p>
<p>This does not mean every .NET application needs obfuscation. An application that runs exclusively on infrastructure you control has a different exposure model from a desktop application, a distributed library, or an on-premises component delivered to another organization. Start by identifying which binaries actually leave your control.</p>
<h2>Decide which work you want to make harder</h2>
<p>Consider a hypothetical vendor shipping a desktop tool with a proprietary calculation module. The vendor wants to discourage straightforward copying of that implementation and make casual modification less convenient. Those are narrower goals than preventing all analysis or guaranteeing that a local license check can never be bypassed.</p>
<p>A useful assessment names an asset, an adversary, and a task. For example: a competitor receives the desktop package and attempts to reconstruct a particular calculation. Or a user modifies a local decision to enable a feature. Those scenarios differ from a stolen backend credential or a missing server-side authorization check. They need different controls.</p>
<p>Symbol renaming can remove convenient labels. Other transformations may change how an implementation is represented or analyzed. Whether a particular transformation materially increases the effort for the chosen task requires evaluation. A larger binary, an unreadable screenshot, or a successful tool invocation is not a measurement of protection strength.</p>
<p>The practical question is whether the expected obstacle is worth its compatibility, performance, support, and operational costs for this application. There is no universally correct maximum setting.</p>
<h2>AI changes the conversation, not the trust boundary</h2>
<p>It is reasonable to consider analysts using AI assistants alongside decompilers, search, and debugging tools. But claims such as “AI breaks every assembly in minutes” or “this profile defeats AI” need reproducible evidence. They should not be assumptions in a purchasing or release decision.</p>
<p>The underlying boundary is simpler: code executing on someone else's machine can be inspected there. An analyst's tools may change while that boundary remains. Obfuscation should be evaluated against concrete tasks and observable results, not sold through anxiety about a tool category.</p>
<p>If you want to compare analyst workflows, define the input, allowed tools, target task, success criterion, and time limit. Keep the results separate from startup latency, application correctness, and build processing time. Those are different measurements, and none can substitute for the others.</p>
<h2>Keep secrets and authority in the right place</h2>
<p>Renaming a field does not turn an embedded credential into a safe secret. Changing control flow does not fix a backend that trusts a client to choose its own permissions. A local integrity mechanism also does not establish that every future execution will happen in an environment you can trust.</p>
<p>Where the product architecture permits it, keep privileged decisions and secrets on trusted infrastructure and validate requests there. For software that genuinely needs offline operation, state the different assumptions and limitations explicitly. Do not pretend an offline client has the same trust model as a service you operate.</p>
<p>OWASP discusses obfuscation and related resilience techniques as additional, threat-dependent measures in its mobile security guidance. That framing is useful: resilience supplements a sound design. Its absence alone does not make every application vulnerable, and its presence does not repair other security failures. The mobile guidance is not a certification for a .NET desktop product.</p>
<h2>Do not confuse packaging with protection</h2>
<p>Single-file publishing packages an application for delivery. Trimming removes code judged unnecessary. Native AOT compiles an application ahead of time into a native executable. Signing helps establish integrity and publisher identity within its verification model. These mechanisms address different concerns.</p>
<p>Native AOT can change what an analyst sees, but choosing a native deployment does not make a program unknowable. It also brings its own restrictions, such as limits on dynamic code generation and loading. Use Microsoft's current Native AOT documentation to evaluate deployment compatibility, and assess reverse-engineering resilience separately.</p>
<p>The same separation applies to artifact hashes. A SHA-256 digest is valuable for identifying which bytes you tested. It does not tell you how difficult those bytes are to understand, whether the program is correct, or who produced an unsigned file.</p>
<h2>Compatibility is part of the cost</h2>
<p>An internal-looking name may be an external contract. A serializer can expose it as a JSON property. A plug-in loader can find it through a string. A binding, configuration file, or integration can rely on it after the compiler has finished checking the source.</p>
<p>That is why a protected application needs behavioral verification. Record the names and metadata that must remain stable, preserve them through a mechanism supported by the selected tool, and test the corresponding consumer. A blanket exclusion can be a useful diagnostic step, but it should not replace understanding the dependency.</p>
<p>The earlier companion examples for this project use explicit JSON names and a reflection-based method lookup. Their negative fixtures demonstrate how a successful build can coexist with a broken consumer contract. They are source-level demonstrations; they are not evidence that an obfuscator preserved those behaviors in a transformed production application.</p>
<p>In a real release, run representative journeys against the actual transformed output. Include the installed or packaged entry point where it differs from the build directory. Retain the input identity, configuration, output identity, warnings, relevant exclusions, environment, and test result.</p>
<h2>Choose a scoped, testable policy</h2>
<p>For a proprietary distributed application, a practical first policy is small. Identify the implementation worth protecting. Map the external contracts around it. Apply only transformations supported for that input and profile. Execute representative compatibility checks, retain diagnostics, and compare relevant costs against the unmodified baseline.</p>
<p>For an open-source library whose purpose is inspection and integration, obfuscation may work against the product's goals. For a private service, infrastructure access and server-side controls may deserve attention first. For a commercial offline client, extra analysis resistance may be useful, but the limits of local enforcement remain part of the design.</p>
<p>Modern code protection earns its place when it makes a defined unwanted task harder without breaking the software customers need. The release still has to run, integrate, update, and be supportable. Those are engineering requirements, not exceptions to a security story.</p>
<h2>References</h2>
<ul>
<li><a href="https://learn.microsoft.com/en-us/dotnet/standard/metadata-and-self-describing-components">Metadata and self-describing components — Microsoft</a></li>
<li><a href="https://github.com/icsharpcode/ILSpy">ILSpy — the project's own repository</a></li>
<li><a href="https://mas.owasp.org/MASVS/11-MASVS-RESILIENCE/">MASVS-RESILIENCE — OWASP Mobile Application Security</a></li>
<li><a href="https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/">Native AOT deployment overview — Microsoft</a></li>
<li><a href="https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/customize-properties">Customize System.Text.Json property names — Microsoft</a></li>
</ul>
<p>Scope: this article makes no new benchmark, product capability, universal support, or production-readiness claim.</p>
]]></content:encoded></item><item><title><![CDATA[Test JSON and Reflection Contracts Before Renaming .NET Code]]></title><description><![CDATA[Catch JSON schema and reflection name breaks with explicit contracts, stable wire names, and negative tests before changing a .NET release.]]></description><link>https://proofcloak.hashnode.dev/test-json-and-reflection-contracts-before-renaming-net-code</link><guid isPermaLink="true">https://proofcloak.hashnode.dev/test-json-and-reflection-contracts-before-renaming-net-code</guid><category><![CDATA[dotnet]]></category><dc:creator><![CDATA[ProofCloak]]></dc:creator><pubDate>Thu, 05 Nov 2026 00:32:22 GMT</pubDate><content:encoded><![CDATA[<p>A .NET application can compile successfully while depending on names that the compiler never treats as a public interface. A JSON field read by another service, a plug-in entry point found with a string, or a property reached through a binding expression can all become part of a contract.</p>
<p>Disclosure: this article was drafted with AI assistance and checked against the linked primary sources. It is prepared for ProofCloak, an open-beta .NET code protection project. The standalone sample was executed locally; it is not evidence of an actual obfuscation or production run.</p>
<p>Changing those names without changing their consumers can break a release. This matters when refactoring, introducing code protection, replacing a serializer, or changing a build configuration. The useful question is precise: which observable behavior must remain stable, and does the candidate artifact preserve it?</p>
<p>This article builds a small executable check for two boundaries: JSON property names and a reflection-discovered method. The example uses .NET 10 and System.Text.Json. It deliberately simulates source-level renaming. It does not run an obfuscator, measure resistance to reverse engineering, or establish that a particular protection tool supports a given application.</p>
<h2>Begin with an external contract</h2>
<p>Suppose an integration expects the following payload:</p>
<pre><code class="language-json">{"invoice_id":"INV-42","total_cents":1250}
</code></pre>
<p>The contract includes the property names, their kinds, and their meaning. Whether the implementation calls its CLR property <code>Id</code>, <code>InvoiceIdentifier</code>, or <code>A</code> is a separate decision.</p>
<p>System.Text.Json allows an explicit serialized name through <code>JsonPropertyName</code>. Microsoft's documentation explains that the attribute applies to serialization and deserialization and takes precedence over a naming policy. It does not, however, change how parameterized constructor parameters are matched. This example uses mutable properties to keep constructor matching outside its scope.</p>
<pre><code class="language-csharp">public sealed class Invoice
{
    [JsonPropertyName("invoice_id")]
    public string Id { get; set; } = "";

    [JsonPropertyName("total_cents")]
    public int TotalCents { get; set; }
}
</code></pre>
<p>An internal rename simulation can preserve those explicit external names:</p>
<pre><code class="language-csharp">public sealed class RenamedInvoice
{
    [JsonPropertyName("invoice_id")]
    public string A { get; set; } = "";

    [JsonPropertyName("total_cents")]
    public int B { get; set; }
}
</code></pre>
<p>Both models should emit the expected wire contract. A third model, with properties <code>A</code> and <code>B</code> but no attributes, emits a different shape under the default options. That third case gives the test a useful negative control.</p>
<p>The explicit names are still visible to a consumer inspecting the application. They are compatibility decisions, not a way to hide an API schema or a secret. Do not put private credentials in an attribute, a DTO, or any other client-side location on the assumption that renaming will protect them.</p>
<h2>Make serializer metadata explicit</h2>
<p>The complete sample uses a generated serializer context:</p>
<pre><code class="language-csharp">[JsonSerializable(typeof(Invoice))]
[JsonSerializable(typeof(RenamedInvoice))]
[JsonSerializable(typeof(UnstableInvoice))]
internal partial class InvoiceJson : JsonSerializerContext { }
</code></pre>
<p>It calls the overload that receives generated type information:</p>
<pre><code class="language-csharp">string json = JsonSerializer.Serialize(
    new Invoice { Id = "INV-42", TotalCents = 1250 },
    InvoiceJson.Default.Invoice);
</code></pre>
<p>The project sets <code>JsonSerializerIsReflectionEnabledByDefault</code> to <code>false</code>. An accidental return to an unconfigured reflection-based serializer path can then fail visibly. Microsoft's source-generation guide documents this switch and the context-based overloads.</p>
<p>This is not an application-wide compatibility guarantee. A different serializer, polymorphic payload, custom converter, or dynamically selected type introduces additional contracts. A transformation tool also has its own handling of metadata and generated code. Verify that handling on the actual output instead of assuming this source-level example proves it.</p>
<h2>Assert what the consumer sees</h2>
<p>A round trip through one implementation is insufficient by itself. If both serialization and deserialization move to the same wrong names, they can agree with each other while breaking an older client.</p>
<p>The sample therefore inspects the emitted document directly:</p>
<pre><code class="language-csharp">static bool HasExpectedWireContract(string json)
{
    using JsonDocument document = JsonDocument.Parse(json);
    JsonElement root = document.RootElement;
    return root.ValueKind == JsonValueKind.Object
        &amp;&amp; root.EnumerateObject().Count() == 2
        &amp;&amp; root.TryGetProperty("invoice_id", out JsonElement id)
        &amp;&amp; id.ValueKind == JsonValueKind.String
        &amp;&amp; id.GetString() == "INV-42"
        &amp;&amp; root.TryGetProperty("total_cents", out JsonElement total)
        &amp;&amp; total.ValueKind == JsonValueKind.Number
        &amp;&amp; total.TryGetInt32(out int amount)
        &amp;&amp; amount == 1250;
}
</code></pre>
<p>The check ignores property ordering and whitespace. Those are not requirements of this example. It rejects extra properties because this particular fixture describes an exact two-field payload. In an integration that permits additive fields, remove that restriction deliberately and document the compatibility rule. Strictness should express the real consumer contract, not an arbitrary snapshot.</p>
<p>Real tests should also cover representative persisted data, nullability, missing fields, enum representations, and version transitions. Successful serialization alone says little about whether a previously saved document can still be read correctly.</p>
<h2>Treat string-based discovery as a separate boundary</h2>
<p>Now consider a loader that expects a public parameterless method named <code>CreateReport</code>:</p>
<pre><code class="language-csharp">public sealed class ReportPlugin
{
    public string CreateReport() =&gt; "report-ok";
}
</code></pre>
<p>The consumer performs the lookup and checks the result:</p>
<pre><code class="language-csharp">MethodInfo? entry = plugin.GetMethod("CreateReport", Type.EmptyTypes);
bool reflectionPass = entry is not null
    &amp;&amp; entry.ReturnType == typeof(string)
    &amp;&amp; entry.Invoke(Activator.CreateInstance(plugin), null) is string result
    &amp;&amp; result == "report-ok";
</code></pre>
<p>The negative fixture exposes the same behavior through a method named <code>A</code>. The original string lookup fails. Correct code still exists, but the discovery contract has changed.</p>
<p>For code you control, a shared interface or another explicit registration mechanism may reduce dependence on names. For an existing external plug-in protocol, changing the consumer may be impossible. Preserve the required entry point using a mechanism supported by your tooling, and keep a test that exercises the loader. A preservation setting without a behavioral test is an assumption that can become stale.</p>
<p>Trimming and obfuscation are different operations. Microsoft's trimming documentation identifies reflection and dynamic loading as areas needing special attention; that is useful context, not evidence that a trimming annotation configures an obfuscator. Do not interchange the tools' configuration contracts.</p>
<h2>Run both the passing and failing paths</h2>
<p>The companion project has no third-party package dependencies. From its directory:</p>
<pre><code class="language-text">dotnet publish -c Release -o publish
dotnet publish/ContractChecks.dll
dotnet publish/ContractChecks.dll --break-json
dotnet publish/ContractChecks.dll --break-reflection
</code></pre>
<p>The normal invocation must exit with code 0. Each negative invocation must exit with code 1. The flags select deliberately incompatible fixtures; they do not invoke code protection or modify a published assembly.</p>
<p>This distinction matters in a release pipeline. A test process that prints <code>FAIL</code> but exits successfully can still produce a green job. Conversely, an expected failing fixture must not be reported as a failed production release. The harness should record the command, expected outcome, actual exit code, and relevant output for each case.</p>
<p>After any transformation, repeat the real contract tests against the candidate assemblies with the actual consumer. A self-check contained inside a rewritten application can move with the implementation. Keep independent fixtures where practical, and exercise the installed package as well as the build directory.</p>
<h2>What this gives you</h2>
<p>These checks turn two hidden dependencies into explicit release requirements. They do not prove that every reflection path is covered, that a transformed application is secure, or that an application is compatible across all frameworks and platforms.</p>
<p>Start with the contracts your customers depend on. Give each one a representative fixture, a useful failure signal, and a known artifact to run against. When a change breaks one, the failure points to a concrete boundary rather than a vague report that the protected build no longer works.</p>
<h2>References and disclosure</h2>
<ul>
<li><a href="https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/customize-properties">Customize System.Text.Json property names — Microsoft</a></li>
<li><a href="https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation">Use source generation in System.Text.Json — Microsoft</a></li>
<li><a href="https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/incompatibilities">Known trimming incompatibilities — Microsoft</a></li>
</ul>
<p>Affiliation: this article is prepared for the ProofCloak account, which develops an open-beta .NET code protection platform. The example is independent of its service and makes no claim about a service-side protection run.</p>
<p>Preparation disclosure: AI assisted with drafting and code preparation. The sample was executed locally; the accompanying verification record distinguishes ordinary publish checks from actual obfuscation or production testing.</p>
<h2>Companion source</h2>
<p><a href="https://cdn.c-sharpcorner.com/source/3086613/b309a800-cfc6-4b45-8353-8f08ce6d4c63/ContractChecks-article-source.zip">Download the complete standalone sample source (ZIP)</a>. The archive contains the project, program, PowerShell release gate, and README; no customer files or service credentials.</p>
]]></content:encoded></item><item><title><![CDATA[A Green Build Is Not a Release Check: Test the .NET Package You Ship]]></title><description><![CDATA[Connect release checks to the actual .NET package: inventory files, test contracts, capture exit codes, and verify artifact identity.]]></description><link>https://proofcloak.hashnode.dev/a-green-build-is-not-a-release-check-test-the-net-package-you-ship</link><guid isPermaLink="true">https://proofcloak.hashnode.dev/a-green-build-is-not-a-release-check-test-the-net-package-you-ship</guid><category><![CDATA[dotnet]]></category><dc:creator><![CDATA[ProofCloak]]></dc:creator><pubDate>Thu, 05 Nov 2026 00:31:07 GMT</pubDate><content:encoded><![CDATA[<p>A useful release question is surprisingly easy to leave unanswered: did the test run against the same files that the customer will receive?</p>
<p>Disclosure: this article was drafted with AI assistance and checked against the linked primary sources. It is prepared for ProofCloak, an open-beta .NET code protection project. The standalone sample was executed locally; it is not evidence of an actual obfuscation or production run.</p>
<p>A unit test can pass in a source checkout while a publish directory lacks a dependency. A smoke test can exercise an unmodified DLL while a packaging step selects another one. A post-build transformation can complete successfully while the installed application fails during its first export. Each individual step may report success without establishing that the final package works.</p>
<p>The fix starts with artifact identity and a small set of meaningful behaviors. This article proposes a minimal gate for a .NET console sample: inventory the candidate directory, execute its contract checks, record the exit code, and verify that the candidate files did not change during that run. It is a local demonstration, not a production deployment or a measurement of code-protection strength.</p>
<h2>Define the candidate before running tests</h2>
<p>Microsoft's publishing overview describes a publish output as the application and the dependencies and related files needed for distribution. The deployment mode matters: a framework-dependent application requires a compatible installed runtime, while a self-contained deployment includes its runtime. Native dependencies and platform-specific behavior still need the appropriate target environment.</p>
<p>For this example, the candidate is an ordinary framework-dependent .NET 10 publish directory. The commands are explicit:</p>
<pre><code class="language-text">dotnet publish ContractChecks.csproj -c Release -o publish
dotnet publish/ContractChecks.dll
</code></pre>
<p>Do not substitute <code>dotnet run</code> for the second command when you intend to test the published output. It selects a project workflow and can introduce a build. Here the application is launched through the DLL already inside the candidate directory.</p>
<p>If a production application is delivered through an apphost, service, installer, container, or launcher, test that path too. Launching a DLL is appropriate for this sample; it is not a universal replacement for the customer's entry point.</p>
<p>Before any code protection or other post-processing, retain an identifiable input. After the transformation, treat its output as a new candidate. The tool returning success proves the tool's reported outcome, not the application's complete behavior. Run the relevant checks on that output rather than carrying the input's green result forward.</p>
<h2>Inventory more than the main DLL</h2>
<p>A directory snapshot should cover the files that form the candidate, using relative paths and content hashes. A changed configuration file or missing dependency can matter just as much as a changed executable.</p>
<p>The PowerShell example uses <code>Get-FileHash</code> with SHA-256:</p>
<pre><code class="language-powershell">function Get-ReleaseSnapshot {
    @(Get-ChildItem -LiteralPath $releaseRoot -File -Recurse | ForEach-Object {
        [pscustomobject]@{
            path = [IO.Path]::GetRelativePath(
                $releaseRoot, $_.FullName).Replace('\', '/')
            sha256 = (Get-FileHash -LiteralPath $_.FullName `
                -Algorithm SHA256).Hash.ToLowerInvariant()
        }
    } | Sort-Object -Property path)
}
</code></pre>
<p>The result is a deterministic ordering of paths and hashes, not a claim that the build itself is reproducible. Two independently built releases can differ for reasons that need separate investigation. This check answers a narrower question about the bytes in one selected directory.</p>
<p>A hash also does not establish who produced a file. An attacker able to replace both a package and an unsigned manifest can produce matching values. Keep the report in a trusted pipeline or artifact store, and use your delivery system's provenance and signing controls where appropriate. Identity, authenticity, compatibility, and resistance to analysis are different properties.</p>
<h2>Execute a behavior with a useful failure signal</h2>
<p>The companion sample from the JSON and reflection article checks a fixed invoice schema and a method discovered by name. The release gate runs that executable and captures its process outcome:</p>
<pre><code class="language-powershell">$before = Get-ReleaseSnapshot
Push-Location -LiteralPath $releaseRoot
try {
    $appOutput = @(&amp; dotnet $entryPoint @AppArguments 2&gt;&amp;1 |
        ForEach-Object { "$_" })
    $appExitCode = $LASTEXITCODE
} finally {
    Pop-Location
}
$after = Get-ReleaseSnapshot
</code></pre>
<p>Capture the native process exit code immediately. A printed success message is not sufficient, and a printed failure message should not be silently treated as success. The full script emits a JSON report and exits with code 1 when the application fails or the directory changes.</p>
<p>The sample contract executable has two deliberate negative modes. <code>--break-json</code> selects an incompatible JSON model. <code>--break-reflection</code> selects a type that lacks the required entry-point name. These are controlled source-level fixtures, not genuine obfuscation results. Each must make the gate fail. Without such a negative control, it is easy to build a release check that never rejects anything.</p>
<p>Keep the assertions representative. For a desktop application, starting the process may miss a broken report export or a plug-in loaded later. For a service, receiving a readiness response may miss a failed authenticated operation. Choose a small, explicit list of release-critical journeys, and record which ones were actually exercised.</p>
<h2>Keep reports outside the candidate directory</h2>
<p>The script compares the before and after snapshots. It therefore expects an immutable candidate directory. Write logs, reports, caches, and synthetic user data elsewhere.</p>
<p>That is an intentional constraint of the example. Some real applications update files beside their executable. Such behavior requires a defined test strategy: configure a separate writable data location, execute a disposable installed copy, or document the files that are expected to change and how they are validated. Do not simply omit inconvenient changes from the report to keep it green.</p>
<p>The snapshot comparison detects observed changes between two inventories. It is not a filesystem isolation mechanism, does not cover permissions or every filesystem feature, and cannot prove that no transient change occurred between reads. In a hostile or concurrent environment, use stronger isolation and trusted artifact storage. A simple gate should state what it observes rather than promise more than its mechanism can establish.</p>
<p>The sample also has no process timeout. Use it for this bounded demonstration. A production harness needs an appropriate deadline and cleanup for the exact process it owns, because a hung application must not occupy a runner indefinitely. That operational requirement is separate from loosening a performance budget or retrying a failed check.</p>
<h2>Place packaging and signing in the evidence chain</h2>
<p>A practical release sequence is: create the candidate, perform the configured transformations, validate the required behaviors, apply the appropriate signing and packaging steps, then validate the resulting delivery artifact through its real entry path. The exact order depends on the signing scheme and delivery format; follow those tools' requirements rather than assuming a signature will survive later modifications.</p>
<p>If packaging changes any executable bytes, the earlier directory hashes no longer identify those bytes. If it wraps the files without changing them, retain both the package hash and the identities of its contents. Test a freshly extracted or installed copy in a representative environment. Record the source revision, SDK, target framework, runtime or image, platform, configuration identity, candidate manifest, test outcome, and delivery artifact identity.</p>
<p>Avoid rebuilding after acceptance merely to produce a nominally equivalent package. Prefer promoting the accepted artifact. When rebuilding is necessary, treat the new output as a new candidate and validate the relevant properties again.</p>
<h2>Read the result narrowly</h2>
<p>For the supplied sample, run:</p>
<pre><code class="language-powershell">./Check-Release.ps1 -PublishDirectory ./publish
./Check-Release.ps1 -PublishDirectory ./publish `
    -AppArguments @('--break-json')
./Check-Release.ps1 -PublishDirectory ./publish `
    -AppArguments @('--break-reflection')
</code></pre>
<p>The first invocation should pass; the other two should exit with code 1. An unchanged file snapshot plus a successful smoke test establishes only the listed checks on those observed files in that environment. It does not establish complete compatibility, production readiness, an absence of vulnerabilities, or a level of protection against reverse engineering.</p>
<p>That narrow result is still useful. It connects a behavior, a process outcome, and a concrete candidate. When a release fails, you can ask which contract broke and which files were actually involved instead of relying on a green build badge detached from the package.</p>
<h2>References and disclosure</h2>
<ul>
<li><a href="https://learn.microsoft.com/en-us/dotnet/core/deploying/">.NET application publishing overview — Microsoft</a></li>
<li><a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-filehash">Get-FileHash — Microsoft PowerShell</a></li>
</ul>
<p>Affiliation: prepared for the ProofCloak account, which develops an open-beta .NET code protection platform. This workflow is a standalone example and does not claim an end-to-end run of that service.</p>
<p>Preparation disclosure: AI assisted with drafting and sample preparation. The accompanying local verification record states the actual passing and expected failing cases.</p>
<h2>Companion source</h2>
<p><a href="https://cdn.c-sharpcorner.com/source/3086613/b309a800-cfc6-4b45-8353-8f08ce6d4c63/ContractChecks-article-source.zip">Download the complete standalone sample source (ZIP)</a>. The archive contains the project, program, PowerShell release gate, and README; no customer files or service credentials.</p>
]]></content:encoded></item></channel></rss>