From d050c6b378d061c97e126b015b76498136bb1da5 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Sun, 23 Jun 2019 14:41:24 +1000 Subject: [PATCH] housekeeping: Stop producing observables for the System.CodeDom namespace --- .../Resolvers/PublicEventNamespaceResolver.cs | 13 +- ...s.4.0.0.482894.netstandard2.0.approved.txt | 153 ------------------ ...s.4.0.0.497661.netstandard2.0.approved.txt | 153 ------------------ 3 files changed, 11 insertions(+), 308 deletions(-) diff --git a/src/Pharmacist.Core/Generation/Resolvers/PublicEventNamespaceResolver.cs b/src/Pharmacist.Core/Generation/Resolvers/PublicEventNamespaceResolver.cs index e34d209..eacd1ff 100644 --- a/src/Pharmacist.Core/Generation/Resolvers/PublicEventNamespaceResolver.cs +++ b/src/Pharmacist.Core/Generation/Resolvers/PublicEventNamespaceResolver.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading.Tasks; @@ -21,13 +22,21 @@ namespace Pharmacist.Core.Generation.Resolvers /// internal class PublicEventNamespaceResolver : EventNamespaceResolverBase { - private const string SkipNamespaceName = "ReactiveUI.Events"; + private static readonly ISet SkipNamespaceList = new HashSet( + new[] + { + "ReactiveUI.Events", + + // Winforms + "System.CodeDom", + }, + StringComparer.InvariantCulture); /// protected override IEnumerable<(ITypeDefinition typeHostingEvent, ITypeDefinition baseTypeDefinition, IEnumerable events)> GetValidEventDetails(ICompilation compilation) { var processedList = new ConcurrentDictionary(TypeDefinitionNameComparer.Default); - var toProcess = new ConcurrentStack(GetPublicTypesWithEvents(compilation).Where(x => !x.Namespace.StartsWith(SkipNamespaceName, StringComparison.InvariantCulture))); + var toProcess = new ConcurrentStack(GetPublicTypesWithEvents(compilation).Where(x => !SkipNamespaceList.Contains(x.Namespace))); var output = new ConcurrentBag<(ITypeDefinition typeHostingEvent, ITypeDefinition baseTypeDefinition, IEnumerable events)>(); var processing = new ITypeDefinition[Environment.ProcessorCount]; diff --git a/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.482894.netstandard2.0.approved.txt b/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.482894.netstandard2.0.approved.txt index 4530dc8..1e2e745 100644 --- a/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.482894.netstandard2.0.approved.txt +++ b/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.482894.netstandard2.0.approved.txt @@ -5,159 +5,6 @@ using global::System.Reactive.Linq; using global::System.Reactive.Subjects; using global::Pharmacist.Common; -namespace System.CodeDom -{ - /// - /// A class that contains extension methods to wrap events for classes contained within the namespace. - /// - public static class EventExtensions - { - /// - /// A wrapper class which wraps all the events contained within the class. - /// - public static CodeMemberMethodEvents Events(this global::System.CodeDom.CodeMemberMethod item) => new CodeMemberMethodEvents(item); - /// - /// A wrapper class which wraps all the events contained within the class. - /// - public static CodeNamespaceEvents Events(this global::System.CodeDom.CodeNamespace item) => new CodeNamespaceEvents(item); - /// - /// A wrapper class which wraps all the events contained within the class. - /// - public static CodeTypeDeclarationEvents Events(this global::System.CodeDom.CodeTypeDeclaration item) => new CodeTypeDeclarationEvents(item); - } - - /// - /// A class which wraps the events contained within the class as observables. - /// - public class CodeMemberMethodEvents - { - private readonly global::System.CodeDom.CodeMemberMethod _data; - /// - /// Initializes a new instance of the class. - /// - /// The class that is being wrapped. - public CodeMemberMethodEvents(global::System.CodeDom.CodeMemberMethod data) - { - _data = data; - } - - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateImplementationTypes => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateImplementationTypes += x, x => _data.PopulateImplementationTypes -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateParameters => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateParameters += x, x => _data.PopulateParameters -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateStatements => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateStatements += x, x => _data.PopulateStatements -= x); - } - - /// - /// A class which wraps the events contained within the class as observables. - /// - public class CodeNamespaceEvents - { - private readonly global::System.CodeDom.CodeNamespace _data; - /// - /// Initializes a new instance of the class. - /// - /// The class that is being wrapped. - public CodeNamespaceEvents(global::System.CodeDom.CodeNamespace data) - { - _data = data; - } - - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateComments => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateComments += x, x => _data.PopulateComments -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateImports => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateImports += x, x => _data.PopulateImports -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateTypes => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateTypes += x, x => _data.PopulateTypes -= x); - } - - /// - /// A class which wraps the events contained within the class as observables. - /// - public class CodeTypeDeclarationEvents - { - private readonly global::System.CodeDom.CodeTypeDeclaration _data; - /// - /// Initializes a new instance of the class. - /// - /// The class that is being wrapped. - public CodeTypeDeclarationEvents(global::System.CodeDom.CodeTypeDeclaration data) - { - _data = data; - } - - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateBaseTypes => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateBaseTypes += x, x => _data.PopulateBaseTypes -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateMembers => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateMembers += x, x => _data.PopulateMembers -= x); - } -} - namespace Xamarin.Forms { /// diff --git a/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.497661.netstandard2.0.approved.txt b/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.497661.netstandard2.0.approved.txt index 4530dc8..1e2e745 100644 --- a/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.497661.netstandard2.0.approved.txt +++ b/src/Pharmacist.Tests/IntegrationTests/Approved/Xamarin.Forms.4.0.0.497661.netstandard2.0.approved.txt @@ -5,159 +5,6 @@ using global::System.Reactive.Linq; using global::System.Reactive.Subjects; using global::Pharmacist.Common; -namespace System.CodeDom -{ - /// - /// A class that contains extension methods to wrap events for classes contained within the namespace. - /// - public static class EventExtensions - { - /// - /// A wrapper class which wraps all the events contained within the class. - /// - public static CodeMemberMethodEvents Events(this global::System.CodeDom.CodeMemberMethod item) => new CodeMemberMethodEvents(item); - /// - /// A wrapper class which wraps all the events contained within the class. - /// - public static CodeNamespaceEvents Events(this global::System.CodeDom.CodeNamespace item) => new CodeNamespaceEvents(item); - /// - /// A wrapper class which wraps all the events contained within the class. - /// - public static CodeTypeDeclarationEvents Events(this global::System.CodeDom.CodeTypeDeclaration item) => new CodeTypeDeclarationEvents(item); - } - - /// - /// A class which wraps the events contained within the class as observables. - /// - public class CodeMemberMethodEvents - { - private readonly global::System.CodeDom.CodeMemberMethod _data; - /// - /// Initializes a new instance of the class. - /// - /// The class that is being wrapped. - public CodeMemberMethodEvents(global::System.CodeDom.CodeMemberMethod data) - { - _data = data; - } - - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateImplementationTypes => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateImplementationTypes += x, x => _data.PopulateImplementationTypes -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateParameters => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateParameters += x, x => _data.PopulateParameters -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateStatements => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateStatements += x, x => _data.PopulateStatements -= x); - } - - /// - /// A class which wraps the events contained within the class as observables. - /// - public class CodeNamespaceEvents - { - private readonly global::System.CodeDom.CodeNamespace _data; - /// - /// Initializes a new instance of the class. - /// - /// The class that is being wrapped. - public CodeNamespaceEvents(global::System.CodeDom.CodeNamespace data) - { - _data = data; - } - - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateComments => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateComments += x, x => _data.PopulateComments -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateImports => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateImports += x, x => _data.PopulateImports -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateTypes => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateTypes += x, x => _data.PopulateTypes -= x); - } - - /// - /// A class which wraps the events contained within the class as observables. - /// - public class CodeTypeDeclarationEvents - { - private readonly global::System.CodeDom.CodeTypeDeclaration _data; - /// - /// Initializes a new instance of the class. - /// - /// The class that is being wrapped. - public CodeTypeDeclarationEvents(global::System.CodeDom.CodeTypeDeclaration data) - { - _data = data; - } - - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateBaseTypes => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateBaseTypes += x, x => _data.PopulateBaseTypes -= x); - /// - /// Gets an observable which signals when the event triggers. - /// - public global::System.IObservable PopulateMembers => global::System.Reactive.Linq.Observable.FromEvent(eventHandler => - { - void Handler(object sender, global::System.EventArgs e) => eventHandler(e); - return Handler; - } - - , x => _data.PopulateMembers += x, x => _data.PopulateMembers -= x); - } -} - namespace Xamarin.Forms { ///