diff --git a/Arcade.sln b/Arcade.sln index 33659aaf739..b78586845ff 100644 --- a/Arcade.sln +++ b/Arcade.sln @@ -83,8 +83,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Build.Task EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Helix.Sdk.Tests", "src\Microsoft.DotNet.Helix\Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests.csproj", "{03390E61-9DC1-4893-93A4-193D76C16034}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.AsmDiff", "src\Microsoft.DotNet.AsmDiff\Microsoft.DotNet.AsmDiff.csproj", "{FDCE3109-3EA0-4166-B6C0-BE7BB4196864}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.SharedFramework.Sdk", "src\Microsoft.DotNet.SharedFramework.Sdk\Microsoft.DotNet.SharedFramework.Sdk.csproj", "{9EB0B2AE-C55C-4DEF-90B3-44E73F0A366D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Build.Tasks.Installers", "src\Microsoft.DotNet.Build.Tasks.Installers\Microsoft.DotNet.Build.Tasks.Installers.csproj", "{32070F78-5045-4402-BCB5-D8A2D479770A}" @@ -595,18 +593,6 @@ Global {03390E61-9DC1-4893-93A4-193D76C16034}.Release|x64.Build.0 = Release|Any CPU {03390E61-9DC1-4893-93A4-193D76C16034}.Release|x86.ActiveCfg = Release|Any CPU {03390E61-9DC1-4893-93A4-193D76C16034}.Release|x86.Build.0 = Release|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Debug|x64.ActiveCfg = Debug|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Debug|x64.Build.0 = Debug|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Debug|x86.ActiveCfg = Debug|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Debug|x86.Build.0 = Debug|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Release|Any CPU.Build.0 = Release|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Release|x64.ActiveCfg = Release|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Release|x64.Build.0 = Release|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Release|x86.ActiveCfg = Release|Any CPU - {FDCE3109-3EA0-4166-B6C0-BE7BB4196864}.Release|x86.Build.0 = Release|Any CPU {9EB0B2AE-C55C-4DEF-90B3-44E73F0A366D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9EB0B2AE-C55C-4DEF-90B3-44E73F0A366D}.Debug|Any CPU.Build.0 = Debug|Any CPU {9EB0B2AE-C55C-4DEF-90B3-44E73F0A366D}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/Directory.Build.targets b/Directory.Build.targets index edebe63fdee..99449926093 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,7 +1,6 @@ - diff --git a/eng/Microsoft.DotNet.XliffTasks.InTree.targets b/eng/Microsoft.DotNet.XliffTasks.InTree.targets deleted file mode 100644 index f68b62bb22b..00000000000 --- a/eng/Microsoft.DotNet.XliffTasks.InTree.targets +++ /dev/null @@ -1,33 +0,0 @@ - - - - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'Microsoft.DotNet.XliffTasks')) - $(ArtifactsBinDir)Microsoft.DotNet.XliffTasks\$(Configuration)\ - - $(XliffTasksBaseOutputDirectory)$(NetToolMinimum)\ - $(XliffTasksBaseOutputDirectory)$(NetFrameworkToolCurrent)\ - - TaskHostFactory - - ResolveProjectReferences - - - - - - - - - - - TargetFramework=$(NetToolMinimum) - TargetFramework=$(NetFrameworkToolCurrent) - - - - diff --git a/src/Microsoft.Cci.Extensions/Experimental/TrimAPIMutator.cs b/src/Microsoft.Cci.Extensions/Experimental/TrimAPIMutator.cs deleted file mode 100644 index ef76cb39ef6..00000000000 --- a/src/Microsoft.Cci.Extensions/Experimental/TrimAPIMutator.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using Microsoft.Cci; -//using Microsoft.Cci.Extensions; -//using Microsoft.Cci.MutableCodeModel; - -//namespace AsmDiff -//{ -// public interface ITrimFilter -// { -// bool TrimAttribute(ICustomAttribute attribute); -// bool TrimMember(ITypeDefinitionMember member); -// bool TrimType(ITypeDefinition type); -// } - -// public class PublicOlyTrimFilter : ITrimFilter -// { -// public bool TrimAttribute(ICustomAttribute attribute) -// { -// return false; -// } - -// public bool TrimMember(ITypeDefinitionMember member) -// { -// return !member.IsVisibleOutsideAssembly(); -// } - -// public bool TrimType(ITypeDefinition type) -// { -// return !type.IsVisibleOutsideAssembly(); -// } -// } - -// public class TrimAPIMutator : MetadataMutator -// { -// private ITrimFilter _filter; - -// public TrimAPIMutator(IMetadataHost host, ITrimFilter filter) -// : base(host) -// { -// _filter = filter; -// } - -// public static IAssembly TrimNonPublicAPIs(IAssembly assembly) -// { -// TrimAPIMutator trim = new TrimAPIMutator(new HostEnvironment(), new PublicOlyTrimFilter()); - -// return trim.Visit(assembly); -// } - -// public override List Visit(List members) -// { -// List newList = new List(); -// foreach (var member in members) -// { -// ITypeDefinition type = member as ITypeDefinition; -// if (type != null) -// { -// if (!_filter.TrimType(type)) -// newList.Add(member); -// } -// else -// { -// newList.Add(member); -// } -// } -// return base.Visit(newList); -// } - -// public override List Visit(List properties) -// { -// properties.RemoveAll(p => _filter.TrimMember(p)); -// return base.Visit(properties); -// } - -// public override List Visit(List events) -// { -// events.RemoveAll(e => _filter.TrimMember(e)); -// return base.Visit(events); -// } - -// public override List Visit(List methods) -// { -// methods.RemoveAll(m => _filter.TrimMember(m)); -// return base.Visit(methods); -// } - -// public override List Visit(List types) -// { -// types.RemoveAll(t => _filter.TrimMember(t)); -// return base.Visit(types); -// } - -// public override List Visit(List members) -// { -// members.RemoveAll(m => _filter.TrimMember(m)); -// return base.Visit(members); -// } - -// public override List Visit(List customAttributes) -// { -// customAttributes.RemoveAll(a => _filter.TrimAttribute(a)); -// return base.Visit(customAttributes); -// } - -// public override List Visit(List securityAttributes) -// { -// securityAttributes.RemoveAll(sa => sa.Attributes.Any(a => _filter.TrimAttribute(a))); -// return base.Visit(securityAttributes); -// } - -// public override MethodDefinition Visit(MethodDefinition methodDefinition) -// { -// // Kill the implementation -// methodDefinition.Body = Dummy.MethodBody; -// return base.Visit(methodDefinition); -// } -// } - -//} diff --git a/src/Microsoft.DotNet.AsmDiff/ApiRecordingCSharpDiffWriter.cs b/src/Microsoft.DotNet.AsmDiff/ApiRecordingCSharpDiffWriter.cs deleted file mode 100644 index e220fd5c700..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/ApiRecordingCSharpDiffWriter.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; -using Microsoft.Cci.Writers; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.DotNet.AsmDiff -{ - internal sealed class ApiRecordingCSharpDiffWriter : DiffCSharpWriter, ICciDifferenceWriter - { - private DiffRecorder _diffRecorder; - private MappingSettings _settings; - private List _apis = new List(); - private Stack> _apiStack = new Stack>(); - private Stack _apiDefinitionStack = new Stack(); - - public ApiRecordingCSharpDiffWriter(DiffRecorder diffRecorder, MappingSettings settings, bool includePseudoCustomAttributes) - : base(diffRecorder, settings, Enumerable.Empty(), includePseudoCustomAttributes) - { - _diffRecorder = diffRecorder; - _settings = settings; - } - - public List ApiDefinitions - { - get { return _apis.ToList(); } - } - - public new void Write(string oldAssembliesName, IEnumerable oldAssemblies, string newAssembliesName, IEnumerable newAssemblies) - { - AssemblySetMapping mapping; - if (!string.IsNullOrEmpty(newAssembliesName)) - { - _settings.ElementCount = 2; - mapping = new AssemblySetMapping(_settings); - mapping.AddMappings(oldAssemblies, newAssemblies); - } - else - { - _settings.ElementCount = 1; - mapping = new AssemblySetMapping(_settings); - mapping.AddMapping(0, oldAssemblies); - } - Visit(mapping); - } - - private void PushApi(ElementMapping elementMapping) - where T : class, IDefinition - { - var left = elementMapping[0]; - var right = elementMapping.ElementCount == 1 - ? null - : elementMapping[1]; - - var difference = elementMapping.Difference; - - var newChildren = new List(); - var apiDefinition = new DiffApiDefinition(left, right, difference, newChildren) - { - StartLine = _diffRecorder.Line - }; - _apis.Add(apiDefinition); - - _apiStack.Push(_apis); - _apiDefinitionStack.Push(apiDefinition); - _apis = newChildren; - } - - private void PopApi() - { - var currentApi = _apiDefinitionStack.Pop(); - currentApi.EndLine = _diffRecorder.Line - 1; - - _apis = _apiStack.Pop(); - } - - public override void Visit(AssemblyMapping assembly) - { - _diffRecorder.CancellationToken.ThrowIfCancellationRequested(); - - PushApi(assembly); - base.Visit(assembly); - PopApi(); - } - - public override void Visit(NamespaceMapping ns) - { - _diffRecorder.CancellationToken.ThrowIfCancellationRequested(); - - PushApi(ns); - base.Visit(ns); - PopApi(); - } - - public override void Visit(TypeMapping type) - { - _diffRecorder.CancellationToken.ThrowIfCancellationRequested(); - - PushApi(type); - base.Visit(type); - PopApi(); - } - - public override void Visit(MemberMapping member) - { - _diffRecorder.CancellationToken.ThrowIfCancellationRequested(); - - var shouldVisit = !IsPropertyOrEventAccessor(member.Representative) && - !IsEnumValueField(member.Representative) && - !IsDelegateMember(member.Representative); - - if (shouldVisit) - PushApi(member); - - base.Visit(member); - - if (shouldVisit) - PopApi(); - } - - private static bool IsPropertyOrEventAccessor(ITypeDefinitionMember representative) - { - var methodDefinition = representative as IMethodDefinition; - if (methodDefinition == null) - return false; - - return methodDefinition.IsPropertyOrEventAccessor(); - } - - private static bool IsEnumValueField(ITypeDefinitionMember representative) - { - var isEnumMember = representative.ContainingTypeDefinition.IsEnum; - if (!isEnumMember) - return false; - - return representative.Name.Value == "value__"; - } - - private static bool IsDelegateMember(ITypeDefinitionMember representative) - { - return representative.ContainingTypeDefinition.IsDelegate; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/AssemblyClassification.cs b/src/Microsoft.DotNet.AsmDiff/AssemblyClassification.cs deleted file mode 100644 index 109115a28fc..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/AssemblyClassification.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff -{ - public enum AssemblyClassification - { - Included, - Dependency, - MissingDependency, - NonRequiredDependency - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/AssemblySet.cs b/src/Microsoft.DotNet.AsmDiff/AssemblySet.cs deleted file mode 100644 index ad6ff63c205..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/AssemblySet.cs +++ /dev/null @@ -1,246 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.IO; -using System.Linq; -using Microsoft.Cci; -using Microsoft.Cci.Extensions; - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class AssemblySet : IEnumerable, IDisposable - { - private AssemblySet(IMetadataHost metadataHost, IEnumerable includedAssemblies, string name) - { - // We want to ensure a few things here: - // - // (1) We want the same assembly only once - // (2) We want the assemblies sorted by identity - // (3) We want a snapshot - // (4) We want all assembly references in the host to be resolved. - // We don't care whether they can be resolved or not -- we only - // care that resolution has been finished so that LoadedUnits - // in the host contains all assemblies. - - var includedAssemblySet = new HashSet(includedAssemblies); - var includedAssembliesSorted = includedAssemblySet.OrderByIdentity() - .ToArray(); - - // Ensure all assembly references are resolved - - if (metadataHost != null) - ResolveAllAssemblies(metadataHost); - - var dependencies = - ClassifyReferences(metadataHost, includedAssemblySet) - .Where(a => a.Classification == AssemblyClassification.Dependency || - a.Classification == AssemblyClassification.NonRequiredDependency) - .Select(a => a.Reference.ResolvedAssembly) - .OrderByIdentity() - .ToArray(); - - IsEmpty = includedAssembliesSorted.Length == 0 && dependencies.Length == 0; - Host = metadataHost; - Assemblies = new ReadOnlyCollection(includedAssembliesSorted); - Dependencies = new ReadOnlyCollection(dependencies); - Name = name; - } - - private static void ResolveAllAssemblies(IMetadataHost metadataHost) - { - var processedSet = new HashSet(); - var queue = new Queue(metadataHost.LoadedUnits.OfType()); - - while (queue.Count > 0) - { - var assembly = queue.Dequeue(); - if (!processedSet.Add(assembly)) - continue; - - var resolved = assembly.ResolvedAssembly; - foreach (var reference in resolved.AssemblyReferences) - queue.Enqueue(reference); - } - } - - private static AssemblySet FromAssemblies(IMetadataHost metadataHost, IAssembly[] assemblies, string name) - { - // We shouldn't return Empty if an explicit name was provided. Otherwise the name is lost. - if (string.IsNullOrEmpty(name) && (assemblies == null || assemblies.Length == 0)) - return Empty; - - if (name == null) - { - var firstLocation = assemblies.Select(a => a.Location).First(); - name = assemblies.Length == 1 - ? firstLocation - : Path.GetDirectoryName(firstLocation); - } - - return new AssemblySet(metadataHost, assemblies, name); - } - - public static AssemblySet FromPaths(string name, params string[] paths) - { - return FromPaths(paths.AsEnumerable(), name); - } - - public static AssemblySet FromPaths(IEnumerable paths, string name) - { - if (paths == null) - return Empty; - - var environment = new HostEnvironment(); - - // TODO: That's not necessarily great. We may want to expose a setting for that. - environment.UnifyToLibPath = true; - - // We want to support path separators here, such as D:\foo.dll;D:\bar.dll - var allPaths = paths.SelectMany(HostEnvironment.SplitPaths).ToArray(); - - var assemblyArray = environment.LoadAssemblies(allPaths).ToArray(); - - // We want to support cases where the paths don't point to valid assemblies. - // In that case, we still want to use the supplied paths to generate a - // meaningful name. - - if (string.IsNullOrEmpty(name) && assemblyArray.Length == 0 && allPaths.Any()) - { - var firstPath = allPaths.First(); - name = allPaths.Length == 1 - ? firstPath - : Path.GetDirectoryName(firstPath); - } - - return FromAssemblies(environment, assemblyArray, name); - } - - public AssemblySet WithAssemblies(IEnumerable assemblies) - { - var assembliesSnapshot = GetSnapshotAndVerifyAssembliesAreInTheSameHost(assemblies); - return new AssemblySet(Host, assembliesSnapshot, Name); - } - - public AssemblySet Remove(IEnumerable assemblies) - { - var snapshot = assemblies.ToArray(); - var assemblyPaths = Assemblies.Except(snapshot).Select(a => a.Location).ToArray(); - var dependencyPaths = Dependencies.Except(snapshot).Select(a => a.Location).ToArray(); - var allPaths = assemblyPaths.Union(dependencyPaths); - var newAssemblySet = FromPaths(allPaths, Name); - var newAssemblies = assemblyPaths.Select(p => newAssemblySet.Host.LoadUnitFrom(p)).OfType(); - return newAssemblySet.WithAssemblies(newAssemblies); - } - - private IEnumerable GetSnapshotAndVerifyAssembliesAreInTheSameHost(IEnumerable assemblies) - { - var assembliesSnapshot = assemblies.ToArray(); - var loadedAssemblies = Host == null - ? Enumerable.Empty() - : Host.LoadedUnits.OfType(); - var loadedAssembliesSet = new HashSet(loadedAssemblies); - - if (assembliesSnapshot.Any() && loadedAssembliesSet.Any()) - { - if (assembliesSnapshot.Any(a => !loadedAssembliesSet.Contains(a))) - throw new ArgumentException("assemblies", "Assemblies must only contain assemblies loaded in the current host"); - } - - return assembliesSnapshot; - } - - private static IEnumerable GetRequiredAssemblies(IEnumerable assemblies) - { - var queue = new Queue(assemblies); - var processedSet = new HashSet(); - - while (queue.Count > 0) - { - var reference = queue.Dequeue(); - var resolved = reference.ResolvedAssembly; - if (resolved is Dummy || !processedSet.Add(resolved)) - continue; - - foreach (var assemblyReference in resolved.AssemblyReferences) - queue.Enqueue(assemblyReference); - } - - return processedSet.OrderByIdentity(); - } - - private static IEnumerable ClassifyReferences(IMetadataHost host, IEnumerable includedAssemblies) - { - if (host == null) - return Enumerable.Empty(); - - var includedAssemblySet = new HashSet(includedAssemblies); - var loadedAssemblies = host.LoadedUnits.OfType() - .Where(a => !(a is Dummy)) - .ToArray(); - - var requiredAssemblySet = new HashSet(GetRequiredAssemblies(includedAssemblySet)); - - // NOTE: Due to unification within our host, we need to make sure we only consider - // the unified reference. We do this by using the identitity of the resovled - // assembly, if it exists. For unresolved identities we use the identity of - // the reference. - var allReferences = loadedAssemblies.Concat(loadedAssemblies.SelectMany(a => a.AssemblyReferences)) - .Select(r => r.ResolvedAssembly.IsDummy() ? r : r.ResolvedAssembly); - - var processedIdentities = new HashSet(); - - return from reference in allReferences - where processedIdentities.Add(reference.AssemblyIdentity) - let resolved = reference.ResolvedAssembly - let classification = resolved is Dummy - ? AssemblyClassification.MissingDependency - : includedAssemblySet.Contains(resolved) - ? AssemblyClassification.Included - : requiredAssemblySet.Contains(resolved) - ? AssemblyClassification.Dependency - : AssemblyClassification.NonRequiredDependency - orderby reference.Name.Value, - reference.GetPublicKeyToken(), - reference.Version - select new ClassifiedAssembly(reference, classification); - } - - public static readonly AssemblySet Empty = new AssemblySet(null, Enumerable.Empty(), "Empty"); - - public bool IsEmpty { get; private set; } - - public bool IsNull - { - get { return ReferenceEquals(this, Empty); } - } - - public IMetadataHost Host { get; private set; } - - public string Name { get; private set; } - - public ReadOnlyCollection Assemblies { get; private set; } - - public ReadOnlyCollection Dependencies { get; private set; } - - public void Dispose() - { - var disposableHost = Host as IDisposable; - if (disposableHost != null) - disposableHost.Dispose(); - } - - public IEnumerator GetEnumerator() - { - return Assemblies.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/ClassifiedAssembly.cs b/src/Microsoft.DotNet.AsmDiff/ClassifiedAssembly.cs deleted file mode 100644 index 5e993322b3b..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/ClassifiedAssembly.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; - -namespace Microsoft.DotNet.AsmDiff -{ - public struct ClassifiedAssembly - { - public ClassifiedAssembly(IAssemblyReference reference, AssemblyClassification classification) - { - Reference = reference; - Classification = classification; - } - - public IAssemblyReference Reference { get; } - - public AssemblyClassification Classification { get; } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/CsvSettings.cs b/src/Microsoft.DotNet.AsmDiff/Csv/CsvSettings.cs deleted file mode 100644 index e2f168a0d68..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/CsvSettings.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Text; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public struct CsvSettings - { - public static CsvSettings Default = new CsvSettings( - encoding: Encoding.UTF8, - delimiter: ',', - textQualifier: '"' - ); - - public CsvSettings(Encoding encoding, char delimiter, char textQualifier) - : this() - { - Encoding = encoding; - Delimiter = delimiter; - TextQualifier = textQualifier; - } - - public Encoding Encoding { get; private set; } - public char Delimiter { get; private set; } - public char TextQualifier { get; private set; } - - public bool IsValid { get { return Encoding != null; } } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/CsvTextWriter.cs b/src/Microsoft.DotNet.AsmDiff/Csv/CsvTextWriter.cs deleted file mode 100644 index 2a224607af9..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/CsvTextWriter.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.IO; -using System.Text; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public class CsvTextWriter : CsvWriter - { - private TextWriter _textWriter; - private bool _valuesSeen; - private char[] _textDelimiters; - - public CsvTextWriter(TextWriter textWriter) - : this(textWriter, CsvSettings.Default) - { - } - - public CsvTextWriter(TextWriter textWriter, CsvSettings settings) - : base(settings) - { - _textWriter = textWriter; - _textDelimiters = new char[] { settings.Delimiter, settings.TextQualifier, '\r', '\n' }; - } - - public override CsvSettings Settings - { - get - { - return base.Settings; - } - set - { - base.Settings = value; - _textDelimiters[0] = value.Delimiter; - _textDelimiters[1] = value.TextQualifier; - } - } - - protected override void Dispose(bool disposing) - { - if (disposing) - _textWriter.Dispose(); - } - - public override void Write(string value) - { - if (_valuesSeen) - _textWriter.Write(Settings.Delimiter); - - _valuesSeen = true; - var escapedText = EscapeValue(value); - _textWriter.Write(escapedText); - } - - public override void WriteLine() - { - if (_valuesSeen) - { - _valuesSeen = false; - _textWriter.WriteLine(); - } - } - - protected string EscapeValue(string value) - { - if (value == null) - return string.Empty; - - var textQualifier = Settings.TextQualifier; - var needsEscaping = value.IndexOfAny(_textDelimiters) >= 0; - if (!needsEscaping) - return value; - - var sb = new StringBuilder(value.Length + 2); - sb.Append(textQualifier); - foreach (var c in value) - { - if (c == textQualifier) - sb.Append(textQualifier); - - sb.Append(c); - } - sb.Append(textQualifier); - return sb.ToString(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/CsvWriter.cs b/src/Microsoft.DotNet.AsmDiff/Csv/CsvWriter.cs deleted file mode 100644 index 58dc731502c..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/CsvWriter.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public abstract class CsvWriter : IDisposable - { - private CsvSettings _settings; - - protected CsvWriter(CsvSettings settings) - { - _settings = settings; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - } - - public abstract void Write(string value); - - public virtual void Write(IEnumerable values) - { - foreach (var value in values) - Write(value); - } - - public abstract void WriteLine(); - - public virtual void WriteLine(IEnumerable values) - { - foreach (var value in values) - Write(value); - - WriteLine(); - } - - public virtual CsvSettings Settings { get { return _settings; } set { _settings = value; } } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffAssemblyCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffAssemblyCsvColumn.cs deleted file mode 100644 index feb02c587cc..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffAssemblyCsvColumn.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public abstract class DiffAssemblyCsvColumn : DiffCsvColumn - { - private int _index; - - protected DiffAssemblyCsvColumn(DiffConfiguration diffConfiguration, int index) - : base(diffConfiguration) - { - _index = index; - } - - public override bool IsVisible - { - get { return _index == 0 || DiffConfiguration.IsDiff; } - } - - public override string Name - { - get - { - switch (_index) - { - case 0: - return DiffConfiguration.IsDiff - ? "OldAssembly" - : "Assembly"; - case 1: - return "NewAssembly"; - - default: - throw new ArgumentException(); - } - } - } - - public override string GetValue(TypeMapping mapping) - { - var assembly = _index < mapping.ElementCount && mapping[_index] != null - ? mapping[_index].GetAssembly() - : null; - return assembly == null ? string.Empty : assembly.Name.Value; - } - - public override string GetValue(MemberMapping mapping) - { - var containingTypeDefinition = _index < mapping.ElementCount && mapping[_index] != null - ? mapping[_index].ContainingTypeDefinition - : null; - - var assembly = containingTypeDefinition == null - ? null - : containingTypeDefinition.GetAssembly(); - - return assembly == null ? string.Empty : assembly.Name.Value; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffCsvColumn.cs deleted file mode 100644 index a6e8db7e492..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffCsvColumn.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.ObjectModel; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public abstract class DiffCsvColumn : IDiffCsvColumn - { - protected DiffCsvColumn(DiffConfiguration diffConfiguration) - { - DiffConfiguration = diffConfiguration; - } - - public DiffConfiguration DiffConfiguration { get; private set; } - - public virtual bool IsVisible - { - get { return true; } - } - - public abstract string Name { get; } - - public string GetValue(ElementMapping mapping) where TElement : class - { - var namespaceMapping = mapping as NamespaceMapping; - if (namespaceMapping != null) - return GetValue(namespaceMapping); - - var typeMapping = mapping as TypeMapping; - if (typeMapping != null) - return GetValue(typeMapping); - - var memberMapping = mapping as MemberMapping; - if (memberMapping != null) - return GetValue(memberMapping); - - throw new ArgumentException("Unexpected mapping", "mapping"); - } - - public virtual string GetValue(NamespaceMapping mapping) - { - return null; - } - - public virtual string GetValue(TypeMapping mapping) - { - return null; - } - - public virtual string GetValue(MemberMapping mapping) - { - return null; - } - - public static ReadOnlyCollection CreateStandardColumns(DiffConfiguration diffConfiguration) - { - return new ReadOnlyCollection(new IDiffCsvColumn[] - { - new DiffIdCsvColumn(diffConfiguration), - new DiffKindCsvColumn(diffConfiguration), - new DiffSubKindCsvColumn(diffConfiguration), - new DiffStaticCsvColumn(diffConfiguration), - new DiffVirtualityCsvColumn(diffConfiguration), - new DiffOverrideCsvColumn(diffConfiguration), - new DiffUnsafeCsvColumn(diffConfiguration), - new DiffObsoletionCsvColumn(diffConfiguration), - new DiffInOldCsvColumn(diffConfiguration), - new DiffInNewCsvColumn(diffConfiguration), - new DiffDifferenceCsvColumn(diffConfiguration), - new DiffOldAssemblyCsvColumn(diffConfiguration), - new DiffNewAssemblyCsvColumn(diffConfiguration), - new DiffNamespaceCsvColumn(diffConfiguration), - new DiffTypeCsvColumn(diffConfiguration), - new DiffMemberCsvColumn(diffConfiguration), - new DiffVisibilityCsvColumn(diffConfiguration), - new DiffTypeIdCsvColumn(diffConfiguration), - new DiffTypeIsExposedCsvColumn(diffConfiguration), - new DiffReturnTypeCsvColumn(diffConfiguration), - new DiffTokensCsvColumn(diffConfiguration) - }); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffDifferenceCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffDifferenceCsvColumn.cs deleted file mode 100644 index 56783ee99bc..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffDifferenceCsvColumn.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Microsoft.Cci.Differs; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffDifferenceCsvColumn : DiffCsvColumn - { - public DiffDifferenceCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override bool IsVisible - { - get { return DiffConfiguration.IsDiff; } - } - - public override string Name - { - get { return "Difference"; } - } - - private static string Difference(DifferenceType differenceType) - { - switch (differenceType) - { - case DifferenceType.Unchanged: - return "Unchanged"; - case DifferenceType.Added: - return "Added"; - case DifferenceType.Removed: - return "Removed"; - case DifferenceType.Changed: - return "Changed"; - default: - throw new ArgumentOutOfRangeException("differenceType"); - } - } - - public override string GetValue(NamespaceMapping mapping) - { - return Difference(mapping.Difference); - } - - public override string GetValue(TypeMapping mapping) - { - return Difference(mapping.Difference); - } - - public override string GetValue(MemberMapping mapping) - { - return Difference(mapping.Difference); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffIdCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffIdCsvColumn.cs deleted file mode 100644 index 6f2174946fa..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffIdCsvColumn.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffIdCsvColumn : DiffCsvColumn - { - public DiffIdCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "ID"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - var namespaceDefinition = mapping.Representative; - return namespaceDefinition.DocId(); - } - - public override string GetValue(TypeMapping mapping) - { - var typeDefinition = mapping.Representative; - return typeDefinition.DocId(); - } - - public override string GetValue(MemberMapping mapping) - { - var typeDefinitionMember = mapping.Representative; - return typeDefinitionMember.DocId(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffInNewCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffInNewCsvColumn.cs deleted file mode 100644 index 6c54fac6a8a..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffInNewCsvColumn.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Microsoft.Cci.Differs; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffInNewCsvColumn : DiffCsvColumn - { - public DiffInNewCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override bool IsVisible - { - get { return DiffConfiguration.IsDiff; } - } - - public override string Name - { - get { return "In " + DiffConfiguration.Right.Name; } - } - - private static string InNew(DifferenceType differenceType) - { - switch (differenceType) - { - case DifferenceType.Unchanged: - case DifferenceType.Added: - case DifferenceType.Changed: - return "Yes"; - - case DifferenceType.Removed: - return "No"; - - default: - throw new ArgumentOutOfRangeException("differenceType"); - } - } - - public override string GetValue(NamespaceMapping mapping) - { - return InNew(mapping.Difference); - } - - public override string GetValue(TypeMapping mapping) - { - return InNew(mapping.Difference); - } - - public override string GetValue(MemberMapping mapping) - { - return InNew(mapping.Difference); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffInOldCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffInOldCsvColumn.cs deleted file mode 100644 index c37622daf72..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffInOldCsvColumn.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Microsoft.Cci.Differs; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffInOldCsvColumn : DiffCsvColumn - { - public DiffInOldCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override bool IsVisible - { - get { return DiffConfiguration.IsDiff; } - } - - public override string Name - { - get { return "In " + DiffConfiguration.Left.Name; } - } - - private static string InOld(DifferenceType differenceType) - { - switch (differenceType) - { - case DifferenceType.Unchanged: - case DifferenceType.Removed: - case DifferenceType.Changed: - return "Yes"; - - case DifferenceType.Added: - return "No"; - - default: - throw new ArgumentOutOfRangeException("differenceType"); - } - } - - public override string GetValue(NamespaceMapping mapping) - { - return InOld(mapping.Difference); - } - - public override string GetValue(TypeMapping mapping) - { - return InOld(mapping.Difference); - } - - public override string GetValue(MemberMapping mapping) - { - return InOld(mapping.Difference); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffKindCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffKindCsvColumn.cs deleted file mode 100644 index d4eaa55374d..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffKindCsvColumn.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffKindCsvColumn : DiffCsvColumn - { - public DiffKindCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Kind"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - return "Namespace"; - } - - public override string GetValue(TypeMapping mapping) - { - return "Type"; - } - - public override string GetValue(MemberMapping mapping) - { - return "Member"; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffMemberCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffMemberCsvColumn.cs deleted file mode 100644 index 3dfd6a167a0..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffMemberCsvColumn.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffMemberCsvColumn : DiffCsvColumn - { - public DiffMemberCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Member"; } - } - - public override string GetValue(MemberMapping mapping) - { - var typeDefinitionMember = mapping.Representative; - const NameFormattingOptions options = NameFormattingOptions.OmitContainingNamespace | - NameFormattingOptions.OmitContainingType | - NameFormattingOptions.TypeParameters | - NameFormattingOptions.Signature; - return MemberHelper.GetMemberSignature(typeDefinitionMember, options); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffNamespaceCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffNamespaceCsvColumn.cs deleted file mode 100644 index 41eec42ee03..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffNamespaceCsvColumn.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffNamespaceCsvColumn : DiffCsvColumn - { - public DiffNamespaceCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Namespace"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - var namespaceDefinition = mapping.Representative; - return namespaceDefinition == null - ? string.Empty - : namespaceDefinition.FullName(); - } - - public override string GetValue(TypeMapping mapping) - { - var typeDefinition = mapping.Representative; - var namespaceDefinition = typeDefinition.GetNamespace(); - return namespaceDefinition == null - ? string.Empty - : namespaceDefinition.FullName(); - } - - public override string GetValue(MemberMapping mapping) - { - var typeDefinitionMember = mapping.Representative; - var typeDefinition = typeDefinitionMember.ContainingTypeDefinition; - var namespaceDefinition = typeDefinition.GetNamespace(); - return namespaceDefinition == null - ? string.Empty - : namespaceDefinition.FullName(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffNewAssemblyCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffNewAssemblyCsvColumn.cs deleted file mode 100644 index b1670144e54..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffNewAssemblyCsvColumn.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffNewAssemblyCsvColumn : DiffAssemblyCsvColumn - { - public DiffNewAssemblyCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration, 1) - { - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffObsoletionCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffObsoletionCsvColumn.cs deleted file mode 100644 index 138b930d310..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffObsoletionCsvColumn.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using Microsoft.Cci; -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffObsoletionCsvColumn : DiffCsvColumn - { - public DiffObsoletionCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Obsoleted"; } - } - - private static bool IsObsoleted(IReference reference) - { - if (reference == null) - return false; - - return (from a in reference.Attributes - where a.Type.FullName() == "System.ObsoleteAttribute" - select a).Any(); - } - - private string GetObsoletionMarker(ElementMapping mapping) - where T : class, IReference - { - if (!DiffConfiguration.IsDiff) - { - var obsoleted = IsObsoleted(mapping.Representative); - return obsoleted ? "Yes" : "No"; - } - - var oldObsoleted = IsObsoleted(mapping[0]); - var newObsoleted = IsObsoleted(mapping[1]); - if (oldObsoleted && newObsoleted) - return "Both"; - else if (!oldObsoleted && !newObsoleted) - return "None"; - else if (oldObsoleted) - return "Old"; - else - return "New"; - } - - public override string GetValue(NamespaceMapping mapping) - { - return GetObsoletionMarker(mapping); - } - - public override string GetValue(TypeMapping mapping) - { - return GetObsoletionMarker(mapping); - } - - public override string GetValue(MemberMapping mapping) - { - return GetObsoletionMarker(mapping); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffOldAssemblyCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffOldAssemblyCsvColumn.cs deleted file mode 100644 index 478b66ea079..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffOldAssemblyCsvColumn.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffOldAssemblyCsvColumn : DiffAssemblyCsvColumn - { - public DiffOldAssemblyCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration, 0) - { - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffOverrideCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffOverrideCsvColumn.cs deleted file mode 100644 index de04fa3a5de..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffOverrideCsvColumn.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Extensions.CSharp; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffOverrideCsvColumn : DiffCsvColumn - { - public DiffOverrideCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Override"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - return string.Empty; - } - - public override string GetValue(TypeMapping mapping) - { - return string.Empty; - } - - public override string GetValue(MemberMapping mapping) - { - var isOverride = mapping.Representative.IsOverride(); - return isOverride - ? "Yes" - : "No"; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffReturnTypeCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffReturnTypeCsvColumn.cs deleted file mode 100644 index d27869ff42d..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffReturnTypeCsvColumn.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffReturnTypeCsvColumn : DiffCsvColumn - { - public DiffReturnTypeCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "ReturnType"; } - } - - public override string GetValue(MemberMapping mapping) - { - var signature = mapping.Representative as ISignature; - return signature == null - ? null - : signature.Type.GetTypeName(NameFormattingOptions.DocumentationId); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffStaticCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffStaticCsvColumn.cs deleted file mode 100644 index d42c2d0fb1e..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffStaticCsvColumn.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffStaticCsvColumn : DiffCsvColumn - { - public DiffStaticCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Static"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - return string.Empty; - } - - public override string GetValue(TypeMapping mapping) - { - return mapping.Representative.IsStatic - ? "Yes" - : "No"; - } - - public override string GetValue(MemberMapping mapping) - { - return IsStatic(mapping.Representative) - ? "Yes" - : "No"; - } - - private static bool IsStatic(ITypeDefinitionMember member) - { - var f = member as IFieldDefinition; - if (f != null) - return f.IsStatic; - - var p = member as IPropertyDefinition; - if (p != null) - return p.IsStatic; - - var e = member as IEventDefinition; - if (e != null) - return e.Adder.IsStatic || e.Remover.IsStatic; - - var method = (IMethodDefinition)member; - return method.IsStatic || method.IsStaticConstructor; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffSubKindCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffSubKindCsvColumn.cs deleted file mode 100644 index 0b81a1f1fb9..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffSubKindCsvColumn.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffSubKindCsvColumn : DiffCsvColumn - { - public DiffSubKindCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Sub Kind"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - return ApiKind.Namespace.ToString(); - } - - public override string GetValue(TypeMapping mapping) - { - var typeDefinition = mapping.Representative; - return typeDefinition.GetApiKind().ToString(); - } - - public override string GetValue(MemberMapping mapping) - { - var member = mapping.Representative; - return member.GetApiKind().ToString(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTokensCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffTokensCsvColumn.cs deleted file mode 100644 index 2050d8ad351..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTokensCsvColumn.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using Microsoft.Cci; -using Microsoft.Cci.Differs; -using Microsoft.Cci.Mappings; -using Microsoft.Cci.Writers; -using Microsoft.Cci.Writers.Syntax; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffTokensCsvColumn : DiffCsvColumn - { - private readonly DiffCSharpWriter _diffWriter; - - public DiffTokensCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - var stringWriter = new StringWriter(); - var writer = new TextSyntaxWriter(stringWriter); - var mappingSettings = DiffEngine.GetMappingSettings(diffConfiguration); - _diffWriter = new DiffCSharpWriter(writer, mappingSettings); - } - - public override string Name - { - get { return "Tokens"; } - } - - private string GetTokenString(ElementMapping mapping) - where T : class, IDefinition - { - return mapping.Difference == DifferenceType.Changed - ? GetTokenDiff(mapping) - : GetTokenStringForSingleItem(mapping); - } - - private string GetTokenDiff(ElementMapping mapping) - where T : class, IDefinition - { - var diff = _diffWriter.GetTokenDiff(mapping[0], mapping[1]); - var tokenStrings = from t in diff - let prefix = GetDifferencePrefix(t.Item1) - let token = t.Item2.Token - let text = string.IsNullOrWhiteSpace(token) - ? token - : prefix + token - select text; - return string.Concat(tokenStrings); - } - - private string GetTokenStringForSingleItem(ElementMapping mapping) - where T : class, IDefinition - { - var tokens = _diffWriter.GetTokenList(mapping.Representative); - return string.Concat(tokens.Select(t => t.Token)); - } - - private static string GetDifferencePrefix(DifferenceType differenceType) - { - switch (differenceType) - { - case DifferenceType.Unknown: - case DifferenceType.Unchanged: - return string.Empty; - case DifferenceType.Added: - return "+"; - case DifferenceType.Removed: - return "-"; - // DifferenceType.Changed can never occur during a token diff. - default: - throw new ArgumentOutOfRangeException("differenceType"); - } - } - - public override string GetValue(NamespaceMapping mapping) - { - return GetTokenString(mapping); - } - - public override string GetValue(TypeMapping mapping) - { - return GetTokenString(mapping); - } - - public override string GetValue(MemberMapping mapping) - { - return GetTokenString(mapping); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeCsvColumn.cs deleted file mode 100644 index d6bc2b12c25..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeCsvColumn.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffTypeCsvColumn : DiffCsvColumn - { - public DiffTypeCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Type"; } - } - - public override string GetValue(TypeMapping mapping) - { - var typeDefinition = mapping.Representative; - return GetTypeName(typeDefinition); - } - - public override string GetValue(MemberMapping mapping) - { - var typeDefinitionMember = mapping.Representative; - var typeDefinition = typeDefinitionMember.ContainingTypeDefinition; - return GetTypeName(typeDefinition); - } - - private static string GetTypeName(ITypeDefinition typeDefinition) - { - return typeDefinition.GetTypeName(NameFormattingOptions.OmitContainingNamespace | - NameFormattingOptions.TypeParameters); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeIdCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeIdCsvColumn.cs deleted file mode 100644 index b1ab0ac07c6..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeIdCsvColumn.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffTypeIdCsvColumn : DiffCsvColumn - { - public DiffTypeIdCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "TypeId"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - return string.Empty; - } - - public override string GetValue(TypeMapping mapping) - { - var typeDefinition = mapping.Representative; - return typeDefinition.DocId(); - } - - public override string GetValue(MemberMapping mapping) - { - var typeDefinitionMember = mapping.Representative; - var typeDefinition = typeDefinitionMember.ContainingTypeDefinition; - return typeDefinition.DocId(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeIsExposedCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeIsExposedCsvColumn.cs deleted file mode 100644 index a485fe481ca..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffTypeIsExposedCsvColumn.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffTypeIsExposedCsvColumn : DiffCsvColumn - { - public DiffTypeIsExposedCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "TypeIsExposed"; } - } - - public override string GetValue(TypeMapping mapping) - { - return mapping.Representative.IsVisibleOutsideAssembly() - ? "Yes" - : "No"; - } - - public override string GetValue(MemberMapping mapping) - { - return mapping.Representative.ContainingTypeDefinition.IsVisibleOutsideAssembly() - ? "Yes" - : "No"; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffUnsafeCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffUnsafeCsvColumn.cs deleted file mode 100644 index 4af70523ace..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffUnsafeCsvColumn.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using Microsoft.Cci; -using Microsoft.Cci.Extensions.CSharp; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffUnsafeCsvColumn : DiffCsvColumn - { - public DiffUnsafeCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Unsafe"; } - } - - public bool? IsUnsafe(ITypeDefinitionMember member) - { - var field = member as IFieldDefinition; - if (field != null) - return field.Type.IsUnsafeType(); - - var method = member as IMethodDefinition; - if (method != null) - return method.IsMethodUnsafe(); - - var property = member as IPropertyDefinition; - if (property != null) - return property.Accessors.Any(a => CSharpCciExtensions.IsMethodUnsafe(a.ResolvedMethod)); - - var evnt = member as IEventDefinition; - if (evnt != null) - return evnt.Accessors.Any(a => a.ResolvedMethod.IsMethodUnsafe()); - - return null; - } - - public override string GetValue(MemberMapping mapping) - { - var isUnsafe = IsUnsafe(mapping.Representative); - return isUnsafe == null - ? null - : isUnsafe.Value - ? "Yes" - : "No"; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffVirtualityCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffVirtualityCsvColumn.cs deleted file mode 100644 index 45f573c0744..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffVirtualityCsvColumn.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Microsoft.Cci; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffVirtualityCsvColumn : DiffCsvColumn - { - public DiffVirtualityCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Virtuality"; } - } - - public override string GetValue(NamespaceMapping mapping) - { - return string.Empty; - } - - public override string GetValue(TypeMapping mapping) - { - return string.Empty; - } - - public override string GetValue(MemberMapping mapping) - { - var virtuality = GetVirtuality(mapping.Representative); - - switch (virtuality) - { - case Virtuality.None: - return string.Empty; - case Virtuality.Virtual: - return "Virtual"; - case Virtuality.Abstract: - return "Abstract"; - default: - throw new ArgumentOutOfRangeException(); - } - } - - private static Virtuality GetVirtuality(ITypeDefinitionMember member) - { - var f = member as IFieldDefinition; - if (f != null) - return Virtuality.None; - - var p = member as IPropertyDefinition; - if (p != null) - { - var getter = GetVirtuality(p.Getter); - var setter = GetVirtuality(p.Setter); - - if (getter == Virtuality.None && - setter == Virtuality.None) - return Virtuality.None; - - if (getter == Virtuality.Abstract || - setter == Virtuality.Abstract) - return Virtuality.Abstract; - - return Virtuality.Virtual; - } - - var e = member as IEventDefinition; - if (e != null) - return GetVirtuality(e.Adder); - - var method = (IMethodReference)member; - return GetVirtuality(method); - } - - private static Virtuality GetVirtuality(IMethodReference methodReference) - { - if (methodReference == null || methodReference is Dummy || methodReference.ResolvedMethod is Dummy) - return Virtuality.None; - - var methodDefinition = methodReference.ResolvedMethod; - if (methodDefinition.IsVirtual) - return Virtuality.Virtual; - - if (methodDefinition.IsAbstract) - return Virtuality.Abstract; - - return Virtuality.None; - } - - private enum Virtuality - { - None, - Virtual, - Abstract - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/DiffVisibiliyCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/DiffVisibiliyCsvColumn.cs deleted file mode 100644 index 453a8d5ac3e..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/DiffVisibiliyCsvColumn.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public sealed class DiffVisibilityCsvColumn : DiffCsvColumn - { - public DiffVisibilityCsvColumn(DiffConfiguration diffConfiguration) - : base(diffConfiguration) - { - } - - public override string Name - { - get { return "Visibility"; } - } - - public override string GetValue(TypeMapping mapping) - { - var visibility = TypeHelper.TypeVisibilityAsTypeMemberVisibility(mapping.Representative); - return visibility.ToString(); - } - - public override string GetValue(MemberMapping mapping) - { - var visibility = mapping.Representative.Visibility; - return visibility.ToString(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Csv/IDiffCsvColumn.cs b/src/Microsoft.DotNet.AsmDiff/Csv/IDiffCsvColumn.cs deleted file mode 100644 index 489bac8c4dc..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Csv/IDiffCsvColumn.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Mappings; - -namespace Microsoft.DotNet.AsmDiff.CSV -{ - public interface IDiffCsvColumn - { - bool IsVisible { get; } - string Name { get; } - string GetValue(ElementMapping mapping) where TElement : class; - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffApiDefinition.cs b/src/Microsoft.DotNet.AsmDiff/DiffApiDefinition.cs deleted file mode 100644 index 465938a630c..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffApiDefinition.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Differs; -using Microsoft.Cci.Extensions; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class DiffApiDefinition - { - public string Name { get; private set; } - public IDefinition Definition { get; private set; } - public IDefinition Left { get; private set; } - public IDefinition Right { get; private set; } - public int StartLine { get; internal set; } - public int EndLine { get; internal set; } - public DifferenceType Difference { get; private set; } - public ReadOnlyCollection Children { get; private set; } - - public DiffApiDefinition(IDefinition left, IDefinition right, DifferenceType difference, IList children) - { - IDefinition representative = left ?? right; - Name = GetName(representative); - Definition = representative; - Left = left; - Right = right; - Difference = difference; - Children = new ReadOnlyCollection(children); - } - - public override string ToString() - { - return Difference.ToString().Substring(0, 1) + " " + Definition.UniqueId(); - } - - private static string GetName(object obj) - { - var assembly = obj as IAssembly; - if (assembly != null) - return GetName(assembly); - - var namespaceDefinition = obj as INamespaceDefinition; - if (namespaceDefinition != null) - return GetName(namespaceDefinition); - - var typeMemberReference = obj as ITypeMemberReference; - if (typeMemberReference != null) - return GetName(typeMemberReference); - - var typeReference = obj as ITypeReference; - if (typeReference != null) - return GetName(typeReference); - - throw new NotImplementedException("Unknown CCI object type: " + obj.GetType()); - } - - private static string GetName(IAssembly assembly) - { - return assembly.Name.Value; - } - - private static string GetName(INamespaceDefinition namespaceName) - { - var name = namespaceName.ToString(); - return string.IsNullOrEmpty(name) - ? "-" - : name; - } - - private static string GetName(ITypeReference typeReference) - { - return TypeHelper.GetTypeName(typeReference, NameFormattingOptions.TypeParameters | - NameFormattingOptions.OmitContainingNamespace); - } - - private static string GetName(ITypeMemberReference typeMemberReference) - { - string memberSignature = MemberHelper.GetMemberSignature(typeMemberReference, NameFormattingOptions.Signature | - NameFormattingOptions.OmitContainingType | - NameFormattingOptions.OmitContainingNamespace | - NameFormattingOptions.PreserveSpecialNames); - - string returnTypeName = GetReturnTypeName(typeMemberReference); - return returnTypeName == null - ? memberSignature - : memberSignature + " : " + returnTypeName; - } - - private static string GetReturnTypeName(ITypeMemberReference typeMemberReference) - { - ITypeDefinitionMember typeDefinitionMember = typeMemberReference.ResolvedTypeDefinitionMember; - var fieldDefinition = typeDefinitionMember as IFieldDefinition; - if (fieldDefinition != null) - return GetName(fieldDefinition.Type); - - var propertyDefinition = typeDefinitionMember as IPropertyDefinition; - if (propertyDefinition != null) - return GetName(propertyDefinition.Type); - - var methodDefinition = typeDefinitionMember as IMethodDefinition; - if (methodDefinition != null && !methodDefinition.IsConstructor && !methodDefinition.IsStaticConstructor) - return GetName(methodDefinition.Type); - - return null; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffCSharpWriter.cs b/src/Microsoft.DotNet.AsmDiff/DiffCSharpWriter.cs deleted file mode 100644 index d9dc5bbeb30..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffCSharpWriter.cs +++ /dev/null @@ -1,492 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Composition.Hosting; -using System.Composition.Hosting.Core; -using System.Diagnostics.Contracts; -using System.IO; -using System.Linq; -using Microsoft.Cci; -using Microsoft.Cci.Comparers; -using Microsoft.Cci.Differs; -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Extensions.CSharp; -using Microsoft.Cci.Mappings; -using Microsoft.Cci.Traversers; -using Microsoft.Cci.Writers; -using Microsoft.Cci.Writers.CSharp; -using Microsoft.Cci.Writers.Syntax; -using Assembly = System.Reflection.Assembly; - -namespace Microsoft.DotNet.AsmDiff -{ - public class DiffCSharpWriter : MappingsTypeMemberTraverser, IDiffingService, ICciDifferenceWriter - { - private readonly IStyleSyntaxWriter _syntaxWriter; - private readonly MappingSettings _settings; - private readonly ICciDeclarationWriter _formatter; - private readonly CSDeclarationHelper _declHelper; - private bool _firstMemberGroup = false; - private readonly IEnumerable _diffComments; - - public DiffCSharpWriter(IStyleSyntaxWriter writer, MappingSettings settings, IEnumerable diffComments) - : this(writer, settings, diffComments, includePseudoCustomAttributes:false) - { - } - - public DiffCSharpWriter(IStyleSyntaxWriter writer, MappingSettings settings, IEnumerable diffComments, bool includePseudoCustomAttributes) - : base (settings) - { - _syntaxWriter = writer; - _settings = InitializeSettings(settings); - _formatter = new CSDeclarationWriter(_syntaxWriter, _settings.Filter, forCompilation: false, includePseudoCustomAttributes: includePseudoCustomAttributes) - { - LangVersion = CSDeclarationWriter.LangVersionPreview - }; - _declHelper = new CSDeclarationHelper(_settings.Filter, forCompilation: false, includePseudoCustomAttributes: includePseudoCustomAttributes); - _diffComments = diffComments ?? Enumerable.Empty(); - } - - public DiffCSharpWriter(IStyleSyntaxWriter writer, MappingSettings settings) - : this(writer, settings, null, false) - { - } - - public bool IncludeSpaceBetweenMemberGroups { get; set; } - - public bool IncludeMemberGroupHeadings { get; set; } - - public bool HighlightBaseMembers { get; set; } - - public bool IncludeAssemblyProperties { get; set; } - - public void Write(string oldAssembliesName, IEnumerable oldAssemblies, string newAssembliesName, IEnumerable newAssemblies) - { - AssemblySetMapping mapping; - - if (!string.IsNullOrEmpty(newAssembliesName)) - { - _settings.ElementCount = 2; - mapping = new AssemblySetMapping(_settings); - mapping.AddMappings(oldAssemblies, newAssemblies); - } - else - { - _settings.ElementCount = 1; - mapping = new AssemblySetMapping(_settings); - mapping.AddMapping(0, oldAssemblies); - } - - if (oldAssembliesName != null) - { - using (_syntaxWriter.StartStyle(SyntaxStyle.Removed)) - _syntaxWriter.Write("{0}", oldAssembliesName); - _syntaxWriter.WriteLine(); - } - - if (newAssembliesName != null) - { - using (_syntaxWriter.StartStyle(SyntaxStyle.Added)) - _syntaxWriter.Write("{0}", newAssembliesName); - _syntaxWriter.WriteLine(); - } - - Visit(mapping); - } - - public override void Visit(AssemblySetMapping assemblySet) - { - if (this.IncludeAssemblyProperties && assemblySet.ElementCount > 1) - { - foreach (var assembly in assemblySet.Assemblies) - { - var attributes = assembly.Attributes.Where(e => DiffFilter.Include(e.Difference)); - var properties = assembly.Properties.Where(e => DiffFilter.Include(e.Difference)); - - if (!attributes.Any() && !properties.Any()) - continue; - - _syntaxWriter.WriteKeyword("assembly"); - _syntaxWriter.WriteSpace(); - _syntaxWriter.WriteIdentifier(assembly.Representative.Name.Value); - using (_syntaxWriter.StartBraceBlock()) - { - Visit(properties); - Visit(attributes); - } - } - } - base.Visit(assemblySet); - } - - public override void Visit(AssemblyMapping assembly) - { - Contract.Assert(this.Settings.GroupByAssembly); - - _syntaxWriter.WriteKeyword("assembly"); - _syntaxWriter.WriteSpace(); - _syntaxWriter.WriteIdentifier(assembly.Representative.Name.Value); - using (_syntaxWriter.StartBraceBlock()) - { - if (this.IncludeAssemblyProperties) - { - var attributes = assembly.Attributes.Where(e => DiffFilter.Include(e.Difference)); - var properties = assembly.Properties.Where(e => DiffFilter.Include(e.Difference)); - - Visit(properties); - Visit(attributes); - } - base.Visit(assembly); - } - } - - public override void Visit(NamespaceMapping mapping) - { - WriteHeader(mapping); - using (_syntaxWriter.StartBraceBlock()) - { - WriteComments(mapping); - base.Visit(mapping); - } - - _syntaxWriter.WriteLine(); - } - - public override void Visit(IEnumerable types) - { - TypeMapping mapping = types.FirstOrDefault(DiffFilter.Include); - - // Need to handle the nested types like members - if (mapping != null) - WriteMemberGroupHeader(mapping.Representative as ITypeDefinitionMember); - - base.Visit(types); - } - - public override void Visit(TypeMapping mapping) - { - WriteHeader(mapping); - - if (mapping.ShouldDiffMembers && !mapping.Representative.IsDelegate) - { - using (_syntaxWriter.StartBraceBlock()) - { - WriteComments(mapping); - _firstMemberGroup = true; - base.Visit(mapping); - } - } - _syntaxWriter.WriteLine(); - } - - public override void Visit(IEnumerable members) - { - MemberMapping mapping = members.FirstOrDefault(m => DiffFilter.Include(m) && !IsPropertyOrEventAccessor(m.Representative)); - - if (mapping != null) - WriteMemberGroupHeader(mapping.Representative); - - base.Visit(members); - } - - public override void Visit(MemberMapping member) - { - if (!IsPropertyOrEventAccessor(member.Representative)) - { - IDisposable style = null; - - if (this.HighlightBaseMembers) - { - if (member.Representative.IsInterfaceImplementation()) - style = _syntaxWriter.StartStyle(SyntaxStyle.InterfaceMember); - else if (member.Representative.IsOverride()) - style = _syntaxWriter.StartStyle(SyntaxStyle.InheritedMember); - } - - WriteHeader(member); - style?.Dispose(); - - _syntaxWriter.WriteLine(); - WriteComments(member); - } - - base.Visit(member); - } - - private static bool IsPropertyOrEventAccessor(ITypeDefinitionMember representative) - { - return (representative is IMethodDefinition methodDefinition) && methodDefinition.IsPropertyOrEventAccessor(); - } - - private void WriteHeader(ElementMapping element) where T : class, IDefinition - { - WriteElement(element, - e => _formatter.WriteDeclaration(e), - (e1, e2) => WriteMergedDefinitions(e1, e2)); - } - - private void WriteComments(ElementMapping mapping) where TElement : class - { - var docId = GetDocId(mapping); - var commentSet = _diffComments.Where((c) => c.DocId == docId).Reverse().ToArray(); - var reviewCommentWriter = _syntaxWriter as IReviewCommentWriter; - if (commentSet.Any() && reviewCommentWriter != null) - { - foreach (var comment in commentSet) - { - reviewCommentWriter.WriteReviewComment(comment.Author, comment.Text); - _syntaxWriter.WriteLine(); - } - } - } - - public string GetDocId(ElementMapping mapping) where TElement : class - { - var namespaceMapping = mapping as NamespaceMapping; - if (namespaceMapping != null) - return namespaceMapping.Representative.DocId(); - - var typeMapping = mapping as TypeMapping; - if (typeMapping != null) - return typeMapping.Representative.DocId(); - - var memberMapping = mapping as MemberMapping; - if (memberMapping != null) - return memberMapping.Representative.DocId(); - - var assemblyMapping = mapping as AssemblyMapping; - if (assemblyMapping != null) - return assemblyMapping.Representative.DocId(); - - return string.Empty; - } - - private void WriteElement(ElementMapping element, Action write, System.Action writeMerged, bool writeNewLine = false) where T : class - { - switch (element.Difference) - { - case DifferenceType.Unchanged: - write(element.Representative); - break; - - case DifferenceType.Added: - Contract.Assert(element[1] != null); - using (_syntaxWriter.StartStyle(SyntaxStyle.Added)) - write(element[1]); - break; - - case DifferenceType.Removed: - Contract.Assert(element[0] != null); - using (_syntaxWriter.StartStyle(SyntaxStyle.Removed)) - write(element[0]); - break; - - case DifferenceType.Changed: - - IDisposable style = null; - if (!element.Differences.ContainsIncompatibleDifferences()) - style = _syntaxWriter.StartStyle(SyntaxStyle.NotCompatible, element.Differences.OfType()); - - writeMerged(element[0], element[1]); - - if (style != null) - style.Dispose(); - break; - } - - if (writeNewLine) - { - _syntaxWriter.WriteLine(); - WriteComments(element); - _syntaxWriter.WriteLine(); - } - } - - private void WriteMergedDefinitions(IDefinition def1, IDefinition def2) - { - var merged = GetTokenDiff(def1, def2); - - IDisposable style = null; - DifferenceType context = DifferenceType.Unchanged; - foreach (var mt in merged) - { - if (context != mt.Item1 && style != null) - { - style.Dispose(); - style = null; - } - switch (mt.Item1) - { - default: - case DifferenceType.Unchanged: - _syntaxWriter.WriteSyntaxToken(mt.Item2); - break; - case DifferenceType.Removed: - if (context != DifferenceType.Removed) - style = _syntaxWriter.StartStyle(SyntaxStyle.Removed); - _syntaxWriter.WriteSyntaxToken(mt.Item2); - break; - case DifferenceType.Added: - if (context != DifferenceType.Added) - style = _syntaxWriter.StartStyle(SyntaxStyle.Added); - _syntaxWriter.WriteSyntaxToken(mt.Item2); - break; - } - context = mt.Item1; - } - if (style != null) - style.Dispose(); - } - - public IEnumerable> GetTokenDiff(IDefinition def1, IDefinition def2) - { - SyntaxToken[] t1 = GetTokenList(def1).ToArray(); - SyntaxToken[] t2 = GetTokenList(def2).ToArray(); - - int t1Start = 0; - int t2Start = 0; - - List> merged = new List>(); - - //TODO: Consider splitting by lines as well to help with the attribute diffing - - // Split the token list at identifiers to help with the merge line up so that we don't get large - // diffing churn in the output. - while (t1Start < t1.Length && t2Start < t2.Length) - { - int t1End = Array.FindIndex(t1, t1Start, s => s.Type == SyntaxTokenType.Identifier); - int t2End = Array.FindIndex(t2, t2Start, s => s.Type == SyntaxTokenType.Identifier); - - if (t1End < 0 || t2End < 0) - break; - - merged.AddRange(ListMerger.Merge(t1, t1Start, t1End + 1, t2, t2Start, t2End + 1)); - - t1Start = t1End + 1; - t2Start = t2End + 1; - } - - // Finish any leftover work from either side. - merged.AddRange(ListMerger.Merge(t1, t1Start, t1.Length, t2, t2Start, t2.Length)); - return merged; - } - - private MappingSettings InitializeSettings(MappingSettings settings) - { - Assembly entryAssembly = Assembly.GetEntryAssembly(); - string appDirectory = Path.GetDirectoryName(entryAssembly.Location); - var assemblies = Directory.EnumerateFiles(appDirectory, "*.dll") - .Select(Assembly.LoadFrom); - - var configuration = new ContainerConfiguration() - .WithAssembly(entryAssembly) - .WithAssemblies(assemblies) - .WithExport(this) - .WithExport>(settings.TypeComparer); - - var compositionHost = configuration.CreateContainer(); - - settings.DiffFactory = new ElementDifferenceFactory(compositionHost); - return settings; - } - - public IEnumerable GetTokenList(IDefinition definition) - { - return _declHelper.GetTokenList(definition); - } - - private void WriteMemberGroupHeader(ITypeDefinitionMember member) - { - if (member == null) - return; - - if (IncludeMemberGroupHeadings || IncludeSpaceBetweenMemberGroups) - { - string heading = CSharpWriter.MemberGroupHeading(member); - - if (heading != null) - { - if (IncludeSpaceBetweenMemberGroups) - { - if (!_firstMemberGroup) - _syntaxWriter.WriteLine(true); - _firstMemberGroup = false; - } - - if (IncludeMemberGroupHeadings) - { - _syntaxWriter.Write("// {0}", heading); - _syntaxWriter.WriteLine(); - } - } - } - } - - // Consider moving these visitors to the base traverser if they end up being needed by others. - private void Visit(IEnumerable> attributes) - { - foreach (var attribute in attributes) - Visit(attribute); - } - - private void Visit(ElementMapping attribute) - { - WriteElement(attribute, - ag => - { - foreach (var attr in ag.Attributes) - _formatter.WriteAttribute(attr); - }, - (ag1, ag2) => - { - // TODO: Need to insert the newlines and indentions, perhaps support GetTokenList(IEnumerable) - var attributeComparer = new AttributeComparer(); - var ag1Tokens = ag1.Attributes.OrderBy(c => c, attributeComparer) - .SelectMany(c => _declHelper.GetTokenList(c)); - var ag2Tokens = ag2.Attributes.OrderBy(c => c, attributeComparer) - .SelectMany(c => _declHelper.GetTokenList(c)); - - foreach (var token in ListMerger.MergeLists(ag1Tokens, ag2Tokens)) - { - WriteElement(token, t => - { - _syntaxWriter.WriteSyntaxToken(t); - }, - (t1, t2) => - { - using (_syntaxWriter.StartStyle(SyntaxStyle.Removed)) - _syntaxWriter.WriteSyntaxToken(t1); - using (_syntaxWriter.StartStyle(SyntaxStyle.Added)) - _syntaxWriter.WriteSyntaxToken(t2); - }, false); - } - }, true); - } - - private void Visit(IEnumerable> properties) - { - foreach (var property in properties) - Visit(property); - } - - private void Visit(ElementMapping property) - { - WriteElement(property, - (p) => - { - _syntaxWriter.Write(string.Format("{0}{1}{2}", p.Name, p.Delimiter, p.Value)); - }, - (p1, p2) => - { - Contract.Assert(p1.Key == p2.Key); - _syntaxWriter.Write(string.Format("{0}{1}", p1.Name, p1.Delimiter)); - using (_syntaxWriter.StartStyle(SyntaxStyle.Removed)) - _syntaxWriter.Write(p1.Value); - using (_syntaxWriter.StartStyle(SyntaxStyle.Added)) - _syntaxWriter.Write(p2.Value); - }, true); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffCciFilter.cs b/src/Microsoft.DotNet.AsmDiff/DiffCciFilter.cs deleted file mode 100644 index cb73989e381..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffCciFilter.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using Microsoft.Cci; -using Microsoft.Cci.Extensions; -using Microsoft.Cci.Filters; - -namespace Microsoft.DotNet.AsmDiff -{ - internal sealed class DiffCciFilter : ICciFilter - { - public DiffCciFilter(bool includeAttributes = false, bool includeInternals = false, bool includePrivates = false, bool includeGenerated = false) - { - IncludeAttributes = includeAttributes; - IncludeInternals = includeInternals; - IncludePrivates = includePrivates; - IncludeGenerated = includeGenerated; - } - - public bool Include(ICustomAttribute attribute) - { - // If we can't resolve an attribute, we err on the side of including it. - // This makes sure we don't accidentally hide all the attributes just - // because we can't resolve the core assembly. - if (!IncludeAttributes) - return false; - - if (attribute.Type == null) - return true; - - var resolvedType = attribute.Type.ResolvedType; - return resolvedType is Dummy || Include(resolvedType); - } - - public bool Include(INamespaceDefinition ns) - { - return ns.GetTypes(IncludeForwardedTypes).Any(Include); - } - - public bool Include(ITypeDefinition type) - { - if (type == null || type is Dummy) - return false; - - if (!IncludeGenerated && IsCompilerGenerated(type)) - return false; - - switch (type.GetVisibility()) - { - case TypeMemberVisibility.Private: - return IncludePrivates; - - case TypeMemberVisibility.Assembly: - case TypeMemberVisibility.FamilyAndAssembly: - return IncludeInternals; - - case TypeMemberVisibility.Family: - case TypeMemberVisibility.FamilyOrAssembly: - return true; - - case TypeMemberVisibility.Public: - return true; - } - - return type.IsVisibleOutsideAssembly(); - } - - public bool Include(ITypeDefinitionMember member) - { - if (member == null || member is Dummy) - return false; - - if (!Include(member.ContainingTypeDefinition)) - return false; - - if (!IncludeGenerated && IsCompilerGenerated(member)) - { - // If it's an accessor, we want to fall-through. - - var propertyAccessors = from p in member.ContainingTypeDefinition.Properties - from a in p.Accessors - select a; - - var eventAccessors = from e in member.ContainingTypeDefinition.Events - from a in e.Accessors - select a; - - var accessors = propertyAccessors.Concat(eventAccessors); - - var isAccessor = (from a in accessors - where a.ResolvedMethod == member - select a).Any(); - - if (!isAccessor) - return false; - } - - switch (member.Visibility) - { - case TypeMemberVisibility.Private: - return IncludePrivates || MemberHelper.IsVisibleOutsideAssembly(member);; - - case TypeMemberVisibility.Assembly: - case TypeMemberVisibility.FamilyAndAssembly: - return IncludeInternals; - - case TypeMemberVisibility.Family: - case TypeMemberVisibility.FamilyOrAssembly: - return true; - - case TypeMemberVisibility.Public: - return true; - } - - return member.IsVisibleOutsideAssembly(); - } - - private static bool IsCompilerGenerated(ITypeDefinition typeDefinition) - { - var generatedAttribute = typeDefinition.PlatformType.SystemRuntimeCompilerServicesCompilerGeneratedAttribute; - return typeDefinition.Attributes.Where(a => TypeHelper.TypesAreEquivalent(a.Type, generatedAttribute)).Any(); - } - - private static bool IsCompilerGenerated(ITypeDefinitionMember typeDefinitionMember) - { - var generatedAttribute = typeDefinitionMember.ContainingTypeDefinition.PlatformType.SystemRuntimeCompilerServicesCompilerGeneratedAttribute; - return typeDefinitionMember.Attributes.Where(a => TypeHelper.TypesAreEquivalent(a.Type, generatedAttribute)).Any(); - } - - public bool IncludeAttributes { get; set; } - - public bool IncludeInternals { get; set; } - - public bool IncludePrivates { get; set; } - - public bool IncludeGenerated { get; set; } - - public bool IncludeForwardedTypes { get; set; } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffComment.cs b/src/Microsoft.DotNet.AsmDiff/DiffComment.cs deleted file mode 100644 index 27aab87301d..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffComment.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class DiffComment - { - public DiffComment(string docId, string author, string text) - { - DocId = docId; - Author = author; - Text = text; - } - - public string DocId { get; private set; } - public string Author { get; private set; } - public string Text { get; private set; } - - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffConfiguration.cs b/src/Microsoft.DotNet.AsmDiff/DiffConfiguration.cs deleted file mode 100644 index aa2999889e1..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffConfiguration.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class DiffConfiguration - { - public DiffConfiguration() - { - Left = AssemblySet.Empty; - Right = AssemblySet.Empty; - Options = DiffConfigurationOptions.IncludeAdded | - DiffConfigurationOptions.IncludeRemoved | - DiffConfigurationOptions.IncludeChanged | - DiffConfigurationOptions.IncludeUnchanged | - DiffConfigurationOptions.IncludeAddedTypes | - DiffConfigurationOptions.IncludeRemovedTypes | - DiffConfigurationOptions.HighlightBaseMembers; - } - - public DiffConfiguration(AssemblySet left, AssemblySet right, DiffConfigurationOptions options) - { - Left = left; - Right = right; - Options = options; - } - - public AssemblySet Left { get; private set; } - - public AssemblySet Right { get; private set; } - - public bool IsDiff - { - get - { - var hasLeft = Left != null && !Left.IsEmpty; - var hasRight = Right != null && !Right.IsEmpty; - if (!hasLeft && !hasRight) - return false; - - return !hasLeft || hasRight; - } - } - - public DiffConfigurationOptions Options { get; private set; } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffConfigurationExtensions.cs b/src/Microsoft.DotNet.AsmDiff/DiffConfigurationExtensions.cs deleted file mode 100644 index dc5fe37a490..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffConfigurationExtensions.cs +++ /dev/null @@ -1,153 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Linq; -using Microsoft.Cci; - -namespace Microsoft.DotNet.AsmDiff -{ - public static class DiffConfigurationExtensions - { - // Options - - public static DiffConfiguration UpdateOptions(this DiffConfiguration configuration, DiffConfigurationOptions options) - { - var left = configuration.Left; - var right = configuration.Right; - return new DiffConfiguration(left, right, options); - } - - public static bool IsOptionSet(this DiffConfiguration configuration, DiffConfigurationOptions option) - { - return option == DiffConfigurationOptions.None - ? configuration.Options == DiffConfigurationOptions.None - : (configuration.Options & option) == option; - } - - public static DiffConfiguration SetOption(this DiffConfiguration configuration, DiffConfigurationOptions option, bool set) - { - var newOptions = set - ? configuration.Options | option - : configuration.Options & ~option; - return configuration.UpdateOptions(newOptions); - } - - // Add assemblies - - public static DiffConfiguration AddLeftAssemblies(this DiffConfiguration configuration, IEnumerable addedPaths) - { - return configuration.AddAssemblies(true, addedPaths); - } - - public static DiffConfiguration AddRightAssemblies(this DiffConfiguration configuration, IEnumerable addedPaths) - { - return configuration.AddAssemblies(false, addedPaths); - } - - private static DiffConfiguration AddAssemblies(this DiffConfiguration configuration, bool isLeft, IEnumerable addedPaths) - { - var existingSet = isLeft - ? configuration.Left - : configuration.Right; - var existingAssemblyPaths = from a in existingSet.Assemblies - select a.Location; - - var totalAssemblyPaths = existingAssemblyPaths.Concat(addedPaths).ToArray(); - var newName = existingSet.IsEmpty ? null : existingSet.Name; - - return configuration.UpdateAssemblies(isLeft, totalAssemblyPaths, newName); - } - - // Remove assemblies - - public static DiffConfiguration RemoveLeftAssemblies(this DiffConfiguration configuration, IEnumerable removals) - { - return configuration.RemoveAssemblies(true, removals); - } - - public static DiffConfiguration RemoveRightAssemblies(this DiffConfiguration configuration, IEnumerable removals) - { - return configuration.RemoveAssemblies(false, removals); - } - - private static DiffConfiguration RemoveAssemblies(this DiffConfiguration configuration, bool isLeft, IEnumerable removals) - { - var existingSet = isLeft - ? configuration.Left - : configuration.Right; - var newSet = existingSet.Remove(removals); - return configuration.UpdateAssemblies(isLeft, newSet); - } - - // Update assemblies - - public static DiffConfiguration UpdateLeftAssemblies(this DiffConfiguration configuration, IEnumerable paths) - { - return configuration.UpdateLeftAssemblies(paths, null); - } - - public static DiffConfiguration UpdateLeftAssemblies(this DiffConfiguration configuration, IEnumerable paths, string name) - { - return configuration.UpdateAssemblies(true, paths, name); - } - - public static DiffConfiguration UpdateLeftAssemblies(this DiffConfiguration configuration, AssemblySet assemblySet) - { - return configuration.UpdateAssemblies(true, assemblySet); - } - - public static DiffConfiguration UpdateRightAssemblies(this DiffConfiguration configuration, IEnumerable paths) - { - return configuration.UpdateRightAssemblies(paths, null); - } - - public static DiffConfiguration UpdateRightAssemblies(this DiffConfiguration configuration, IEnumerable paths, string name) - { - return configuration.UpdateAssemblies(false, paths, name); - } - - public static DiffConfiguration UpdateRightAssemblies(this DiffConfiguration configuration, AssemblySet assemblySet) - { - return configuration.UpdateAssemblies(false, assemblySet); - } - - private static DiffConfiguration UpdateAssemblies(this DiffConfiguration configuration, bool isLeft, IEnumerable newPaths, string newName) - { - var assemblySet = AssemblySet.FromPaths(newPaths, newName); - return configuration.UpdateAssemblies(isLeft, assemblySet); - } - - private static DiffConfiguration UpdateAssemblies(this DiffConfiguration configuration, bool isLeft, AssemblySet assemblySet) - { - var isRight = !isLeft; - var existingSet = isLeft - ? configuration.Left - : configuration.Right; - - // This is the a debatible thing here. - // - // Without Dipose(), instances of DiffConfiguration would be fully immutable, which means - // we could pass it around to different threads and you could be sure that no than is stepping - // on your toes. - // - // However, this also means we would only unlock the files on disk when the GC collects the - // the underlying metadata reader host. This means, nobody can open the files exlusively or - // deleting them until they are collected. - // - // A workaround for the user is to simply close the app but I feel the workaround feels really - // bad. Especially because most of the assemblies being added to the tool will come from temp - // folders on the desktop. - // - // Since our apps is blocking adding/removing files when an analysis is running, there are - // no real advantages of full immutable sharing. - - existingSet.Dispose(); - - var newLeft = isLeft ? assemblySet : configuration.Left; - var newRight = isRight ? assemblySet : configuration.Right; - - return new DiffConfiguration(newLeft, newRight, configuration.Options); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffConfigurationOptions.cs b/src/Microsoft.DotNet.AsmDiff/DiffConfigurationOptions.cs deleted file mode 100644 index 3a3d5588e9a..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffConfigurationOptions.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.DotNet.AsmDiff -{ - [Flags] - public enum DiffConfigurationOptions - { - None = 0x0, - IncludeUnchanged = 0x2, - IncludeAdded = 0x4, - IncludeRemoved = 0x8, - IncludeChanged = 0x10, - IncludeInternals = 0x20, - IncludePrivates = 0x40, - IncludeGenerated = 0x80, - DiffAttributes = 0x100, - DiffAssemblyInfo = 0x200, - GroupByAssembly = 0x400, - FlattenTypes = 0x800, - TypesOnly = 0x1000, - HighlightBaseMembers = 0x2000, - AlwaysDiffMembers = 0x4000, - IncludeAddedTypes = 0x8000, - IncludeRemovedTypes = 0x10000, - StrikeRemoved = 0x20000 - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffCsvWriter.cs b/src/Microsoft.DotNet.AsmDiff/DiffCsvWriter.cs deleted file mode 100644 index c1a37fde2b3..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffCsvWriter.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Threading; -using Microsoft.Cci; -using Microsoft.Cci.Mappings; -using Microsoft.Cci.Traversers; -using Microsoft.Cci.Writers; -using Microsoft.DotNet.AsmDiff.CSV; - -namespace Microsoft.DotNet.AsmDiff -{ - internal sealed class DiffCsvWriter : MappingsTypeMemberTraverser, ICciDifferenceWriter - { - private CsvWriter _writer; - private IEnumerable _columns; - private CancellationToken _cancellationToken; - - public DiffCsvWriter(CsvWriter writer, MappingSettings settings, IEnumerable columns, CancellationToken cancellationToken) - : base(settings) - { - _writer = writer; - _columns = columns; - _cancellationToken = cancellationToken; - } - - public void Write(string oldAssembliesName, IEnumerable oldAssemblies, string newAssembliesName, IEnumerable newAssemblies) - { - AssemblySetMapping mapping; - if (!string.IsNullOrEmpty(newAssembliesName)) - { - Settings.ElementCount = 2; - mapping = new AssemblySetMapping(Settings); - mapping.AddMappings(oldAssemblies, newAssemblies); - } - else - { - Settings.ElementCount = 1; - mapping = new AssemblySetMapping(Settings); - mapping.AddMapping(0, oldAssemblies); - } - - Visit(mapping); - } - - private void WriteRow(ElementMapping mapping) where TElement : class - { - foreach (var mappingCsvColumn in _columns) - { - var value = mappingCsvColumn.GetValue(mapping); - _writer.Write(value); - } - - _writer.WriteLine(); - } - - public override void Visit(NamespaceMapping mapping) - { - if (_cancellationToken.IsCancellationRequested) - return; - - if (DiffFilter.Include(mapping.Difference)) - WriteRow(mapping); - - base.Visit(mapping); - } - - public override void Visit(TypeMapping mapping) - { - if (_cancellationToken.IsCancellationRequested) - return; - - if (DiffFilter.Include(mapping.Difference)) - WriteRow(mapping); - - if (mapping.ShouldDiffMembers) - base.Visit(mapping); - } - - public override void Visit(MemberMapping mapping) - { - if (_cancellationToken.IsCancellationRequested) - return; - - if (DiffFilter.Include(mapping.Difference)) - WriteRow(mapping); - - base.Visit(mapping); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffDocument.cs b/src/Microsoft.DotNet.AsmDiff/DiffDocument.cs deleted file mode 100644 index 3f17203cc84..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffDocument.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class DiffDocument - { - public AssemblySet Left { get; private set; } - public AssemblySet Right { get; private set; } - public ReadOnlyCollection Lines { get; private set; } - public ReadOnlyCollection ApiDefinitions { get; private set; } - - public DiffDocument(AssemblySet left, AssemblySet right, IEnumerable lines, IEnumerable apiDefinitions) - { - Left = left; - Right = right; - Lines = new ReadOnlyCollection(lines.ToArray()); - ApiDefinitions = new ReadOnlyCollection(apiDefinitions.ToArray()); - } - - public bool IsDiff - { - get - { - var hasLeft = Left != null && !Left.IsEmpty; - var hasRight = Right != null && !Right.IsEmpty; - if (!hasLeft && !hasRight) - return false; - - return !hasLeft || hasRight; - } - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffEngine.cs b/src/Microsoft.DotNet.AsmDiff/DiffEngine.cs deleted file mode 100644 index 7287760e832..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffEngine.cs +++ /dev/null @@ -1,287 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Differs; -using Microsoft.Cci.Filters; -using Microsoft.Cci.Mappings; -using Microsoft.Cci.Writers; -using Microsoft.Cci.Writers.Syntax; -using Microsoft.DotNet.AsmDiff.CSV; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; - -namespace Microsoft.DotNet.AsmDiff -{ - public static class DiffEngine - { - public static void Export(DiffConfiguration configuration, IEnumerable diffComments, DiffFormat format, TextWriter streamWriter) - { - var strikeOutRemoved = configuration.IsOptionSet(DiffConfigurationOptions.StrikeRemoved); - using (var syntaxWriter = GetExportWriter(format, streamWriter, strikeOutRemoved)) - { - var writer = CreateExportWriter(format, streamWriter, configuration, syntaxWriter, diffComments); - WriteDiff(configuration, writer); - } - } - - private static void WriteDiff(DiffConfiguration configuration, ICciDifferenceWriter writer) - { - var oldSet = configuration.Left; - var oldAssemblies = oldSet.Assemblies; - var oldAssembliesName = oldSet.Name; - - // The diff writer special cases the name being null - // to indicated that there is only one "set". - var newSet = configuration.Right; - var newAssembliesName = newSet.IsNull - ? null - : newSet.Name; - var newAssemblies = newSet.Assemblies; - - writer.Write(oldAssembliesName, oldAssemblies, newAssembliesName, newAssemblies); - } - - private static ICciDifferenceWriter CreateExportWriter(DiffFormat format, TextWriter textWriter, DiffConfiguration configuration, IStyleSyntaxWriter writer, IEnumerable diffComments) - { - var mappingSettings = GetMappingSettings(configuration); - var includeAttributes = configuration.IsOptionSet(DiffConfigurationOptions.DiffAttributes); - - switch (format) - { - case DiffFormat.Csv: - var diffColumns = DiffCsvColumn.CreateStandardColumns(configuration).Where(c => c.IsVisible).ToArray(); - var csvTextWriter = new CsvTextWriter(textWriter); - csvTextWriter.WriteLine(diffColumns.Select(c => c.Name)); - return new DiffCsvWriter(csvTextWriter, mappingSettings, diffColumns, CancellationToken.None); - case DiffFormat.Html: - return new DiffCSharpWriter(writer, mappingSettings, diffComments, includeAttributes) - { - IncludeAssemblyProperties = configuration.IsOptionSet(DiffConfigurationOptions.DiffAssemblyInfo), - HighlightBaseMembers = configuration.IsOptionSet(DiffConfigurationOptions.HighlightBaseMembers) - }; - case DiffFormat.WordXml: - case DiffFormat.Text: - case DiffFormat.UnifiedDiff: - return new DiffCSharpWriter(writer, mappingSettings, diffComments, includeAttributes) - { - IncludeAssemblyProperties = configuration.IsOptionSet(DiffConfigurationOptions.DiffAssemblyInfo), - HighlightBaseMembers = configuration.IsOptionSet(DiffConfigurationOptions.HighlightBaseMembers) - }; - default: - throw new ArgumentOutOfRangeException("format"); - } - } - - private static IStyleSyntaxWriter GetExportWriter(DiffFormat format, TextWriter textWriter, bool strikeOutRemoved) - { - switch (format) - { - case DiffFormat.Csv: - return null; - case DiffFormat.Html: - return new HtmlSyntaxWriter(textWriter) {StrikeOutRemoved = strikeOutRemoved}; - case DiffFormat.WordXml: - return new OpenXmlSyntaxWriter(textWriter); - case DiffFormat.Text: - return new TextSyntaxWriter(textWriter); - case DiffFormat.UnifiedDiff: - return new UnifiedDiffSyntaxWriter(textWriter); - default: - throw new ArgumentOutOfRangeException("format"); - } - } - - public static MappingSettings GetMappingSettings(DiffConfiguration configuration) - { - Func diffFilterPredicate = t => (t != DifferenceType.Added || configuration.IsOptionSet(DiffConfigurationOptions.IncludeAdded)) && - (t != DifferenceType.Changed || configuration.IsOptionSet(DiffConfigurationOptions.IncludeChanged)) && - (t != DifferenceType.Removed || configuration.IsOptionSet(DiffConfigurationOptions.IncludeRemoved)) && - (t != DifferenceType.Unchanged || configuration.IsOptionSet(DiffConfigurationOptions.IncludeUnchanged)); - - var cciFilter = GetFilter(configuration); - var mappingDifferenceFilter = configuration.IsOptionSet(DiffConfigurationOptions.TypesOnly) - ? new TypesOnlyMappingDifferenceFilter(diffFilterPredicate, cciFilter) - : new MappingDifferenceFilter(diffFilterPredicate, cciFilter); - - var includeAddedTypes = configuration.IsOptionSet(DiffConfigurationOptions.IncludeAddedTypes); - var includeRemovedTypes = configuration.IsOptionSet(DiffConfigurationOptions.IncludeRemovedTypes); - var actualFilter = includeAddedTypes && includeRemovedTypes - ? (IMappingDifferenceFilter) mappingDifferenceFilter - : new CommonTypesMappingDifferenceFilter(mappingDifferenceFilter, includeAddedTypes, includeRemovedTypes); - - return new MappingSettings - { - Filter = cciFilter, - DiffFilter = actualFilter, - IncludeForwardedTypes = true, - GroupByAssembly = configuration.IsOptionSet(DiffConfigurationOptions.GroupByAssembly), - FlattenTypeMembers = configuration.IsOptionSet(DiffConfigurationOptions.FlattenTypes), - AlwaysDiffMembers = configuration.IsOptionSet(DiffConfigurationOptions.AlwaysDiffMembers) - }; - } - - private static ICciFilter GetFilter(DiffConfiguration configuration) - { - var includeAttributes = configuration.IsOptionSet(DiffConfigurationOptions.DiffAttributes); - var includeInternals = configuration.IsOptionSet(DiffConfigurationOptions.IncludeInternals); - var includePrivates = configuration.IsOptionSet(DiffConfigurationOptions.IncludePrivates); - var includeGenerated = configuration.IsOptionSet(DiffConfigurationOptions.IncludeGenerated); - return new DiffCciFilter(includeAttributes, includeInternals, includePrivates, includeGenerated); - } - - public static DiffDocument BuildDiffDocument(DiffConfiguration configuration) - { - return BuildDiffDocument(configuration, CancellationToken.None); - } - - public static DiffDocument BuildDiffDocument(DiffConfiguration configuration, CancellationToken cancellationToken) - { - try - { - IEnumerable tokens; - IEnumerable apiDefinitions; - GetTokens(configuration, cancellationToken, out tokens, out apiDefinitions); - - IEnumerable lines = GetLines(tokens, cancellationToken); - AssemblySet left = configuration.Left; - AssemblySet right = configuration.Right; - return new DiffDocument(left, right, lines, apiDefinitions); - } - catch (OperationCanceledException) - { - return null; - } - } - - private static void GetTokens(DiffConfiguration configuration, CancellationToken cancellationToken, out IEnumerable tokens, out IEnumerable apiDefinitions) - { - bool includeAttributes = configuration.IsOptionSet(DiffConfigurationOptions.DiffAttributes); - var diffRecorder = new DiffRecorder(cancellationToken); - MappingSettings mappingSettings = GetMappingSettings(configuration); - var writer = new ApiRecordingCSharpDiffWriter(diffRecorder, mappingSettings, includeAttributes) - { - IncludeAssemblyProperties = configuration.IsOptionSet(DiffConfigurationOptions.DiffAssemblyInfo), - HighlightBaseMembers = configuration.IsOptionSet(DiffConfigurationOptions.HighlightBaseMembers) - }; - - WriteDiff(configuration, writer); - - tokens = diffRecorder.Tokens; - apiDefinitions = writer.ApiDefinitions; - } - - private static IEnumerable GetLines(IEnumerable tokens, CancellationToken cancellationToken) - { - var lines = new List(); - var currentLineTokens = new List(); - - foreach (var diffToken in tokens) - { - cancellationToken.ThrowIfCancellationRequested(); - - if (diffToken.Kind != DiffTokenKind.LineBreak) - { - currentLineTokens.Add(diffToken); - } - else - { - DiffLineKind kind = GetDiffLineKind(currentLineTokens); - var line = new DiffLine(kind, currentLineTokens); - lines.Add(line); - currentLineTokens.Clear(); - } - } - - // HACH: Fixup lines that only have closing brace but - return FixupCloseBraces(lines, cancellationToken); - } - - private static IEnumerable FixupCloseBraces(IEnumerable lines, CancellationToken cancellationToken) - { - var startLineStack = new Stack(); - - foreach (var diffLine in lines) - { - cancellationToken.ThrowIfCancellationRequested(); - - int braceDelta = GetBraceDelta(diffLine); - DiffLine result = diffLine; - - for (var i = braceDelta; i > 0; i--) - startLineStack.Push(diffLine); - - for (var i = braceDelta; i < 0 && startLineStack.Count > 0; i++) - { - DiffLine startLine = startLineStack.Pop(); - DiffLineKind fixedLineKind = startLine.Kind; - if (result.Kind != fixedLineKind) - result = new DiffLine(fixedLineKind, diffLine.Tokens); - } - - yield return result; - } - } - - private static int GetBraceDelta(DiffLine diffLine) - { - int openBraces = 0; - foreach (var symbol in diffLine.Tokens.Where(t => t.Kind == DiffTokenKind.Symbol)) - { - switch (symbol.Text) - { - case "{": - openBraces++; - break; - case "}": - openBraces--; - break; - } - } - - return openBraces; - } - - private static DiffLineKind GetDiffLineKind(IEnumerable currentLineTokens) - { - IEnumerable relevantTokens = currentLineTokens.Where(t => t.Kind != DiffTokenKind.Indent && - t.Kind != DiffTokenKind.Whitespace && - t.Kind != DiffTokenKind.LineBreak); - - bool hasSame = HasStyle(relevantTokens, DiffStyle.None); - bool hasAdditions = HasStyle(relevantTokens, DiffStyle.Added); - bool hasRemovals = HasStyle(relevantTokens, DiffStyle.Removed); - bool hasIncompatibility = HasStyle(relevantTokens, DiffStyle.NotCompatible); - - if (hasSame && (hasAdditions || hasRemovals) || hasIncompatibility) - return DiffLineKind.Changed; - - if (hasAdditions) - return DiffLineKind.Added; - - if (hasRemovals) - return DiffLineKind.Removed; - - return DiffLineKind.Same; - } - - private static bool HasStyle(IEnumerable tokens, DiffStyle diffStyle) - { - return tokens.Where(t => t.HasStyle(diffStyle)).Any(); - } - } - - public static class DiffExtensions - { - public static bool HasStyle(this DiffToken token, DiffStyle diffStyle) - { - // Special case the zero-flag. - if (diffStyle == DiffStyle.None) - return token.Style == DiffStyle.None; - - return (token.Style & diffStyle) == diffStyle; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffFormat.cs b/src/Microsoft.DotNet.AsmDiff/DiffFormat.cs deleted file mode 100644 index 02714d67063..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffFormat.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff -{ - public enum DiffFormat - { - Csv, - Html, - WordXml, - Text, - UnifiedDiff, - Md - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffLine.cs b/src/Microsoft.DotNet.AsmDiff/DiffLine.cs deleted file mode 100644 index f49814b19bf..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffLine.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class DiffLine - { - public DiffLineKind Kind { get; private set; } - public ReadOnlyCollection Tokens { get; private set; } - - public DiffLine(DiffLineKind kind, IEnumerable tokens) - { - Kind = kind; - Tokens = new ReadOnlyCollection(tokens.ToArray()); - } - - public override string ToString() - { - return string.Concat(Tokens); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffLineKind.cs b/src/Microsoft.DotNet.AsmDiff/DiffLineKind.cs deleted file mode 100644 index f98c51f52fc..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffLineKind.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff -{ - public enum DiffLineKind - { - Same, - Added, - Removed, - Changed - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffRecorder.cs b/src/Microsoft.DotNet.AsmDiff/DiffRecorder.cs deleted file mode 100644 index d81b1510158..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffRecorder.cs +++ /dev/null @@ -1,165 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci.Writers.Syntax; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; - -namespace Microsoft.DotNet.AsmDiff -{ - internal sealed class DiffRecorder : IStyleSyntaxWriter - { - private Stack _styleStack = new Stack(); - private bool _needIndent = true; - private bool _skipNextWithspace; - private bool _lastTokenWasLineBreak; - - public CancellationToken CancellationToken { get; } - public List Tokens { get; } = new List(); - public int Line { get; private set; } - - public DiffRecorder(CancellationToken cancellationToken) - { - CancellationToken = cancellationToken; - } - - public void Dispose() - { - } - - private void WriteIndentIfNeeded() - { - if (!_needIndent) - return; - - WriteToken(DiffTokenKind.Indent, new string(' ', IndentLevel * 4)); - _needIndent = false; - } - - private void WriteToken(DiffTokenKind kind, string text) - { - CancellationToken.ThrowIfCancellationRequested(); - - var tokenIsLineBreak = kind == DiffTokenKind.LineBreak; - if (tokenIsLineBreak && _lastTokenWasLineBreak) - return; - - if (tokenIsLineBreak) - Line++; - - _lastTokenWasLineBreak = tokenIsLineBreak; - - var diffStyle = GetCurrentDiffStyle(); - var token = new DiffToken(diffStyle, kind, text); - Tokens.Add(token); - } - - private DiffStyle GetCurrentDiffStyle() - { - return _styleStack.Aggregate(DiffStyle.None, (current, diffStyle) => current | diffStyle); - } - - public void Write(string str) - { - // Work around issue where member attributes are emitted using a textual linebreak. - if (str == "\r\n" || str == "\r" || str == "\n") - { - // We should ignore the next whitespace text to avoid double indenting. - // However, setting _needIndent to false is not a good solution either - // as it assumes that the writer uses the same level of indentation as - // we are (which is not the case). - WriteLine(); - _skipNextWithspace = true; - return; - } - - // If the text is whitespace only, recored it as such. - if (str.Trim().Length == 0) - { - WriteWhitespace(str); - return; - } - - // Work around issue where member attributes are emitted using a textual indent. - if (_lastTokenWasLineBreak && str.Trim().Length == 0) - { - return; - } - - WriteIndentIfNeeded(); - WriteToken(DiffTokenKind.Text, str); - } - - private void WriteWhitespace(string str) - { - if (_skipNextWithspace) - { - _skipNextWithspace = false; - return; - } - - WriteIndentIfNeeded(); - WriteToken(DiffTokenKind.Whitespace, str); - } - - public void WriteSymbol(string symbol) - { - WriteIndentIfNeeded(); - WriteToken(DiffTokenKind.Symbol, symbol); - } - - public void WriteIdentifier(string id) - { - WriteIndentIfNeeded(); - WriteToken(DiffTokenKind.Identifier, id); - } - - public void WriteKeyword(string keyword) - { - WriteIndentIfNeeded(); - WriteToken(DiffTokenKind.Keyword, keyword); - } - - public void WriteTypeName(string typeName) - { - WriteIndentIfNeeded(); - WriteToken(DiffTokenKind.TypeName, typeName); - } - - public void WriteLine() - { - WriteToken(DiffTokenKind.LineBreak, Environment.NewLine); - _needIndent = true; - } - - public int IndentLevel { get; set; } - - public IDisposable StartStyle(SyntaxStyle style, object context) - { - var convertedStyle = ConvertStyle(style); - _styleStack.Push(convertedStyle); - return new DisposeAction(() => _styleStack.Pop()); - } - - private static DiffStyle ConvertStyle(SyntaxStyle style) - { - switch (style) - { - case SyntaxStyle.Added: - return DiffStyle.Added; - case SyntaxStyle.Removed: - return DiffStyle.Removed; - case SyntaxStyle.InterfaceMember: - return DiffStyle.InterfaceMember; - case SyntaxStyle.InheritedMember: - return DiffStyle.InheritedMember; - case SyntaxStyle.NotCompatible: - return DiffStyle.NotCompatible; - default: - throw new ArgumentOutOfRangeException("style"); - } - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffStyle.cs b/src/Microsoft.DotNet.AsmDiff/DiffStyle.cs deleted file mode 100644 index 6583d4e8873..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffStyle.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.DotNet.AsmDiff -{ - [Flags] - public enum DiffStyle - { - None = 0x00, - Added = 0x01, - Removed = 0x02, - InterfaceMember = 0x04, - InheritedMember = 0x08, - NotCompatible = 0x10, - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffToken.cs b/src/Microsoft.DotNet.AsmDiff/DiffToken.cs deleted file mode 100644 index 4bb2f793cdb..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffToken.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class DiffToken - { - public DiffStyle Style { get; private set; } - public DiffTokenKind Kind { get; set; } - public string Text { get; private set; } - - public DiffToken(DiffStyle style, DiffTokenKind kind, string text) - { - Style = style; - Text = text; - Kind = kind; - } - - public bool HasStyle(DiffStyle diffStyle) - { - // Special case the zero-flag. - if (diffStyle == DiffStyle.None) - return Style == DiffStyle.None; - - return (Style & diffStyle) == diffStyle; - } - - public override string ToString() - { - return Text; - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/DiffTokenKind.cs b/src/Microsoft.DotNet.AsmDiff/DiffTokenKind.cs deleted file mode 100644 index 727c3b7bc94..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/DiffTokenKind.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.DotNet.AsmDiff -{ - public enum DiffTokenKind - { - Text, - Symbol, - Identifier, - Keyword, - TypeName, - LineBreak, - Indent, - Whitespace - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/MarkdownDiffExporter.cs b/src/Microsoft.DotNet.AsmDiff/MarkdownDiffExporter.cs deleted file mode 100644 index 22894fcc2f7..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/MarkdownDiffExporter.cs +++ /dev/null @@ -1,228 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Cci; -using Microsoft.Cci.Differs; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.Cci.Extensions.CSharp; - -namespace Microsoft.DotNet.AsmDiff -{ - public sealed class MarkdownDiffExporter - { - private readonly DiffDocument _diffDocument; - private readonly string _path; - private readonly bool _includeTableOfContents; - private readonly bool _createFilePerNamespace; - - public MarkdownDiffExporter(DiffDocument diffDocument, string path, bool includeTableOfContents, bool createFilePerNamespace) - { - _diffDocument = diffDocument; - _path = path; - _includeTableOfContents = includeTableOfContents; - _createFilePerNamespace = createFilePerNamespace; - } - - public void Export() - { - if (_createFilePerNamespace && !_includeTableOfContents) - { - WriteDiffForNamespaces(null); - } - else - { - using (var writer = new StreamWriter(_path)) - { - WriteHeader(writer); - - if (_includeTableOfContents) - WriteTableOfContents(writer); - - WriteDiffForNamespaces(writer); - } - } - } - - private void WriteHeader(StreamWriter writer) - { - if (_diffDocument.IsDiff) - { - writer.WriteLine(Resources.MarkdownTitle, _diffDocument.Left.Name, _diffDocument.Right.Name); - } - else - { - string singleSideName = _diffDocument.Left.IsEmpty ? _diffDocument.Right.Name : _diffDocument.Left.Name; - writer.WriteLine(Resources.MarkdownAPIListTitle, singleSideName); - } - - writer.WriteLine(); - - if (_diffDocument.IsDiff) - { - writer.WriteLine(Resources.MarkdownDiffDescription); - writer.WriteLine(); - } - } - - private void WriteTableOfContents(StreamWriter writer) - { - foreach (var topLevelApi in _diffDocument.ApiDefinitions) - { - string linkTitle = topLevelApi.Name; - string linkTarget = GetLinkTarget(topLevelApi.Name); - - writer.WriteLine("* [{0}]({1})", linkTitle, linkTarget); - } - - writer.WriteLine(); - } - - private void WriteDiffForNamespaces(StreamWriter writer) - { - if (_createFilePerNamespace) - { - foreach (var topLevelApi in _diffDocument.ApiDefinitions) - { - string fileName = GetFileNameForNamespace(topLevelApi.Name); - using (var nestedWriter = new StreamWriter(fileName)) - WriteDiffForNamespace(nestedWriter, topLevelApi, isStandalone: true); - } - } - else - { - foreach (DiffApiDefinition topLevelApi in _diffDocument.ApiDefinitions) - { - WriteDiffForNamespace(writer, topLevelApi, isStandalone: false); - } - } - } - - private void WriteDiffForNamespace(StreamWriter writer, DiffApiDefinition topLevelApi, bool isStandalone) - { - string heading = _createFilePerNamespace ? "#" : "##"; - writer.WriteLine(heading + " " + topLevelApi.Name); - writer.WriteLine(); - - WriteDiff(writer, topLevelApi); - - writer.WriteLine(); - } - - private static void WriteDiff(StreamWriter writer, DiffApiDefinition topLevelApi) - { - writer.WriteLine("``` diff"); - WriteDiff(writer, topLevelApi, 0); - writer.WriteLine("```"); - } - - private static void WriteDiff(StreamWriter writer, DiffApiDefinition api, int level) - { - bool hasChildren = api.Children.Any(); - - string indent = new string(' ', level * 4); - string suffix = hasChildren ? " {" : string.Empty; - DifferenceType diff = api.Difference; - - if (diff == DifferenceType.Changed) - { - // Let's see whether the syntax actually changed. For some cases the syntax might not - // diff, for example, when attribute declarations have changed. - - string left = api.Left.GetCSharpDeclaration(); - string right = api.Right.GetCSharpDeclaration(); - - if (string.Equals(left, right, StringComparison.OrdinalIgnoreCase)) - diff = DifferenceType.Unchanged; - } - - switch (diff) - { - case DifferenceType.Added: - WriteDiff(writer, "+", indent, suffix, api.Right); - break; - case DifferenceType.Removed: - WriteDiff(writer, "-", indent, suffix, api.Left); - break; - case DifferenceType.Changed: - WriteDiff(writer, "-", indent, suffix, api.Left); - WriteDiff(writer, "+", indent, suffix, api.Right); - break; - default: - WriteDiff(writer, " ", indent, suffix, api.Definition); - break; - } - - if (hasChildren) - { - foreach (DiffApiDefinition child in api.Children) - { - WriteDiff(writer, child, level + 1); - } - - var diffMarker = diff == DifferenceType.Added - ? "+" - : diff == DifferenceType.Removed - ? "-" - : " "; - - writer.Write(diffMarker); - writer.Write(indent); - writer.WriteLine("}"); - } - } - - private static void WriteDiff(TextWriter writer, string marker, string indent, string suffix, IDefinition api) - { - IEnumerable lines = GetCSharpDecalarationLines(api); - bool isFirst = true; - - foreach (string line in lines) - { - if (isFirst) - isFirst = false; - else - writer.WriteLine(); - - writer.Write(marker); - writer.Write(indent); - writer.Write(line); - } - - writer.WriteLine(suffix); - } - - private static IEnumerable GetCSharpDecalarationLines(IDefinition api) - { - string text = api.GetCSharpDeclaration(); - using (var reader = new StringReader(text)) - { - string line; - while ((line = reader.ReadLine()) != null) - yield return line; - } - } - - private string GetLinkTarget(string namespaceName) - { - return _createFilePerNamespace - ? Path.GetFileName(GetFileNameForNamespace(namespaceName)) - : "#" + GetAnchorName(namespaceName); - } - - private string GetFileNameForNamespace(string namespaceName) - { - string directory = Path.GetDirectoryName(_path); - string fileName = Path.GetFileNameWithoutExtension(_path); - string extension = Path.GetExtension(_path); - return Path.Combine(directory, fileName + "_" + namespaceName + extension); - } - - private static string GetAnchorName(string name) - { - return name.Replace(".", "").ToLower(); - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/MefHelpers.cs b/src/Microsoft.DotNet.AsmDiff/MefHelpers.cs deleted file mode 100644 index 43525036e56..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/MefHelpers.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Composition.Hosting; -using System.Composition.Hosting.Core; -using System.Linq; - -namespace Microsoft.DotNet.AsmDiff -{ - static class MefHelpers - { - public static ContainerConfiguration WithExport(this ContainerConfiguration configuration, T exportedInstance, string contractName = null, IDictionary metadata = null) - { - return WithExport(configuration, exportedInstance, typeof(T), contractName, metadata); - } - - public static ContainerConfiguration WithExport(this ContainerConfiguration configuration, object exportedInstance, Type contractType, string contractName = null, IDictionary metadata = null) - { - return configuration.WithProvider(new InstanceExportDescriptorProvider( - exportedInstance, contractType, contractName, metadata)); - } - - abstract class SinglePartExportDescriptorProvider : ExportDescriptorProvider - { - readonly Type _contractType; - readonly string _contractName; - - protected SinglePartExportDescriptorProvider(Type contractType, string contractName, IDictionary metadata) - { - if (contractType == null) throw new ArgumentNullException("contractType"); - - _contractType = contractType; - _contractName = contractName; - Metadata = metadata ?? new Dictionary(); - } - - protected bool IsSupportedContract(CompositionContract contract) - { - if (contract.ContractType != _contractType || - contract.ContractName != _contractName) - return false; - - if (contract.MetadataConstraints != null) - { - var subsetOfConstraints = contract.MetadataConstraints.Where(c => Metadata.ContainsKey(c.Key)).ToDictionary(c => c.Key, c => Metadata[c.Key]); - var constrainedSubset = new CompositionContract(contract.ContractType, contract.ContractName, - subsetOfConstraints.Count == 0 ? null : subsetOfConstraints); - - if (!contract.Equals(constrainedSubset)) - return false; - } - - return true; - } - - protected IDictionary Metadata { get; } - } - - // This one-instance-per-provider design is not efficient for more than a few instances; - // we're just aiming to show the mechanics here. - class InstanceExportDescriptorProvider : SinglePartExportDescriptorProvider - { - object _exportedInstance; - - public InstanceExportDescriptorProvider(object exportedInstance, Type contractType, string contractName, IDictionary metadata) - : base(contractType, contractName, metadata) - { - if (exportedInstance == null) throw new ArgumentNullException("exportedInstance"); - _exportedInstance = exportedInstance; - } - - public override IEnumerable GetExportDescriptors(CompositionContract contract, DependencyAccessor descriptorAccessor) - { - if (IsSupportedContract(contract)) - yield return new ExportDescriptorPromise(contract, _exportedInstance.ToString(), true, NoDependencies, _ => - ExportDescriptor.Create((c, o) => _exportedInstance, Metadata)); - } - } - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/Microsoft.DotNet.AsmDiff.csproj b/src/Microsoft.DotNet.AsmDiff/Microsoft.DotNet.AsmDiff.csproj deleted file mode 100644 index 37a4b31931e..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Microsoft.DotNet.AsmDiff.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - - $(NetToolCurrent) - Exe - true - true - dotnet-asmdiff - true - Open - true - - true - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.DotNet.AsmDiff/Program.cs b/src/Microsoft.DotNet.AsmDiff/Program.cs deleted file mode 100644 index 5ae9aecf52e..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Program.cs +++ /dev/null @@ -1,226 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using McMaster.Extensions.CommandLineUtils; -using System; -using System.IO; -using System.Text; -using System.Threading; - -namespace Microsoft.DotNet.AsmDiff -{ - public class Program - { - [Option("-os|--OldSet", "Provide path to an assembly or directory for an assembly set to gather the old set of types. These types will be the baseline for the compare.", CommandOptionType.SingleValue)] - public string OldSet { get; set; } - [Option("-ns|--NewSet", "Provide path to an assembly or directory for an assembly set to gather the new set of types. If this parameter is not provided the API's for the oldset will be printed instead of the diff.", CommandOptionType.SingleValue)] - public string NewSet { get; set; } - - [Option("-nsn|--NewSetName", "Provide a name for the new set in output. If this parameter is not provided the file or directory name will be used.", CommandOptionType.SingleValue)] - public string NewSetName { get; set; } - [Option("-osn|--OldSetName", "Provide a name for the old set in output. If this parameter is not provided the file or directory name will be used.", CommandOptionType.SingleValue)] - public string OldSetName { get; set; } - - [Option("-u|--Unchanged", "Include members, types, and namespaces that are unchanged.", CommandOptionType.NoValue)] - public bool Unchanged { get; set; } - [Option("-r|--Removed", "Include members, types, and namespaces that were removed. (default is removed and added)", CommandOptionType.NoValue)] - public bool Removed { get; set; } - [Option("-a|--Added", "Include members, types, and namespaces that were removed. (default is removed and added)", CommandOptionType.NoValue)] - public bool Added { get; set; } - [Option("-c|--Changed", "Include members, types, and namespaces that were removed. (default is removed and added)", CommandOptionType.NoValue)] - public bool Changed { get; set; } - - [Option("-to|--TypesOnly", "Only show down to the type level not the member level.", CommandOptionType.NoValue)] - public bool TypesOnly { get; set; } - [Option("-sr|--StrikeRemoved", "For removed API's also strike them out. This option currently only works with the HTML writer which is the default.", CommandOptionType.NoValue)] - public bool StrikeRemoved { get; set; } - [Option("-da|--DiffAttributes", "Enables diffing of the attributes as well, by default all attributes are ignored. For CSV writer causes the assembly name to be included in the column for types.", CommandOptionType.NoValue)] - public bool DiffAttributes { get; set; } - [Option("-dai|--DiffAssemblyInfo", "Enables diffing of the assembly level information like version, key, etc.", CommandOptionType.NoValue)] - public bool DiffAssemblyInfo { get; set; } - [Option("-adm|--AlwaysDiffMembers", "By default if an entire class is added or removed we don't show the members, setting this option forces all the members to be shown instead.", CommandOptionType.NoValue)] - public bool AlwaysDiffMembers { get; set; } - [Option("-hbm|--HighlightBaseMembers", "Highlight members that are interface implementations or overrides of a base member.", CommandOptionType.NoValue)] - public bool HighlightBaseMembers { get; set; } - - [Option("-ft|--FlattenTypes", "Will flatten types so that all members available on the type show on the type not just the implemented ones.", CommandOptionType.NoValue)] - public bool FlattenTypes { get; set; } - [Option("-gba|--GroupByAssembly", "Group the differences by assembly instead of flattening the namespaces.", CommandOptionType.NoValue)] - public bool GroupByAssembly { get; set; } - [Option("-eat|--ExcludeAddedTypes", "Do not show types that have been added to the new set of types.", CommandOptionType.NoValue)] - public bool ExcludeAddedTypes { get; set; } - [Option("-ert|--ExcludeRemovedTypes", "Do not show types that have been removed from the new set of types.", CommandOptionType.NoValue)] - public bool ExcludeRemovedTypes { get; set; } - [Option("-iia|--IncludeInternalApis", "Include internal types and members as part of the diff.", CommandOptionType.NoValue)] - public bool IncludeInternalApis { get; set; } - [Option("-ipa|--IncludePrivateApis", "Include private types and members as part of the diff.", CommandOptionType.NoValue)] - public bool IncludePrivateApis { get; set; } - - [Option("-itc|--IncludeTableOfContents", "Include table of contents as part of the diff.", CommandOptionType.NoValue)] - public bool IncludeTableOfContents { get; set; } - [Option("-cfn|--CreateFilePerNamespace", "Create files per namespace.", CommandOptionType.NoValue)] - public bool CreateFilePerNamespace { get; set; } - - [Option("-w|--DiffWriter", "Type of difference writer to use, either CSharp code diffs or flat list of compat violations (default).", CommandOptionType.SingleValue)] - public DiffWriterType DiffWriter { get; set; } - [Option("-s|--SyntaxWriter", "Specific the syntax writer type. Only used if the writer is CSDecl", CommandOptionType.SingleValue)] - public SyntaxWriterType SyntaxWriter { get; set; } - - [Option("-o|--OutFile", "Output file path. Default is the console.", CommandOptionType.SingleValue)] - public string OutFile { get; set; } - - [Option("-l|--Language", "Provide a languagetag for localized content. If this parameter is not provided the environments default language will be used. Currently language specific content is only available in Markdown Writer.", CommandOptionType.SingleValue)] - public string Language { get; set; } - - public void OnExecute() - { - if (string.IsNullOrEmpty(NewSet)) - { - // Reset the filter to be unchanged if we only have a single set so that it will - // simply output the contents of the set. - Removed = Added = false; - Unchanged = true; - } - - if (!Added && !Removed && !Changed && !Unchanged) - { - // If the user didn't explicitly specify what to include we default to changes only. - Added = Removed = Changed = true; - } - - if (!string.IsNullOrEmpty(Language)) - { - var cultureInfo = System.Globalization.CultureInfo.GetCultureInfo(Language); - Thread.CurrentThread.CurrentCulture = cultureInfo; - Thread.CurrentThread.CurrentUICulture = cultureInfo; - } - - DiffConfigurationOptions options = GetDiffOptions(); - DiffFormat diffFormat = GetDiffFormat(); - - AssemblySet oldAssemblies = AssemblySet.FromPaths(OldSetName, OldSet); - AssemblySet newAssemblies = AssemblySet.FromPaths(NewSetName, NewSet); - - DiffConfiguration diffConfiguration = new DiffConfiguration(oldAssemblies, newAssemblies, options); - - if (diffFormat == DiffFormat.Md) - { - DiffDocument diffDocument = DiffEngine.BuildDiffDocument(diffConfiguration); - var markdownDiffExporter = new MarkdownDiffExporter(diffDocument, OutFile, IncludeTableOfContents, CreateFilePerNamespace); - markdownDiffExporter.Export(); - } - else - { - using (TextWriter output = GetOutput()) - DiffEngine.Export(diffConfiguration, null, diffFormat, output); - } - } - - public static int Main(string[] args) => CommandLineApplication.Execute(args); - - private DiffConfigurationOptions GetDiffOptions() - { - var result = DiffConfigurationOptions.IncludeAddedTypes | DiffConfigurationOptions.IncludeRemovedTypes; - - if (Added) - result |= DiffConfigurationOptions.IncludeAdded; - - if (Removed) - result |= DiffConfigurationOptions.IncludeRemoved; - - if (Changed) - result |= DiffConfigurationOptions.IncludeChanged; - - if (Unchanged) - result |= DiffConfigurationOptions.IncludeUnchanged; - - if (AlwaysDiffMembers) - result |= DiffConfigurationOptions.AlwaysDiffMembers; - - if (TypesOnly) - result |= DiffConfigurationOptions.TypesOnly; - - if (FlattenTypes) - result |= DiffConfigurationOptions.FlattenTypes; - - if (GroupByAssembly) - result |= DiffConfigurationOptions.GroupByAssembly; - - if (HighlightBaseMembers) - result |= DiffConfigurationOptions.HighlightBaseMembers; - - if (DiffAssemblyInfo) - result |= DiffConfigurationOptions.DiffAssemblyInfo; - - if (StrikeRemoved) - result |= DiffConfigurationOptions.StrikeRemoved; - - if (DiffAttributes) - result |= DiffConfigurationOptions.DiffAttributes; - - if (ExcludeAddedTypes) - result &= ~DiffConfigurationOptions.IncludeAddedTypes; - - if (ExcludeRemovedTypes) - result &= ~DiffConfigurationOptions.IncludeRemovedTypes; - - if (IncludeInternalApis) - result |= DiffConfigurationOptions.IncludeInternals; - - if (IncludePrivateApis) - result |= DiffConfigurationOptions.IncludePrivates; - - return result; - } - - private DiffFormat GetDiffFormat() - { - switch (DiffWriter) - { - case DiffWriterType.CSharp: - switch (SyntaxWriter) - { - case SyntaxWriterType.Html: - return DiffFormat.Html; - case SyntaxWriterType.Text: - return DiffFormat.Text; - case SyntaxWriterType.Diff: - return DiffFormat.UnifiedDiff; - case SyntaxWriterType.Xml: - return DiffFormat.WordXml; - default: - throw new ArgumentOutOfRangeException(); - } - case DiffWriterType.CSV: - return DiffFormat.Csv; - case DiffWriterType.Markdown: - return DiffFormat.Md; - default: - throw new ArgumentOutOfRangeException(); - } - } - - public TextWriter GetOutput() - { - if (string.IsNullOrWhiteSpace(OutFile)) - return Console.Out; - - return new StreamWriter(OutFile, false, Encoding.UTF8); - } - } - - public enum SyntaxWriterType - { - Html, - Text, - Diff, - Xml, - } - - public enum DiffWriterType - { - CSharp, - CSV, - Markdown - } -} diff --git a/src/Microsoft.DotNet.AsmDiff/README.md b/src/Microsoft.DotNet.AsmDiff/README.md deleted file mode 100644 index 2dad02c4859..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Microsoft.DotNet.AsmDiff - -AsmDiff is a command line tool which may be used to check the API changes between a two sets of .NET assemblies. - -## Required Options - -- `-os|--OldSet` - Provide path to an assembly or directory for an assembly set to gather the old set of types. These types will be the baseline for the compare. -- `-ns|--NewSet` - Provide path to an assembly or directory for an assembly set to gather the new set of types. If this parameter is not provided the API's for the oldset will be printed instead of the diff. - -## Additional Options - -- `-nsn|--NewSetName` - Provide a name for the new set in output. If this parameter is not provided the file or directory name will be used. -- `-osn|--OldSetName` - Provide a name for the old set in output. If this parameter is not provided the file or directory name will be used. -- `-u|--Unchanged` - Include members, types, and namespaces that are unchanged. -- `-r|--Removed` - Include members, types, and namespaces that were removed. (default is removed and added) -- `-a|--Added` - Include members, types, and namespaces that were added. (default is removed and added) -- `-c|--Changed` - Include members, types, and namespaces that were changed. (default is removed and added) -- `-to|--TypesOnly` - Only show down to the type level not the member level. -- `-sr|--StrikeRemoved` - For removed API's also strike them out. This option currently only works with the HTML writer which is the default. -- `-da|--DiffAttributes` - Enables diffing of the attributes as well, by default all attributes are ignored. For CSV writer causes the assembly name to be included in the column for types. -- `-dai|--DiffAssemblyInfo` - Enables diffing of the assembly level information like version, key, etc. -- `-adm|--AlwaysDiffMembers` - By default if an entire class is added or removed we don't show the members, setting this option forces all the members to be shown instead. -- `-hbm|--HighlightBaseMembers` - Highlight members that are interface implementations or overrides of a base member. -- `-ft|--FlattenTypes` - Will flatten types so that all members available on the type show on the type not just the implemented ones. -- `-gba|--GroupByAssembly` - Group the differences by assembly instead of flattening the namespaces. -- `-eat|--ExcludeAddedTypes` - Do not show types that have been added to the new set of types. -- `-ert|--ExcludeRemovedTypes` - Do not show types that have been removed from the new set of types. -- `-iia|--IncludeInternalApis` - Include internal types and members as part of the diff. -- `-ipa|--IncludePrivateApis` - Include private types and members as part of the diff. -- `-w|--DiffWriter` - Type of difference writer to use, either CSharp code diffs or flat list of compat violations (default). -- `-s|--SyntaxWriter` - Specific the syntax writer type. Only used if the writer is CSDecl -- `-o|--OutFile` - Output file path. Default is the console. -- `-l|--Language` - Provide a languagetag for localized content. Currently language specific content is only available in Markdown for en and de. If this parameter is not provided the environments default language will be used. If a specific language is not supported english is the default language. diff --git a/src/Microsoft.DotNet.AsmDiff/Resources.resx b/src/Microsoft.DotNet.AsmDiff/Resources.resx deleted file mode 100644 index 9fa2a4ed7ef..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/Resources.resx +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - # API List of {0} - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - - - # API Difference {0} vs {1} - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.cs.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.cs.xlf deleted file mode 100644 index 9955162a2f7..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.cs.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # Seznam rozhraní API pro {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - Výpis rozhraní API se řídí standardním formátováním rozdílů. -Řádky před znakem + jsou přidané a znak - označuje odebrání. - - - - # API Difference {0} vs {1} - # Rozdíly v rozhraních API mezi {0} a {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.de.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.de.xlf deleted file mode 100644 index 920aaeec945..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.de.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # API-Liste von {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - Die API-Auflistung folgt der Standard-Diff-Formatierung. -Zeilen, denen ein "+" vorangestellt ist, sind Ergänzungen, und ein "-" gibt das Entfernen an. - - - - # API Difference {0} vs {1} - # API-Unterschiede {0} im Vergleich zu {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.es.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.es.xlf deleted file mode 100644 index 333e4e351b8..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.es.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # Lista de API de {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - La lista de API sigue el formato de diff estándar. -Las líneas precedidas por un signo "+" son adiciones y un "-" indica una eliminación. - - - - # API Difference {0} vs {1} - # Diferencias de API {0} frente a {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.fr.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.fr.xlf deleted file mode 100644 index b3a0136388a..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.fr.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # Liste des API de {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - La liste des API respecte la mise en forme diff standard. -Les lignes précédées d’un signe « + » sont des ajouts et « - » indique une suppression. - - - - # API Difference {0} vs {1} - # Différence d’API {0} vs {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.it.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.it.xlf deleted file mode 100644 index 35d6b35f3e4..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.it.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # Elenco delle API di {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - Per l'elenco delle API viene usata la formattazione standard delle differenze. -Le righe precedute dal segno più ('+') sono aggiunte, mentre il segno meno ('-') contraddistingue quelle rimosse. - - - - # API Difference {0} vs {1} - # Differenza API {0} rispetto a {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ja.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ja.xlf deleted file mode 100644 index dd529a8a0ba..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ja.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - {0} の # API リスト - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - API 一覧は、標準の差分形式に従います。 - + ' が続く行は追加、'-' は削除を示します。 - - - - # API Difference {0} vs {1} - # API 差分 {0} 対 {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ko.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ko.xlf deleted file mode 100644 index adbcf69d360..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ko.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # {0}의 API 목록 - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - API 목록은 표준 차이 서식을 따릅니다. -앞에 '+'로 시작하는 줄은 추가이며 '-'는 제거를 나타냅니다. - - - - # API Difference {0} vs {1} - # API 차이 {0} 및 {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.pl.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.pl.xlf deleted file mode 100644 index 05323de3b8a..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.pl.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - Lista interfejsów API # z {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - Lista interfejsów API jest zgodna ze standardowym formatowaniem różnicowym. -Wiersze poprzedzone znakiem "+" są dodawaniem, a znak "-" wskazuje usuwanie. - - - - # API Difference {0} vs {1} - Różnica interfejsu API # {0} w stosunku do {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.pt-BR.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.pt-BR.xlf deleted file mode 100644 index c5ea35bc9a8..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.pt-BR.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # Lista de APIs de {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - A listagem da API segue a formatação de comparação padrão. -Linhas precedidas por '+' são adições e '-' indica remoção. - - - - # API Difference {0} vs {1} - # Diferença da API {0} vs {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ru.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ru.xlf deleted file mode 100644 index 9d1156bffe6..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.ru.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # Список API {0} - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - Списки API следуют стандартному форматированию различий. -Строки, начинающиеся символом "+", являются дополнениями, а символ "-" означает удаление. - - - - # API Difference {0} vs {1} - # Различие API {0} и {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.tr.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.tr.xlf deleted file mode 100644 index 2972a564b9d..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.tr.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # {0} API listesi - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - API listesi, standart fark biçimlendirmeyi izler. -Başında '+' olması satırların ekleneceğini, '-' olması ise kaldırılacağını belirtir. - - - - # API Difference {0} vs {1} - # {0} ile {1} arasındaki API farkı - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.zh-Hans.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.zh-Hans.xlf deleted file mode 100644 index ae88e93fcfe..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.zh-Hans.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # API {0} 列表 - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - API 列表遵循标准差异格式。 -行前面有 "+" 的是添加,而 "-" 表示删除。 - - - - # API Difference {0} vs {1} - # API 差异 {0} 与 {1} - - - - - \ No newline at end of file diff --git a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.zh-Hant.xlf b/src/Microsoft.DotNet.AsmDiff/xlf/Resources.zh-Hant.xlf deleted file mode 100644 index 837f19474a7..00000000000 --- a/src/Microsoft.DotNet.AsmDiff/xlf/Resources.zh-Hant.xlf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - # API List of {0} - # {0} 的 API 清單 - - - - API listing follows standard diff formatting. -Lines preceded by a '+' are additions and a '-' indicates removal. - API 清單遵循標準差異格式。 -前面加上 '+' 的行是加法,而 '-' 表示移除。 - - - - # API Difference {0} vs {1} - # API 差異 {0} 與 {1} - - - - - \ No newline at end of file