Skip to content

Commit

Permalink
Use string interpolation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLambrou committed Apr 14, 2016
1 parent b0b88a8 commit a11da64
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion XmlDoc2CmdletDoc.Core/Comments/RewritingCommentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static string GetTextForCrefValue(string cref)
var cmdletAttribute = GetCustomAttribute<CmdletAttribute>(type);
if (cmdletAttribute != null)
{
return string.Format("{0}-{1}", cmdletAttribute.VerbName, cmdletAttribute.NounName);
return $"{cmdletAttribute.VerbName}-{cmdletAttribute.NounName}";
}

// Otherwise, return the short name.
Expand Down
6 changes: 3 additions & 3 deletions XmlDoc2CmdletDoc.Core/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static string GetFullyQualifiedName(MemberInfo memberInfo)
var type = memberInfo as Type;
return type != null
? type.FullName
: string.Format("{0}.{1}", GetFullyQualifiedName(memberInfo.DeclaringType), memberInfo.Name);
: $"{GetFullyQualifiedName(memberInfo.DeclaringType)}.{memberInfo.Name}";
}

/// <summary>
Expand Down Expand Up @@ -370,7 +370,7 @@ private void GenerateAliasElements(ICommentReader commentReader, ReportWarning r
descriptionElement = new XElement(mamlNs + "description");
parameterElement.Add(descriptionElement);
}
descriptionElement.Add(new XElement(mamlNs + "para", string.Format("This is an alias of the {0} parameter.", parameter.Name)));
descriptionElement.Add(new XElement(mamlNs + "para", $"This is an alias of the {parameter.Name} parameter."));
}
}

Expand Down Expand Up @@ -568,6 +568,6 @@ private XElement GenerateTypeElement(ICommentReader commentReader, Type type, bo
/// </summary>
/// <param name="text">The text of the comment.</param>
/// <returns>An <see cref="XComment"/> instance based on the specified <paramref name="text"/>.</returns>
private XComment GenerateComment(string text) { return new XComment(string.Format(" {0} ", text)); }
private XComment GenerateComment(string text) { return new XComment($" {text} "); }
}
}
10 changes: 5 additions & 5 deletions XmlDoc2CmdletDoc.Core/Extensions/CommentReaderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static XElement GetCommandExampleElement(XElement exampleElement, int ex
var paras = items.SkipWhile(x => x.Name == "para").SkipWhile(x => x.Name == "code").ToList();

var example = new XElement(commandNs + "example",
new XElement(mamlNs + "title", string.Format("---------- EXAMPLE {0} ----------", exampleNumber)));
new XElement(mamlNs + "title", $"---------- EXAMPLE {exampleNumber} ----------"));

