- 
                Notifications
    You must be signed in to change notification settings 
- Fork 120
          Emit IAsyncActionWithProgress<T> and IAsyncOperation* types
          #2091
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            Sergio0694
  wants to merge
  68
  commits into
  staging/3.0
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
user/sergiopedri/generic-async-apis
  
      
      
   
  
    
  
  
  
 
  
      
    base: staging/3.0
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    Introduces the IAsyncActionWithProgressVftbl struct to bind the vtable for the IAsyncActionWithProgress<TProgress> interface, enabling interop with Windows Runtime asynchronous actions with progress reporting.
Introduces a static class providing helper methods for Windows.Foundation.IAsyncActionWithProgress<TProgress> types, intended for use by generated code. Includes a GetResults method to invoke the native implementation and handle errors.
Introduces the IAsyncActionWithProgressMethodsImpl<TProgress> interface for internal use by generated code, providing static abstract methods to get and set progress and completion handlers for IAsyncActionWithProgress types.
Introduces WindowsRuntimeAsyncActionWithProgress<TProgress, TIAsyncActionWithProgressMethods> to support IAsyncActionWithProgress<TProgress> in WinRT. Updates IAsyncActionWithProgressMethodsImpl<TProgress> to allow nullable progress and completed handlers for improved flexibility.
Introduces the IAsyncOperationVftbl struct to define the vtable layout for the IAsyncOperation<TResult> interface in WinRT interop scenarios. This enables low-level binding and invocation of asynchronous operations from native code.
Introduces IAsyncOperationMethodsImpl<TResult> for implementations of IAsyncOperation<TResult> types. This interface provides static abstract methods for handling completion and retrieving results, intended for use by generated code only.
Introduces WindowsRuntimeAsyncOperation<TResult, TIAsyncOperationMethods> as a native object implementation for IAsyncOperation<TResult>. Also updates XML documentation in WindowsRuntimeAsyncActionWithProgress to use <inheritdoc> for IAsyncInfoObjectReference.
Introduces IAsyncOperationWithProgressVftbl to define the vtable layout for the IAsyncOperationWithProgress<TResult, TProgress> interface, enabling interop scenarios in WinRT.Runtime2.
Introduces the IAsyncOperationWithProgressMethodsImpl<TResult, TProgress> interface for internal use by generated code. This interface provides static abstract methods for managing progress and completion handlers, as well as retrieving operation results for IAsyncOperationWithProgress types.
Introduces WindowsRuntimeAsyncOperationWithProgress abstract class to provide a native object implementation for IAsyncOperationWithProgress. Also updates IAsyncOperationWithProgress interface to allow nullable Progress and Completed handlers for improved flexibility.
Applied the [MethodImpl(MethodImplOptions.NoInlining)] attribute to the GetResults method in IAsyncActionWithProgressMethods to prevent inlining, potentially aiding debugging or interop scenarios.
Deleted IAsyncOperationVftbl and IAsyncOperationWithProgressVftbl from the Vtables directory. These structs are no longer needed, possibly due to refactoring or changes in interop handling.
Introduces the IAsyncOperationVftbl type definition in WellKnownTypeDefinitionFactory and exposes it in InteropDefinitions. Also registers the new vtable type in InteropGenerator.Emit. Updates several vtable delegate signatures to use HRESULT instead of int for improved correctness.
Introduces tracking and code generation scaffolding for Windows.Foundation.IAsyncOperation<TResult> types in the interop generator. Updates discovery, references, and error handling to support these types, and adds a placeholder for their code generation logic.
Introduces InteropTypeDefinitionBuilder.IAsyncOperation1 with a static IID method to create the IID property for IAsyncOperation1<TResult> interfaces. Updates InteropGenerator.Emit to use this new helper for generating the IID method.
Added [Obsolete] and [EditorBrowsable(EditorBrowsableState.Never)] attributes to internal members in WindowsRuntimeAsync* classes to discourage usage and improve diagnostics. Updated usage of WellKnownInterfaceIds to WellKnownWindowsInterfaceIIDs for IAsyncInfo references.
Added IWindowsRuntimeInterface<IAsyncInfo> to async action and operation classes, providing GetInterface implementations that return the IAsyncInfo object reference. This enables consistent access to IAsyncInfo across all Windows Runtime async types.
Updated the call to InteropUtf8NameFactory.TypeName to omit the 'IID' suffix when generating the type name for operationType. This change ensures consistency with naming conventions and may prevent duplicate or incorrect type names.
Corrected the comment to reference 'IAsyncOperation`1<TResult>' instead of 'IObservableMap`2<K, V>' to accurately describe the vtable layout.
Introduces get_Handler, set_Handler, and get_UntypedRetVal methods to WellKnownTypeSignatureFactory for delegate handler accessors and untyped property getters. Also updates comments to use HRESULT as the return type for relevant method signatures.
Replaced inline construction of method signatures for 'Completed' and 'GetResults' with calls to WellKnownTypeSignatureFactory helper methods. This improves code readability and centralizes signature logic.
Introduces the IAsyncActionWithProgressVftbl type definition and its registration in the interop module. This enables support for generating interop vtables for IAsyncActionWithProgress<TProgress> interfaces.
Introduces WellKnownTypeDefinitionFactory.IAsyncOperationWithProgressVftbl to generate vtable type definitions for IAsyncOperationWithProgress<TResult, TProgress>. Registers the new vtable type in InteropGenerator.Emit to support code generation for this interface.
Introduces the Methods builder for IAsyncOperation1<T> to generate a static class with a Completed method, including CIL body and exception handling. Adds AsyncOperationCompletedHandler1 and IAsyncOperationMethodsImpl1 references, and updates InteropGenerator.Emit to emit these types and track marshaller types for async operations.
Introduces a static NativeObject method to InteropTypeDefinitionBuilder.IAsyncOperation1 for creating native object type definitions for IAsyncOperation1<TResult> interfaces. Updates InteropGenerator.Emit to use this builder and adds a WindowsRuntimeAsyncOperation2 type reference to InteropReferences to support the new functionality.
Introduces a new ComWrappersCallbackType method to InteropTypeDefinitionBuilder.IAsyncOperation1 for generating callback types for IAsyncOperation1<TResult> interfaces. Updates InteropGenerator.Emit to utilize this method, enabling creation of ComWrappers callback types during interop generation.
Introduces a new method to create marshaller attribute type definitions for IAsyncOperation1<TResult> interfaces. Updates InteropGenerator.Emit to generate the marshaller type using the new method, improving support for COM wrappers marshalling.
Introduces a new static Marshaller method to InteropTypeDefinitionBuilder.IAsyncOperation1 for creating marshaller type definitions for IAsyncOperation1<TResult> interfaces. Updates InteropGenerator.Emit to use the new method, improving clarity and separation of marshaller creation logic.
Introduces InteropTypeDefinitionBuilder.IAsyncOperation1.InterfaceImpl to generate explicit interface implementations for IAsyncOperation1<TResult>. Updates InteropGenerator.Emit to invoke this builder and extends InteropReferences with methods and references for IAsyncOperation1 interface members. This enables dynamic interface castable implementations for async operations.
Introduces a new Proxy method to InteropTypeDefinitionBuilder.IAsyncOperation1 for generating proxy types for IAsyncOperation1<TResult> interfaces. Updates InteropGenerator.Emit to utilize this method, enabling proxy type creation during interop code generation.
Implements interop type and method generation for Windows.Foundation.IAsyncActionWithProgress<TProgress>, including builder, generator, discovery state, and reference updates. This adds method implementations for Progress and Completed handlers, corrects type tracking and ordering, and exposes new references for AsyncActionWithProgress-related types and handlers.
Added support for AsyncActionProgressHandler1 and AsyncActionWithProgressCompletedHandler1 in the marshaller type tracking logic, alongside AsyncOperationCompletedHandler1. This ensures marshaller types are generated for all relevant async handler types.
Introduces the static GetResults method to the IAsyncActionWithProgress interop builder and adds corresponding member references in InteropReferences. This enables proper method implementation and referencing for GetResults in generated interop types.
Introduces a NativeObject method for IAsyncActionWithProgress<TProgress> in InteropTypeDefinitionBuilder, enabling generation of native object types for async actions with progress. Updates InteropGenerator.Emit to use this method and adds a reference to WindowsRuntimeAsyncActionWithProgress<T, ...> in InteropReferences.
Introduces the ComWrappersCallbackType method to InteropTypeDefinitionBuilder.IAsyncActionWithProgress1, enabling creation of callback types for IAsyncActionWithProgress<TProgress> interfaces. Updates InteropGenerator.Emit to utilize this new method for generating the appropriate callback type.
Introduces a new method to generate a marshaller attribute type for IAsyncActionWithProgress<TProgress> interfaces in InteropTypeDefinitionBuilder. Updates InteropGenerator.Emit to invoke this method, enabling marshaller attribute creation during interop code generation.
Introduces a new static Marshaller method to InteropTypeDefinitionBuilder.IAsyncActionWithProgress1 for creating marshaller type definitions for IAsyncActionWithProgress<TProgress> interfaces. Updates InteropGenerator.Emit to use this new method, improving clarity and separation of marshaller creation logic.
Introduces InteropTypeDefinitionBuilder.IAsyncActionWithProgress1.InterfaceImpl to generate interface implementation types for IAsyncActionWithProgress<TProgress>. Updates InteropGenerator.Emit to invoke this method and extends InteropReferences with helpers for referencing IAsyncActionWithProgress<T> members. This enables dynamic interface castable implementations for async actions with progress.
Introduces a new Proxy method in InteropTypeDefinitionBuilder.IAsyncActionWithProgress1 to generate proxy types for IAsyncActionWithProgress<TProgress> interfaces. Updates InteropGenerator.Emit to invoke this method, enabling proxy type creation during interop code generation.
Introduces a new static method TypeMapAttributes in InteropTypeDefinitionBuilder.IAsyncActionWithProgress1 to create type map attributes for IAsyncActionWithProgress<TProgress> interfaces. Updates InteropGenerator.Emit to call this method after proxy and interface implementation type generation.
Introduces the ImplType method for IAsyncActionWithProgress<TProgress> in InteropTypeDefinitionBuilder, generating the implementation type for the vtable and wiring up Progress and Completed handler methods. Updates InteropGenerator.Emit to invoke this new method, and refactors IAsyncOperation1 to use a cached handler type signature for marshaller lookups.
Added InteropMethodDefinitionFactory.IAsyncActionWithProgress1Impl with a static GetResults method to generate the GetResults export for IAsyncActionWithProgress<TProgress> implementation types. Updated InteropTypeDefinitionBuilder to use this method and include it in the generated implementation.
Added [Obsolete] and [EditorBrowsable(EditorBrowsableState.Never)] attributes to WindowsRuntimeAsyncActionWithProgress, WindowsRuntimeAsyncOperationWithProgress, and WindowsRuntimeAsyncOperation classes to discourage direct usage and hide them from IntelliSense. This clarifies their intended internal use and guides developers away from relying on private implementation details.
Eliminated <remarks> sections stating usage by generated code from various collection and interop types. This reduces documentation clutter and relies on the existing Obsolete attribute for guidance.
Introduces tracking, reference, and code generation scaffolding for Windows.Foundation.IAsyncOperationWithProgress<TResult, TProgress> types in the interop generator. Updates error handling, discovery state, and references to support these types.
Added logic to ensure that delegate types associated with IAsyncActionWithProgress<TProgress>, IAsyncOperation<T>, and IAsyncOperationWithProgress<TProgress, TResult> are tracked when these interfaces are instantiated. This ensures all necessary delegate types are available for code generation and projection scenarios.
Introduced InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2 with a static IID method to generate the 'IID' property for IAsyncOperationWithProgress2 interfaces. Updated InteropGenerator.Emit to use this helper when emitting interop types.
Implements static method generation for IAsyncOperationWithProgress2<T,TProgress> in InteropTypeDefinitionBuilder, including Progress and Completed handler accessors and GetResults. Adds corresponding type and member references in InteropReferences, and integrates method generation into the emit pipeline.
Introduces a NativeObject method for IAsyncOperationWithProgress2 in InteropTypeDefinitionBuilder, enabling creation of native object types for async operations with progress. Updates InteropGenerator.Emit to use this method and adds a new type reference for WindowsRuntimeAsyncOperationWithProgress`3 in InteropReferences.
Introduces a new static method, ComWrappersCallbackType, to InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2 for generating callback types for IAsyncOperationWithProgress2 interfaces. Updates InteropGenerator.Emit to utilize this method, enabling creation of ComWrappers callback types during interop generation.
Introduces a new method to generate a marshaller attribute type for IAsyncOperationWithProgress2 interfaces in InteropTypeDefinitionBuilder, and integrates its usage in InteropGenerator.Emit. This supports improved interop code generation for async operations with progress.
Introduces a new static Marshaller method in InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2 to create marshaller type definitions for IAsyncOperationWithProgress2 interfaces. Updates InteropGenerator.Emit to use this new method, improving modularity and clarity in marshaller type generation.
Introduces InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2.InterfaceImpl to generate interface implementation types for IAsyncOperationWithProgress<TResult, TProgress>. Updates InteropReferences with member reference helpers for IAsyncOperationWithProgress2 methods and properties. Also corrects XML doc comments and clarifies method comments for related async interfaces.
Introduces a new static Proxy method in InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2 to generate proxy types for IAsyncOperationWithProgress<TProgress> interfaces. Updates InteropGenerator.Emit to invoke this method, enabling proxy type creation during interop code generation.
Introduces the TypeMapAttributes method to InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2 and calls it from InteropGenerator.Emit. This ensures type map attributes are created for IAsyncOperationWithProgress<TResult, TProgress> interfaces, improving type mapping and interop support.
Introduces the ImplType method to InteropTypeDefinitionBuilder.IAsyncOperationWithProgress2 for generating implementation types for IAsyncOperationWithProgress<TResult, TProgress> interfaces. Updates InteropGenerator.Emit to invoke this method, enabling vtable implementation generation for these async operation interfaces.
Added support for AsyncOperationProgressHandler2 and AsyncOperationWithProgressCompletedHandler2 in the marshaller type tracking logic to ensure all relevant async handler types are properly processed.
Added pragma directives to disable CS1573 and IDE0017 warnings in InteropMethodDefinitionFactory.IAsyncInfoMethods.cs. This is a temporary measure, as indicated by the TODO comment.
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This PR updates cswinrtgen to emit code for:
IAsyncOperation<TResult>IAsyncOperationWithProgress<TResult, TProgress>Also includes some WinRT.Runtime tweaks in related supporting code.
There's some TODOs left here and there, but those can be resolved later.