|
| 1 | +# Azure SDK for .NET - Management Plane SDK Naming Conventions |
| 2 | + |
| 3 | +This document describes the naming conventions for the Azure Management Plane SDK for .NET. |
| 4 | +In addition to adhering to the [General Naming Conventions of .NET](https://learn.microsoft.com/dotnet/standard/design-guidelines/general-naming-conventions), there are specific guidelines related to the naming of classes, properties, and methods. These include rules for using abbreviations and acronyms, as well as recommendations for avoiding Azure-specific names. |
| 5 | + |
| 6 | +## General Guidelines |
| 7 | + |
| 8 | +**DO** Use Pascal case which capital case for the first letter only. |
| 9 | + |
| 10 | +**DO** Two-letter acronyms are special and should be all-uppercased if it is not part of longer compound identifiers, but still have some exceptions like `Vm`, `Id` and etc. |
| 11 | + |
| 12 | +**DO** Use a singular type name for an `enum` type if it does not have the `[Flags]` attribute. Use a plural type name for an `enum` type if it has `[Flags]` attribute. For more details, please check [C# enumeration naming convention](https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#naming-enumerations). |
| 13 | + |
| 14 | +**DO** The name of PATCH operation's body parameter should be: `[Model]Patch`. For the model of a property in the `[Model]Patch`, if you need to rename the suffix, use `Content` instead of `Patch` since properties are not patchable, they will be set as the property model is. |
| 15 | + |
| 16 | +**DO** The name of PUT / POST operation's body parameter should be: `[Model]Content` or `[Model]Data`. |
| 17 | + |
| 18 | +**DO** Start property or parameter names of type bool with a verb, like `Is`, `Can`, `Has` prefix. |
| 19 | + |
| 20 | +**DO** End property or parameter names of type DateTime with `On`. |
| 21 | + |
| 22 | + - Use the original verb form for active voice, like `StartOn` and `EndOn`. |
| 23 | + |
| 24 | + - Use the passive verb form for passive voice, like `CreatedOn`, `EstablishedOn`. |
| 25 | + |
| 26 | +**DO** End property or parameter names of type integer that represent intervals or durations with units, for example: `MonitoringInterval` -> `MonitoringIntervalInSeconds`. |
| 27 | + |
| 28 | +**DO** If a property or parameter name ends with `Interval` or `Duration` and its value is not in ISO 8601 duration format (e.g., P1DT2H59M59S) or ISO 8601 time format (e.g., 2.2:59:59.5000000), rename the property or parameter to remove the `Interval` or `Duration` suffix. |
| 29 | + |
| 30 | +**DO** Consider renaming TTL properties or parameters to `TimeToLiveIn<Unit>`. |
| 31 | + |
| 32 | +**DO** Avoid using single-word class names. Instead, use more descriptive names after consulting with the service development team. |
| 33 | + |
| 34 | +**DO** Rename `CheckNameAvailability` operation: |
| 35 | + |
| 36 | + - The method name should be `Check[Resource/RP name]NameAvailability`. |
| 37 | + |
| 38 | + - The parameter / response model name should be `[Resource/RP name]NameAvailabilityXXX`. |
| 39 | + |
| 40 | + - If there is a `Reason` property which is used to represent the unavailable reason code, and its type is an `enum` then the name of this `enum` should be `[Resource/RP name]NameUnavailableReason`. |
| 41 | + |
| 42 | +**DO NOT** Duplicate names across different RPs. Additionally, ensure that the data plane is covered (if applicable). |
| 43 | + |
| 44 | +## Guidelines for model prefixes |
| 45 | + |
| 46 | +We should avoid using `Microsoft`, `Azure` prefixes for any models or classes. |
| 47 | + |
| 48 | +## Guidelines for model suffixes |
| 49 | + |
| 50 | +We should avoid using the following suffixes for any models or classes. |
| 51 | + |
| 52 | +- Parameter(s) |
| 53 | + |
| 54 | + It should be changed to either `Content` or `Patch` based on the context of its usage. |
| 55 | + |
| 56 | +- Request |
| 57 | + |
| 58 | + It should be changed to `Content` based on the context of its usage. |
| 59 | + |
| 60 | +- Options |
| 61 | + |
| 62 | + It should be changed to `Config`, unless it's a `ClientOptions`. |
| 63 | + |
| 64 | +- Response |
| 65 | + |
| 66 | + It should be changed to `Result`. |
| 67 | + |
| 68 | +- Resource: |
| 69 | + |
| 70 | + - For a resource name (under `src/Generated` and you'll have `XXResourceData`, `XXResourceCollection`), if removing the word `Resource` leaves a descriptive enough noun, then remove it. Only keep `Resource` if removing it makes the noun no longer descriptive enough (e.g., `GenericResource` would become `Generic`). |
| 71 | + |
| 72 | + - For a model name (under `src/Generated/Models`), if removing the `Resource` suffix makes it no longer descriptive or reduces it to a single word, append `Data` if it inherits from `ResourceData` or `TrackedResourceData`, otherwise append `Info`. |
| 73 | + |
| 74 | + - Entity names that still have `Resource` suffix: `GenericResource`, `PrivateLinkServiceResource`. |
| 75 | + |
| 76 | +- Collection |
| 77 | + |
| 78 | + Rename to `Group` or `List` when it makes sense and does not conflict with existing model names. |
| 79 | + For some resource name, it may be difficult to find a replacement and developers of that domain are familiar with the collection terminology like `MongoDBCollection`. It's **okay** to keep the suffix in such cases. |
| 80 | + |
| 81 | +- Data |
| 82 | + |
| 83 | + Remove it unless the model derives from `ResourceData` or `TrackedResourceData`. |
| 84 | + |
| 85 | +- Operation |
| 86 | + |
| 87 | + Remove it unless the model derives from `Operation<T>` or `Operation`. Append `Data` or `Info` suffix if it's hard to rename with other words. |
| 88 | + |
| 89 | +## Guidelines for Expanding Acronyms |
| 90 | + |
| 91 | +If an acronym can be clearly explained on the first page of search results without needing a context word or with just one well-known context word, then there's no need to expand it. Otherwise, spell it out. |
| 92 | + |
| 93 | +For Cryptographic (or other) algorithm names follow the same Pascal case acronym naming conventions: |
| 94 | + |
| 95 | +- Advanced Encryption Standard (AES) is `Aes`. |
| 96 | + |
| 97 | +- Elliptic Curve Digital Signature Algorithm (ECDSA) is `ECDsa` (two-letter acronym followed by a three-letter acronym). |
| 98 | + |
| 99 | +- Elliptic Curve Diffie-Hellman (ECDH) is `ECDiffieHellman` (avoiding the four concurrent capital letters required by a two-letter acronym following a two-letter acronym). |
0 commit comments