Most teams ship their application logic as a compiled assembly and their configuration as a YAML file sitting next to it. The assembly is the IP you want to protect; the YAML is a plain-text file an operator edits by hand. It is easy to assume these two concerns are independent — obfuscate the code, leave the file alone. They are not independent. If you use YamlDotNet with its default settings, the keys in that hand-authored file are your property names, and renaming the properties renames the keys the file must contain. The file you shipped last week stops loading, and the failure lands at your customer's first startup, not in your build.
The real question
YamlDotNet never stores a schema. There is no code generator, no .proto, no attribute you are required to write. So where does the key DatabaseUrl: in the file come from, and what does the deserializer compare it against at read time? Answer that precisely and the rename hazard — and its fix — becomes obvious.
Keys are property names, resolved at runtime
Take an ordinary config type and the ordinary way to read it:
public sealed class AppConfig { public string DatabaseUrl { get; set; } = ""; public int MaxRetries { get; set; } } var yaml = File.ReadAllText("appsettings.yaml"); var config = new DeserializerBuilder().Build() .Deserialize<AppConfig>(yaml); Serialize an instance and YamlDotNet writes the property names straight out, because the default naming convention (NullNamingConvention) passes them through unchanged:
DatabaseUrl: postgres://db/app MaxRetries: 5 The key DatabaseUrl is not stored anywhere in your assembly as data. It is produced on demand: when the serializer or deserializer processes AppConfig, an ITypeInspector walks the type, and the default ReflectionTypeInspector reads each PropertyInfo.Name and hands it to the active naming convention. The result is the YAML key. Both directions use the same path — the writer asks reflection for the name to emit, and the reader asks reflection for the name to match an incoming scalar against. The name is the contract, and it is recomputed from metadata every time.
That is the whole mechanism, and it is why renaming is dangerous: an obfuscator rewrites exactly the metadata that reflection reads.
What renaming actually produces
Run the assembly through Nebula with renaming on, and a decompiler shows the config type stripped of meaning:
public sealed class b { public string a { get; set; } = ""; public int c { get; set; } } The properties are now a and c. Reflection reports exactly those, so a fresh serialize now writes:
a: postgres://db/app c: 5 and a deserialize of that same shape reads back cleanly. This is the trap. A unit test that serializes an AppConfig, deserializes the string it just produced, and asserts the fields match will pass after obfuscation, because both halves agree that the key is a. The test never touches the file your customer actually has.
The failure is at read time, and it is loud by default
The real input is appsettings.yaml, written by a human who typed DatabaseUrl: because that is what your docs say. The renamed deserializer walks b, finds members named a and c, and looks for scalars called a and c. It finds DatabaseUrl instead — a key that matches no member. YamlDotNet's default deserializer treats an unmatched key as an error and throws:
YamlDotNet.Core.YamlException: Property 'DatabaseUrl' not found on type 'b'. That is, at least, honest: the application fails fast at startup with a message pointing at the exact key. The quieter and more dangerous variant appears when the app was built with IgnoreUnmatchedProperties() for forward-compatibility:
var config = new DeserializerBuilder() .IgnoreUnmatchedProperties() .Build() .Deserialize<AppConfig>(yaml); Now the unmatched DatabaseUrl is simply skipped. No exception. a keeps its default of "", the app boots with an empty connection string, and the first database call is where you discover the config never loaded. The same leniency that protects you against extra keys hides a renamed key.
Enums have the same shape of problem one level down: YamlDotNet writes and reads enum values by their member name (LogLevel: Warning), so if your rename settings touch enum members, the string Warning in the file stops resolving too. Most obfuscation profiles leave public enum names alone, but it is worth confirming.
Scoping the rename in nebula.config.json
The correct posture is the same as for any name-fragile serializer: obfuscate the whole assembly, then exempt the names the serializer must see. Put everything under full renaming and protection, and keep-list the config contracts:
{ "schemaVersion": 1, "inputs": [ "bin/Release/net8.0/Acme.Service.dll" ], "outputDirectory": "protected", "rename": { "enabled": true, "scope": "all" }, "stringEncryption": { "enabled": true }, "controlFlow": { "enabled": true }, "keep": [ { "type": "Acme.Service.Configuration.*", "members": "names", "reason": "YamlDotNet maps YAML keys to these property names" } ] } "members": "names" preserves the member names on those types only, so the serializer still resolves DatabaseUrl, while string encryption and control-flow transforms still rewrite their method bodies — you keep the key, you protect the logic. Everything outside the keep-list is renamed freely, which is almost always the bulk of the assembly. Then:
nebula protect --config nebula.config.json The alias is the durable fix
Keep-lists work, but they couple your config schema to your source tree: anyone who later renames DatabaseUrl in C# silently renames the YAML key again. The more robust design decouples the two with an explicit alias on every config member:
public sealed class AppConfig { [YamlMember(Alias = "database_url")] public string DatabaseUrl { get; set; } = ""; [YamlMember(Alias = "max_retries")] public int MaxRetries { get; set; } } Now the YAML key comes from the literal "database_url", which the C# compiler stores in the custom-attribute blob of the property's metadata. Renaming the property to a does not touch that blob — the alias is data, not an identifier — so the serialized key stays database_url and the hand-written file keeps loading. You get a clean, underscored, documented config schema and a fully renamed property, and you no longer need a keep rule for these members at all. Be clear-eyed about what it does not do, though: the string database_url is now visible both in the metadata and in every file on disk, so an alias preserves compatibility, never secrecy. If the meaning of a field is itself sensitive, the key cannot also be its human-readable name.
Caveats and the honest check
Two things that look like they would help, and do not. Casing conventions (WithNamingConvention(UnderscoredNamingConvention.Instance)) only transform the property name — they still start from the renamed identifier, so a becomes a, not database_url. And a case-insensitive deserializer does not save you either, because a and DatabaseUrl differ by far more than case. Neither convention nor casing is a substitute for a keep rule or an alias.
The regression test that actually catches this is not a round-trip. It is loading a real, hand-authored config file — ideally the one shipped with the previous release — against the obfuscated build and asserting that every field is populated. If you use IgnoreUnmatchedProperties(), add an assertion that a known key resolves to a non-default value, because the deserializer will not raise on your behalf. After protecting, open the output in Glass.NET and confirm the config types kept their member names (or carry their [YamlMember] aliases) while the rest of the assembly is renamed.
Takeaway
YamlDotNet has no schema but your property names — it reads them by reflection and makes them the keys, every read and every write. Rename the properties and you rename the contract, but only against files that were authored before the rename, which your round-trip tests can never see. Keep-list the config types' member names, or better, pin each key with a [YamlMember] alias so the schema lives in the attribute blob instead of your identifiers. Then protect everything else aggressively, and verify against a file a human actually wrote.
See Nebula.NET for the full transform set and the nebula.config.json reference.

