Skip to content

Commit

Permalink
housekeeping: Stop producing observables for the System.CodeDom names…
Browse files Browse the repository at this point in the history
…pace
  • Loading branch information
glennawatson committed Jun 23, 2019
1 parent ca75471 commit d050c6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

Expand All @@ -21,13 +22,21 @@ namespace Pharmacist.Core.Generation.Resolvers
/// </summary>
internal class PublicEventNamespaceResolver : EventNamespaceResolverBase
{
private const string SkipNamespaceName = "ReactiveUI.Events";
private static readonly ISet<string> SkipNamespaceList = new HashSet<string>(
new[]
{
"ReactiveUI.Events",

// Winforms
"System.CodeDom",
},
StringComparer.InvariantCulture);

/// <inheritdoc />
protected override IEnumerable<(ITypeDefinition typeHostingEvent, ITypeDefinition baseTypeDefinition, IEnumerable<IEvent> events)> GetValidEventDetails(ICompilation compilation)
{
var processedList = new ConcurrentDictionary<ITypeDefinition, bool>(TypeDefinitionNameComparer.Default);
var toProcess = new ConcurrentStack<ITypeDefinition>(GetPublicTypesWithEvents(compilation).Where(x => !x.Namespace.StartsWith(SkipNamespaceName, StringComparison.InvariantCulture)));
var toProcess = new ConcurrentStack<ITypeDefinition>(GetPublicTypesWithEvents(compilation).Where(x => !SkipNamespaceList.Contains(x.Namespace)));
var output = new ConcurrentBag<(ITypeDefinition typeHostingEvent, ITypeDefinition baseTypeDefinition, IEnumerable<IEvent> events)>();

var processing = new ITypeDefinition[Environment.ProcessorCount];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,159 +5,6 @@ using global::System.Reactive.Linq;
using global::System.Reactive.Subjects;
using global::Pharmacist.Common;

namespace System.CodeDom
{
/// <summary>
/// A class that contains extension methods to wrap events for classes contained within the <see cref = "System.CodeDom"/> namespace.
/// </summary>
public static class EventExtensions
{
/// <summary>
/// A wrapper class which wraps all the events contained within the <see cref = "global::System.CodeDom.CodeMemberMethod"/> class.
/// </summary>
public static CodeMemberMethodEvents Events(this global::System.CodeDom.CodeMemberMethod item) => new CodeMemberMethodEvents(item);
/// <summary>
/// A wrapper class which wraps all the events contained within the <see cref = "global::System.CodeDom.CodeNamespace"/> class.
/// </summary>
public static CodeNamespaceEvents Events(this global::System.CodeDom.CodeNamespace item) => new CodeNamespaceEvents(item);
/// <summary>
/// A wrapper class which wraps all the events contained within the <see cref = "global::System.CodeDom.CodeTypeDeclaration"/> class.
/// </summary>
public static CodeTypeDeclarationEvents Events(this global::System.CodeDom.CodeTypeDeclaration item) => new CodeTypeDeclarationEvents(item);
}

/// <summary>
/// A class which wraps the events contained within the <see cref = "global::System.CodeDom.CodeMemberMethod"/> class as observables.
/// </summary>
public class CodeMemberMethodEvents
{
private readonly global::System.CodeDom.CodeMemberMethod _data;
/// <summary>
/// Initializes a new instance of the <see cref = "global::System.CodeDom.CodeMemberMethod"/> class.
/// </summary>
/// <param name = "data">The class that is being wrapped.</param>
public CodeMemberMethodEvents(global::System.CodeDom.CodeMemberMethod data)
{
_data = data;
}

/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeMemberMethod.PopulateImplementationTypes"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateImplementationTypes => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateImplementationTypes += x, x => _data.PopulateImplementationTypes -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeMemberMethod.PopulateParameters"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateParameters => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateParameters += x, x => _data.PopulateParameters -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeMemberMethod.PopulateStatements"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateStatements => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateStatements += x, x => _data.PopulateStatements -= x);
}

/// <summary>
/// A class which wraps the events contained within the <see cref = "global::System.CodeDom.CodeNamespace"/> class as observables.
/// </summary>
public class CodeNamespaceEvents
{
private readonly global::System.CodeDom.CodeNamespace _data;
/// <summary>
/// Initializes a new instance of the <see cref = "global::System.CodeDom.CodeNamespace"/> class.
/// </summary>
/// <param name = "data">The class that is being wrapped.</param>
public CodeNamespaceEvents(global::System.CodeDom.CodeNamespace data)
{
_data = data;
}

/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeNamespace.PopulateComments"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateComments => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateComments += x, x => _data.PopulateComments -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeNamespace.PopulateImports"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateImports => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateImports += x, x => _data.PopulateImports -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeNamespace.PopulateTypes"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateTypes => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateTypes += x, x => _data.PopulateTypes -= x);
}

/// <summary>
/// A class which wraps the events contained within the <see cref = "global::System.CodeDom.CodeTypeDeclaration"/> class as observables.
/// </summary>
public class CodeTypeDeclarationEvents
{
private readonly global::System.CodeDom.CodeTypeDeclaration _data;
/// <summary>
/// Initializes a new instance of the <see cref = "global::System.CodeDom.CodeTypeDeclaration"/> class.
/// </summary>
/// <param name = "data">The class that is being wrapped.</param>
public CodeTypeDeclarationEvents(global::System.CodeDom.CodeTypeDeclaration data)
{
_data = data;
}

/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeTypeDeclaration.PopulateBaseTypes"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateBaseTypes => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateBaseTypes += x, x => _data.PopulateBaseTypes -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeTypeDeclaration.PopulateMembers"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateMembers => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateMembers += x, x => _data.PopulateMembers -= x);
}
}

namespace Xamarin.Forms
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,159 +5,6 @@ using global::System.Reactive.Linq;
using global::System.Reactive.Subjects;
using global::Pharmacist.Common;

namespace System.CodeDom
{
/// <summary>
/// A class that contains extension methods to wrap events for classes contained within the <see cref = "System.CodeDom"/> namespace.
/// </summary>
public static class EventExtensions
{
/// <summary>
/// A wrapper class which wraps all the events contained within the <see cref = "global::System.CodeDom.CodeMemberMethod"/> class.
/// </summary>
public static CodeMemberMethodEvents Events(this global::System.CodeDom.CodeMemberMethod item) => new CodeMemberMethodEvents(item);
/// <summary>
/// A wrapper class which wraps all the events contained within the <see cref = "global::System.CodeDom.CodeNamespace"/> class.
/// </summary>
public static CodeNamespaceEvents Events(this global::System.CodeDom.CodeNamespace item) => new CodeNamespaceEvents(item);
/// <summary>
/// A wrapper class which wraps all the events contained within the <see cref = "global::System.CodeDom.CodeTypeDeclaration"/> class.
/// </summary>
public static CodeTypeDeclarationEvents Events(this global::System.CodeDom.CodeTypeDeclaration item) => new CodeTypeDeclarationEvents(item);
}

/// <summary>
/// A class which wraps the events contained within the <see cref = "global::System.CodeDom.CodeMemberMethod"/> class as observables.
/// </summary>
public class CodeMemberMethodEvents
{
private readonly global::System.CodeDom.CodeMemberMethod _data;
/// <summary>
/// Initializes a new instance of the <see cref = "global::System.CodeDom.CodeMemberMethod"/> class.
/// </summary>
/// <param name = "data">The class that is being wrapped.</param>
public CodeMemberMethodEvents(global::System.CodeDom.CodeMemberMethod data)
{
_data = data;
}

/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeMemberMethod.PopulateImplementationTypes"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateImplementationTypes => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateImplementationTypes += x, x => _data.PopulateImplementationTypes -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeMemberMethod.PopulateParameters"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateParameters => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateParameters += x, x => _data.PopulateParameters -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeMemberMethod.PopulateStatements"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateStatements => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateStatements += x, x => _data.PopulateStatements -= x);
}

/// <summary>
/// A class which wraps the events contained within the <see cref = "global::System.CodeDom.CodeNamespace"/> class as observables.
/// </summary>
public class CodeNamespaceEvents
{
private readonly global::System.CodeDom.CodeNamespace _data;
/// <summary>
/// Initializes a new instance of the <see cref = "global::System.CodeDom.CodeNamespace"/> class.
/// </summary>
/// <param name = "data">The class that is being wrapped.</param>
public CodeNamespaceEvents(global::System.CodeDom.CodeNamespace data)
{
_data = data;
}

/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeNamespace.PopulateComments"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateComments => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateComments += x, x => _data.PopulateComments -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeNamespace.PopulateImports"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateImports => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateImports += x, x => _data.PopulateImports -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeNamespace.PopulateTypes"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateTypes => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateTypes += x, x => _data.PopulateTypes -= x);
}

/// <summary>
/// A class which wraps the events contained within the <see cref = "global::System.CodeDom.CodeTypeDeclaration"/> class as observables.
/// </summary>
public class CodeTypeDeclarationEvents
{
private readonly global::System.CodeDom.CodeTypeDeclaration _data;
/// <summary>
/// Initializes a new instance of the <see cref = "global::System.CodeDom.CodeTypeDeclaration"/> class.
/// </summary>
/// <param name = "data">The class that is being wrapped.</param>
public CodeTypeDeclarationEvents(global::System.CodeDom.CodeTypeDeclaration data)
{
_data = data;
}

/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeTypeDeclaration.PopulateBaseTypes"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateBaseTypes => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateBaseTypes += x, x => _data.PopulateBaseTypes -= x);
/// <summary>
/// Gets an observable which signals when the <see cref = "System.CodeDom.CodeTypeDeclaration.PopulateMembers"/> event triggers.
/// </summary>
public global::System.IObservable<global::System.EventArgs> PopulateMembers => global::System.Reactive.Linq.Observable.FromEvent<global::System.EventHandler, global::System.EventArgs>(eventHandler =>
{
void Handler(object sender, global::System.EventArgs e) => eventHandler(e);
return Handler;
}

, x => _data.PopulateMembers += x, x => _data.PopulateMembers -= x);
}
}

namespace Xamarin.Forms
{
/// <summary>
Expand Down

0 comments on commit d050c6b

Please sign in to comment.