Sometimes you have to use indexed placeholders with string.Format() and you are not alone. Keeping track of array element positions can be difficult. This plugin helps maintain clarity by adding and updating index comments via Context Actions.
const string notificationTemplate = @"Dear {0},
Your recent transaction (ID: {1}) of {2:C} on {3} has been processed.
The payment method used: {4}.
Status: {5}.
If you have any questions, please contact {6}.
Best regards,
Your Bank";
var args = new object[]
{
/*0*/ user.GetProfile().GetFullName(),
/*1*/ transaction.GetDetails().GetTransactionId(),
/*2*/ transaction.GetAmount().CalculateWithTax(user.GetTaxRate()),
/*3*/ transaction.GetTimestamp().ToString("MMMM dd, yyyy HH:mm"),
/*4*/ user.GetPreferredPaymentMethod().GetDisplayName(),
/*5*/ transaction.GetStatus().ToFriendlyString(user.GetLocale()),
/*6*/ bank.GetSupportService().GetContactEmail(user.GetRegion(), true)
};
string notificationMessage = string.Format(notificationTemplate, args);- Install the plugin from the JetBrains Marketplace (an IDE restart may be required).
- Open the
Context Actionsmenu (Alt+Enter) inside an array initializer. - Select
Add Index Comments to Array Elementsto annotate the array with index comments. - To update indexes, run the action again.
Run ./gradlew buildPlugin from the solution root directory. The output directory will contain two files:
.nupkgfor ReSharper.zipfor Rider.