bool isEmpty = true;
if (intros.Any())
Expand All @@ -139,7 +139,7 @@ private static XElement GetCommandExampleElement(XElement exampleElement, int ex

if (isEmpty)
{
reportWarning(string.Format("No para or code elements found for example {0}.", exampleNumber));
reportWarning($"No para or code elements found for example {exampleNumber}.");
}

return example;
Expand Down Expand Up @@ -378,7 +378,7 @@ private static XElement GetMamlDescriptionElementFromXmlDocComment(XElement comm
if (commentsElement != null)
{
// Examine the XML doc comment first for an embedded <maml:description> element.
var mamlDescriptionElement = commentsElement.XPathSelectElement(string.Format(".//maml:description[@type='{0}']", typeAttribute), resolver);
var mamlDescriptionElement = commentsElement.XPathSelectElement($".//maml:description[@type='{typeAttribute}']", resolver);
if (mamlDescriptionElement != null)
{
mamlDescriptionElement = new XElement(mamlDescriptionElement); // Deep clone the element, as we're about to modify it.
Expand All @@ -387,7 +387,7 @@ private static XElement GetMamlDescriptionElementFromXmlDocComment(XElement comm
}

// Next try <para type="typeAttribute"> elements.
var paraElements = commentsElement.XPathSelectElements(string.Format(".//para[@type='{0}']", typeAttribute)).ToList();
var paraElements = commentsElement.XPathSelectElements($".//para[@type='{typeAttribute}']").ToList();
if (paraElements.Any())
{
var descriptionElement = new XElement(mamlNs + "description");
Expand All @@ -397,7 +397,7 @@ private static XElement GetMamlDescriptionElementFromXmlDocComment(XElement comm
}

// We've failed to provide a description from the XML doc commment.
reportWarning(string.Format("No {0} comment found.", typeAttribute));
reportWarning($"No {typeAttribute} comment found.");
return null;
}

Expand Down
15 changes: 7 additions & 8 deletions XmlDoc2CmdletDoc.Tests/AcceptanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void Command_Parameters_Parameter(string parameterName)
Assert.That(testManualElementsCommandElement, Is.Not.Null);

var parameter = testManualElementsCommandElement.XPathSelectElement(
string.Format("command:parameters/command:parameter[maml:name/text() = '{0}']", parameterName), resolver);
$"command:parameters/command:parameter[maml:name/text() = '{parameterName}']", resolver);
Assert.That(parameter, Is.Not.Null);
}

Expand All @@ -231,7 +231,7 @@ public void Command_Parameters_Parameter_RequiredAttribute(string parameterName,
Assert.That(testManualElementsCommandElement, Is.Not.Null);

var parameter = testManualElementsCommandElement.XPathSelectElement(
string.Format("command:parameters/command:parameter[maml:name/text() = '{0}']", parameterName), resolver);
$"command:parameters/command:parameter[maml:name/text() = '{parameterName}']", resolver);
Assert.That(parameter, Is.Not.Null);

var attribute = parameter.Attribute("required");
Expand All @@ -246,7 +246,7 @@ public void Command_Parameters_Parameter_PositionAttribute(string parameterName,
Assert.That(testManualElementsCommandElement, Is.Not.Null);

var parameter = testManualElementsCommandElement.XPathSelectElement(
string.Format("command:parameters/command:parameter[maml:name/text() = '{0}']", parameterName), resolver);
$"command:parameters/command:parameter[maml:name/text() = '{parameterName}']", resolver);
Assert.That(parameter, Is.Not.Null);

var attribute = parameter.Attribute("position");
Expand All @@ -262,7 +262,7 @@ public void Command_Parameters_Parameter_PipelineInputAttribute(string parameter
Assert.That(testManualElementsCommandElement, Is.Not.Null);

var parameter = testManualElementsCommandElement.XPathSelectElement(
string.Format("command:parameters/command:parameter[maml:name/text() = '{0}']", parameterName), resolver);
$"command:parameters/command:parameter[maml:name/text() = '{parameterName}']", resolver);
Assert.That(parameter, Is.Not.Null);

var attribute = parameter.Attribute("pipelineInput");
Expand All @@ -276,7 +276,7 @@ public void Command_Parameters_Parameter_GlobbingInputAttribute(string parameter
Assert.That(testManualElementsCommandElement, Is.Not.Null);

var parameter = testManualElementsCommandElement.XPathSelectElement(
string.Format("command:parameters/command:parameter[maml:name/text() = '{0}']", parameterName), resolver);
$"command:parameters/command:parameter[maml:name/text() = '{parameterName}']", resolver);
Assert.That(parameter, Is.Not.Null);

var attribute = parameter.Attribute("globbing");
Expand All @@ -292,7 +292,7 @@ public void Command_Parameters_Parameter_AliasesAttribute(string parameterName,
Assert.That(testManualElementsCommandElement, Is.Not.Null);

var parameter = testManualElementsCommandElement.XPathSelectElement(
string.Format("command:parameters/command:parameter[maml:name/text() = '{0}']", parameterName), resolver);
$"command:parameters/command:parameter[maml:name/text() = '{parameterName}']", resolver);
Assert.That(parameter, Is.Not.Null);

var attribute = parameter.Attribute("aliases");
Expand All @@ -310,8 +310,7 @@ public void Command_Parameters_Parameter_AliasesExistAsParametersWithNote(string
foreach (var alias in aliases.Split(','))
{
var parameter = testManualElementsCommandElement.XPathSelectElement(
string.Format(
"command:parameters/command:parameter[maml:name/text() = '{0}']", alias), resolver);
$"command:parameters/command:parameter[maml:name/text() = '{alias}']", resolver);
Assert.That(parameter, Is.Not.Null);

var description = parameter.XPathSelectElement("maml:description", resolver);
Expand Down

0 comments on commit a11da64

Please sign in to comment.