Skip to content

Commit

Permalink
Merge branch 'master' into ujjwalchadha/minimize_idic_usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwalchadha authored Oct 7, 2021
2 parents 0b13794 + bd25372 commit 66f4c01
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 162 deletions.
6 changes: 3 additions & 3 deletions src/Authoring/WinRT.Host.Shim/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static class ActivationLoader
#else
private class ActivationLoader : AssemblyLoadContext
{
private static readonly ConcurrentDictionary<string, ActivationLoader> ALCMapping = new ConcurrentDictionary<string, ActivationLoader>();
private static readonly ConcurrentDictionary<string, ActivationLoader> ALCMapping = new ConcurrentDictionary<string, ActivationLoader>(StringComparer.Ordinal);
private AssemblyDependencyResolver _resolver;

public static Assembly LoadAssembly(string targetAssembly)
Expand All @@ -79,7 +79,7 @@ private ActivationLoader(string path)
AssemblyLoadContext.Default.Resolving += (AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName) =>
{
// Consolidate all WinRT.Runtime loads to the default ALC, or failing that, the first shim ALC
if (assemblyName.Name == "WinRT.Runtime")
if (string.CompareOrdinal(assemblyName.Name, "WinRT.Runtime") == 0)
{
string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
Expand All @@ -93,7 +93,7 @@ private ActivationLoader(string path)

protected override Assembly Load(AssemblyName assemblyName)
{
if (assemblyName.Name != "WinRT.Runtime")
if (string.CompareOrdinal(assemblyName.Name, "WinRT.Runtime") != 0)
{
string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
Expand Down
7 changes: 4 additions & 3 deletions src/Authoring/WinRT.SourceGenerator/DiagnosticHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ private void ImplementsInvalidInterface(INamedTypeSymbol typeSymbol, TypeDeclara
bool AsyncActionCase(INamedTypeSymbol sym)
{
// are we using Windows.Foundation.IAsyncAction ?
bool isWindowsFoundation = sym.ContainingNamespace.IsGlobalNamespace || sym.ContainingNamespace.Name == "Windows.Foundation";
bool isAsyncAction = sym.MetadataName == "IAsyncAction";
bool isWindowsFoundation = sym.ContainingNamespace.IsGlobalNamespace ||
string.CompareOrdinal(sym.ContainingNamespace.Name, "Windows.Foundation") == 0;
bool isAsyncAction = string.CompareOrdinal(sym.MetadataName, "IAsyncAction") == 0;
return isWindowsFoundation && isAsyncAction;
}

Expand Down Expand Up @@ -159,7 +160,7 @@ private bool MatchesAnyAttribute(string attrName, SyntaxList<AttributeListSyntax
foreach (var attr in attrList.Attributes)
{
// no declared symbol for AttributeSyntax...
if (attr.Name.ToString() == attrName)
if (string.CompareOrdinal(attr.Name.ToString(), attrName) == 0)
{
return true;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Authoring/WinRT.SourceGenerator/DiagnosticUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ private void HasConflictingParameterName(MethodDeclarationSyntax method)
/// <param name="methodDeclarations">Collection of methods</param><param name="typeId">Containing class or interface</param>
private void CheckMethods(IEnumerable<MethodDeclarationSyntax> methodDeclarations, SyntaxToken typeId)
{
Dictionary<string, bool> methodsHasAttributeMap = new();
Dictionary<string, Diagnostic> overloadsWithoutAttributeMap = new Dictionary<string, Diagnostic>();
Dictionary<string, bool> methodsHasAttributeMap = new(StringComparer.Ordinal);
Dictionary<string, Diagnostic> overloadsWithoutAttributeMap = new Dictionary<string, Diagnostic>(StringComparer.Ordinal);

// var methodDeclarations = interfaceDeclaration.DescendantNodes().OfType<MethodDeclarationSyntax>();
foreach (MethodDeclarationSyntax method in methodDeclarations)
Expand Down Expand Up @@ -402,23 +402,23 @@ private void CheckStructFields(StructDeclarationSyntax @struct)
/// <param name="namespace">the authored namespace to check</param><param name="assemblyName">the name of the component/winmd</param>
/// <returns>True iff namespace is disjoint from the assembly name</returns>
private bool IsInvalidNamespace(INamespaceSymbol @namespace, string assemblyName)
{
if (@namespace.ToString() == assemblyName)
{
if (string.CompareOrdinal(@namespace.ToString(), assemblyName) == 0)
{
return false;
}

var topLevel = @namespace;
while (!topLevel.ContainingNamespace.IsGlobalNamespace)
{
if (topLevel.ToString() == assemblyName)
{
if (string.CompareOrdinal(topLevel.ToString(), assemblyName) == 0)
{
return false;
}
topLevel = topLevel.ContainingNamespace;
}

return topLevel.ToString() != assemblyName;
return string.CompareOrdinal(topLevel.ToString(), assemblyName) != 0;
}

///<summary>Array types can only be one dimensional and not System.Array,
Expand Down
2 changes: 1 addition & 1 deletion src/Authoring/WinRT.SourceGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public class SourceGenerator : ISourceGenerator
{
public void Execute(GeneratorExecutionContext context)
{
var isTest = Process.GetCurrentProcess().ProcessName == "testhost";
var isTest = string.CompareOrdinal(Process.GetCurrentProcess().ProcessName, "testhost") == 0;
if (!isTest && !context.IsCsWinRTComponent())
{
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Authoring/WinRT.SourceGenerator/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AttributeDataComparer : IEqualityComparer<AttributeData>
{
public bool Equals(AttributeData x, AttributeData y)
{
return x.ToString() == y.ToString();
return string.CompareOrdinal(x.ToString(), y.ToString()) == 0;
}

public int GetHashCode(AttributeData obj)
Expand Down
Loading

0 comments on commit 66f4c01

Please sign in to comment.