Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre

// build anonymous type field descriptor
fieldSyntaxNodes[i] = (nameToken.Kind() == SyntaxKind.IdentifierToken) ? (CSharpSyntaxNode)nameToken.Parent : fieldInitializer;
fields[i] = new AnonymousTypeField(fieldName == null ? '$' + i.ToString() : fieldName, fieldSyntaxNodes[i].Location, fieldType);
fields[i] = new AnonymousTypeField(fieldName == null ? "$" + i.ToString() : fieldName, fieldSyntaxNodes[i].Location, fieldType);

// NOTE: ERR_InvalidAnonymousTypeMemberDeclarator (CS0746) would be generated by parser if needed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private bool IsNew(IFieldSymbol field)

private string GenerateFieldName(IFieldSymbol field, string correspondingPropertyName)
{
return char.ToLower(correspondingPropertyName[0]) + correspondingPropertyName.Substring(1);
return char.ToLower(correspondingPropertyName[0]).ToString() + correspondingPropertyName.Substring(1);
}

protected string MakeUnique(string baseName, INamedTypeSymbol containingType, bool considerBaseMembers = true)
Expand Down
6 changes: 3 additions & 3 deletions src/Features/Core/Completion/CommonCompletionUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis.Completion
{
internal static class CommonCompletionUtilities
{
private const char NonBreakingSpace = (char)0x00A0;
private const string NonBreakingSpaceString = "\x00A0";

public static TextSpan GetTextChangeSpan(SourceText text, int position,
Func<char, bool> isWordStartCharacter, Func<char, bool> isWordCharacter)
Expand Down Expand Up @@ -123,7 +123,7 @@ private static async Task<ImmutableArray<SymbolDisplayPart>> CreateDescriptionAs
textContentBuilder.AddSpace();
textContentBuilder.AddPunctuation("(");
textContentBuilder.AddPunctuation("+");
textContentBuilder.AddText(NonBreakingSpace + overloadCount.ToString());
textContentBuilder.AddText(NonBreakingSpaceString + overloadCount.ToString());

AddOverloadPart(textContentBuilder, overloadCount, isGeneric);

Expand Down Expand Up @@ -170,7 +170,7 @@ private static void AddOverloadPart(List<SymbolDisplayPart> textContentBuilder,
? FeaturesResources.Overload
: FeaturesResources.Overloads;

textContentBuilder.AddText(NonBreakingSpace + text);
textContentBuilder.AddText(NonBreakingSpaceString + text);
}

private static void AddDocumentationPart(List<SymbolDisplayPart> textContentBuilder, ISymbol symbol, SemanticModel semanticModel, int position, IDocumentationCommentFormattingService formatter, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private static ValueTuple<string, VersionStamp> GetUniqueDiagnosticStateNameAndV
var providerType = provider.GetType();
var location = providerType.Assembly.Location;

return ValueTuple.Create(UserDiagnosticsPrefixTableName + "_" + type + "_" + providerType.AssemblyQualifiedName, GetProviderVersion(location));
return ValueTuple.Create(UserDiagnosticsPrefixTableName + "_" + type.ToString() + "_" + providerType.AssemblyQualifiedName, GetProviderVersion(location));
}

private static VersionStamp GetProviderVersion(string path)
Expand Down
2 changes: 1 addition & 1 deletion src/Features/Core/EditAndContinue/LineChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override int GetHashCode()

public override string ToString()
{
return OldLine + " -> " + NewLine;
return OldLine.ToString() + " -> " + NewLine.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,12 @@ protected IMethodSymbol CreateGet(string originalFieldName, IFieldSymbol field,
new[] { body }.ToList());
}

private static readonly char[] s_underscoreCharArray = new[] { '_' };

protected string GeneratePropertyName(string fieldName)
{
// Trim leading underscores
var baseName = fieldName.TrimStart('_');
var baseName = fieldName.TrimStart(s_underscoreCharArray);

// Trim leading "m_"
if (baseName.Length >= 2 && baseName[0] == 'm' && baseName[1] == '_')
Expand All @@ -366,7 +368,7 @@ protected string GeneratePropertyName(string fieldName)
}

// Make uppercase the first letter
return char.ToUpper(baseName[0]) + baseName.Substring(1);
return char.ToUpper(baseName[0]).ToString() + baseName.Substring(1);
}

protected abstract Task<SyntaxNode> RewriteFieldNameAndAccessibility(string originalFieldName, bool makePrivate, Document document, SyntaxAnnotation declarationAnnotation, CancellationToken cancellationToken);
Expand Down
5 changes: 3 additions & 2 deletions src/Features/Core/ExtractMethod/MethodExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ internal static string MakeMethodName(string prefix, string originalName)
var startingWithLetter = originalName.SkipWhile(c => !char.IsLetter(c)).ToArray();
var name = startingWithLetter.Length == 0 ? originalName : new string(startingWithLetter);

var methodName = char.IsUpper(name[0]) ? name : char.ToUpper(name[0]) + name.Substring(1);
return prefix + methodName;
return char.IsUpper(name[0]) ?
prefix + name :
prefix + char.ToUpper(name[0]).ToString() + name.Substring(1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ private string GenerateAnonymousTypeName(int current)
char c = (char)('a' + current);
if (c >= 'a' && c <= 'z')
{
return "'" + c;
return "'" + c.ToString();
}

return "'" + current;
return "'" + current.ToString();
}

private IList<INamedTypeSymbol> OrderAnonymousTypes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal static bool TryGetAccessors(
private static string GenerateFieldName(PropertyDeclarationSyntax property, SemanticModel semanticModel)
{
var baseName = property.Identifier.ValueText;
baseName = char.ToLower(baseName[0]) + baseName.Substring(1);
baseName = char.ToLower(baseName[0]).ToString() + baseName.Substring(1);

var propertySymbol = semanticModel.GetDeclaredSymbol(property);
if (propertySymbol == null ||
Expand All @@ -99,7 +99,7 @@ private static string GenerateFieldName(PropertyDeclarationSyntax property, Sema
var name = baseName;
while (propertySymbol.ContainingType.MemberNames.Contains(name))
{
name = baseName + ++index;
name = baseName + (++index).ToString();
}

return name;
Expand Down
2 changes: 1 addition & 1 deletion src/Scripting/Core/ObjectFormatter.Formatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public int MinimalLength

public string GetDisplayName()
{
return Name ?? "[" + Index + "]";
return Name ?? "[" + Index.ToString() + "]";
}

public bool HasKeyName()
Expand Down
7 changes: 4 additions & 3 deletions src/Scripting/Core/ScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public ScriptBuilder(AssemblyLoader assemblyLoader = null)
assemblyLoader = new InteractiveAssemblyLoader();
}

_assemblyNamePrefix = s_globalAssemblyNamePrefix + "#" + Interlocked.Increment(ref s_engineIdDispenser);
_assemblyNamePrefix = s_globalAssemblyNamePrefix + "#" + Interlocked.Increment(ref s_engineIdDispenser).ToString();
_collectibleCodeManager = new CollectibleCodeManager(assemblyLoader, _assemblyNamePrefix);
_uncollectibleCodeManager = new UncollectibleCodeManager(assemblyLoader, _assemblyNamePrefix);
}
Expand All @@ -111,8 +111,9 @@ internal static bool IsReservedAssemblyName(AssemblyIdentity identity)
public int GenerateSubmissionId(out string assemblyName, out string typeName)
{
int id = Interlocked.Increment(ref _submissionIdDispenser);
assemblyName = _assemblyNamePrefix + id;
typeName = "Submission#" + id;
string idAsString = id.ToString();
assemblyName = _assemblyNamePrefix + idAsString;
typeName = "Submission#" + idAsString;
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ internal bool TrySubmit()
trimmedFileName = trimmedFileName.StartsWith("\\") ? trimmedFileName.Substring(1) : trimmedFileName;

// Construct the full path of the file to be created
this.FullFilePath = implicitFilePath + '\\' + trimmedFileName;
this.FullFilePath = implicitFilePath + "\\" + trimmedFileName;

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.PreviewPane
{
internal partial class PreviewPane : UserControl, IDisposable
{
private static readonly string s_dummyThreeLineTitle = 'A' + Environment.NewLine + 'A' + Environment.NewLine + 'A';
private static readonly string s_dummyThreeLineTitle = "A" + Environment.NewLine + "A" + Environment.NewLine + "A";
private static readonly Size s_infiniteSize = new Size(double.PositiveInfinity, double.PositiveInfinity);

private readonly string _errorId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ private IEnumerable<ProjectFileReference> GetProjectReferencesCore(ProjectInstan
private ProjectFileInfo CreateProjectFileInfo(CSharpCompilerInputs compilerInputs, MSB.Execution.ProjectInstance executedProject)
{
string projectDirectory = executedProject.Directory;
if (!projectDirectory.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.OrdinalIgnoreCase))
string directorySeparator = Path.DirectorySeparatorChar.ToString();
if (!projectDirectory.EndsWith(directorySeparator, StringComparison.OrdinalIgnoreCase))
{
projectDirectory += Path.DirectorySeparatorChar;
projectDirectory += directorySeparator;
}

var docs = compilerInputs.Sources
Expand Down
4 changes: 2 additions & 2 deletions src/Workspaces/CSharp/Portable/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static string EscapeIdentifier(
// Check if we need to escape this contextual keyword
needsEscaping = needsEscaping || (isQueryContext && SyntaxFacts.IsQueryContextualKeyword(SyntaxFacts.GetContextualKeywordKind(identifier)));

return needsEscaping ? '@' + identifier : identifier;
return needsEscaping ? "@" + identifier : identifier;
}

public static SyntaxToken ToIdentifierToken(
Expand All @@ -44,7 +44,7 @@ public static SyntaxToken ToIdentifierToken(
: identifier;

var token = SyntaxFactory.Identifier(
default(SyntaxTriviaList), SyntaxKind.None, '@' + unescaped, unescaped, default(SyntaxTriviaList));
default(SyntaxTriviaList), SyntaxKind.None, "@" + unescaped, unescaped, default(SyntaxTriviaList));

if (!identifier.StartsWith("@"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public static string GetRelativePath(string baseDirectory, string fullPath)

// add backup notation for remaining base path levels beyond the index
var remainingParts = basePathParts.Length - index;
for (int i = 0; i < remainingParts; i++)
if (remainingParts > 0)
{
relativePath += relativePath + ".." + Path.DirectorySeparatorChar;
string directorySeparator = Path.DirectorySeparatorChar.ToString();
for (int i = 0; i < remainingParts; i++)
{
relativePath += relativePath + ".." + directorySeparator;
}
}

// add the rest of the full path parts
Expand Down