Skip to content

Commit

Permalink
Merge pull request #14371 from CyrusNajmabadi/eventParameters3
Browse files Browse the repository at this point in the history
Use immutable arrays inside our special codegen events.
  • Loading branch information
CyrusNajmabadi authored Oct 7, 2016
2 parents 7f2048c + e433935 commit 1e55ad1
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 281 deletions.
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/Symbols/IEventSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public interface IEventSymbol : ISymbol
/// </remarks>
ImmutableArray<IEventSymbol> ExplicitInterfaceImplementations { get; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind

Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Friend Class SourceEventSymbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ public WrappedEventSymbol(IEventSymbol eventSymbol, bool canImplementImplicitly,
_symbol = eventSymbol;
}

public IMethodSymbol AddMethod
{
get
{
return _symbol.AddMethod;
}
}

public ImmutableArray<IEventSymbol> ExplicitInterfaceImplementations
{
get
Expand All @@ -35,53 +27,14 @@ public ImmutableArray<IEventSymbol> ExplicitInterfaceImplementations
}
}

public bool IsWindowsRuntimeEvent
{
get
{
return _symbol.IsWindowsRuntimeEvent;
}
}

public new IEventSymbol OriginalDefinition
{
get
{
return this;
}
}

public IEventSymbol OverriddenEvent
{
get
{
return _symbol.OverriddenEvent;
}
}

public IMethodSymbol RaiseMethod
{
get
{
return _symbol.RaiseMethod;
}
}

public IMethodSymbol RemoveMethod
{
get
{
return _symbol.RemoveMethod;
}
}
public new IEventSymbol OriginalDefinition => this;

public ITypeSymbol Type
{
get
{
return _symbol.Type;
}
}
public IMethodSymbol AddMethod => _symbol.AddMethod;
public bool IsWindowsRuntimeEvent => _symbol.IsWindowsRuntimeEvent;
public IEventSymbol OverriddenEvent => _symbol.OverriddenEvent;
public IMethodSymbol RaiseMethod => _symbol.RaiseMethod;
public IMethodSymbol RemoveMethod => _symbol.RemoveMethod;
public ITypeSymbol Type => _symbol.Type;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.GenerateEvent
Private ReadOnly _generatedEvent As IEventSymbol
Private ReadOnly _codeGenerationOptions As CodeGenerationOptions
Private ReadOnly _codeGenService As ICodeGenerationService
Private ReadOnly _generatedType As INamedTypeSymbol

Public Sub New(solution As Solution,
targetSymbol As INamedTypeSymbol,
generatedEvent As IEventSymbol,
generatedType As INamedTypeSymbol,
codeGenService As ICodeGenerationService,
codeGenerationOptions As CodeGenerationOptions)
Me._solution = solution
Me._targetSymbol = targetSymbol
Me._generatedEvent = generatedEvent
Me._generatedType = generatedType
Me._codeGenService = codeGenService
Me._codeGenerationOptions = codeGenerationOptions
_solution = solution
_targetSymbol = targetSymbol
_generatedEvent = generatedEvent
_codeGenService = codeGenService
_codeGenerationOptions = codeGenerationOptions
End Sub

Public Overrides ReadOnly Property Title As String
Expand All @@ -36,19 +33,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.GenerateEvent
End Get
End Property

Protected Overrides Async Function GetChangedDocumentAsync(cancellationToken As CancellationToken) As Task(Of Document)
Dim withEvent = Await _codeGenService.AddEventAsync(_solution, _targetSymbol, _generatedEvent, _codeGenerationOptions, cancellationToken).ConfigureAwait(False)
If _generatedType IsNot Nothing Then
Dim compilation = Await withEvent.Project.GetCompilationAsync(cancellationToken).ConfigureAwait(False)
Dim newTargetSymbol = _targetSymbol.GetSymbolKey().Resolve(compilation).Symbol
If newTargetSymbol.ContainingType IsNot Nothing Then
Return Await _codeGenService.AddNamedTypeAsync(withEvent.Project.Solution, newTargetSymbol.ContainingType, _generatedType, _codeGenerationOptions, cancellationToken).ConfigureAwait(False)
ElseIf newTargetSymbol.ContainingNamespace IsNot Nothing Then
Return Await _codeGenService.AddNamedTypeAsync(withEvent.Project.Solution, newTargetSymbol.ContainingNamespace, _generatedType, _codeGenerationOptions, cancellationToken).ConfigureAwait(False)
End If
End If

Return Await _codeGenService.AddEventAsync(_solution, _targetSymbol, _generatedEvent, _codeGenerationOptions, cancellationToken).ConfigureAwait(False)
Protected Overrides Function GetChangedDocumentAsync(cancellationToken As CancellationToken) As Task(Of Document)
Return _codeGenService.AddEventAsync(
_solution, _targetSymbol, _generatedEvent,
_codeGenerationOptions, cancellationToken)
End Function
End Class
End Class
Expand Down
Loading

0 comments on commit 1e55ad1

Please sign in to comment.