Esempio n. 1
0
        private static void SanityCheck(LogAnalyzer analyzer, Options options = null)
        {
            var dupes = analyzer.Invocations
                        .Where(i => i.AssemblyName != null)
                        .GroupBy(i => i.AssemblyName, StringComparer.OrdinalIgnoreCase)
                        .Where(g => g.Count() > 1).ToArray();

            if (dupes.Any())
            {
                foreach (var dupe in dupes)
                {
                    Log.Exception("=== Dupes: " + dupe.Key);
                    foreach (var value in dupe)
                    {
                        Log.Exception(value.ToString());
                    }
                }
            }

            var ambiguousProjects = analyzer.assemblyNameToProjectFilePathsMap.Where(kvp => kvp.Value.Count > 1).ToArray();

            if (ambiguousProjects.Any())
            {
                foreach (var ambiguousProject in ambiguousProjects)
                {
                    Log.Exception("Multiple projects for the same assembly name: " + ambiguousProject.Key);
                    foreach (var value in ambiguousProject.Value)
                    {
                        Log.Exception(value);
                    }
                }
            }

            var ambiguousIntermediatePaths = analyzer.intermediateAssemblyPathToOutputAssemblyPathMap
                                             .GroupBy(kvp => Path.GetFileNameWithoutExtension(kvp.Key), StringComparer.OrdinalIgnoreCase)
                                             .Where(g => g.Count() > 1)
                                             .OrderByDescending(g => g.Count());

            if (ambiguousIntermediatePaths.Any())
            {
            }

            if (analyzer.ambiguousFinalDestinations.Any())
            {
            }

            foreach (var assemblyName in ambiguousInvocations.Keys.ToArray())
            {
                var  values       = ambiguousInvocations[assemblyName].ToArray();
                bool shouldRemove = true;
                for (int i = 1; i < values.Length; i++)
                {
                    if (!values[i].OutputAssemblyPath.Equals(values[0].OutputAssemblyPath))
                    {
                        // if entries in a bucket are different, we keep the bucket to report it at the end
                        shouldRemove = false;
                        break;
                    }
                }

                // remove buckets where all entries are exactly the same
                if (shouldRemove)
                {
                    ambiguousInvocations.Remove(assemblyName);
                }
            }

            if (ambiguousInvocations.Any())
            {
                foreach (var ambiguousInvocation in ambiguousInvocations)
                {
                    Log.Exception("Ambiguous invocations for the same assembly name: " + ambiguousInvocation.Key);
                    foreach (var value in ambiguousInvocation.Value)
                    {
                        Log.Exception(value.ToString());
                    }
                }
            }

            if (options.CheckForNonExistingReferences)
            {
                DumpNonExistingReferences();
            }
        }