Skip to content
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

409 update 2.0 documentation #537

Draft
wants to merge 7 commits into
base: develop-2.0
Choose a base branch
from

Conversation

baseTwo
Copy link
Collaborator

@baseTwo baseTwo commented Sep 13, 2024

⚠️ DRAFT PR
Work for #409

  • Updated dependency diagrams for:
    • CQL Packager with dependencies SDK
    • CQL to ELM SDK

Service Dependency Graphs

Table of Contents

  1. CQL to ELM
  2. CQL Packager SDK (with dependencies: Code Generation and Compiler)

CQL to ELM

Legend

  • Exclude dependencies to ILogger<T> and IOptions<T>
  • Cyan classes indicate scoped services
  • Purple classes indicate transient services
  • Gray classes indicate types not registered by the service provider
  • Brown classes indicate singleton services
  • Classes are group by their respective projects
classDiagram

    direction LR

    namespace Microsoft {
        class IServiceProvider { }
        class CultureInfo { }
    }

    namespace CqlToElm {
        class CqlToElmConverter { }
        class StreamInspector { }
        class FileSystemLibraryProvider { }
        class LibraryBuilder { }
        class LibraryInfo { }
        class CoercionProvider { }
        class ElmFactory { }
        class SystemLibrary { }
        class StreamInspector { }
        class InvocationBuilder { }
        class LocalIdentifierProvider { }
        class DiskStreamProvider { }
        class IModelProvider { }
        class MessageProvider { }
        class ILibraryProvider { }
        class MemoryLibraryProvider { }
        class BuiltinModelProvider { }
        class IStreamProvider { }
        class ISymbolScope { }
        class LibraryVisitor { }
        class DefinitionVisitor { }
    }

    namespace CqlModel {
        class ModelInfo { }
    }

    %% Style Singleton Types as Brown
    
    style CqlToElmConverter fill:#550
    style CoercionProvider fill:#550
    style ElmFactory fill:#550
    style SystemLibrary fill:#550
    style StreamInspector fill:#550
    style InvocationBuilder fill:#550
    style LocalIdentifierProvider fill:#550
    style IModelProvider fill:#550
    style MessageProvider fill:#550
    style IServiceProvider fill:#550
    style BuiltinModelProvider fill:#550

    %% Style Scoped Types as Cyan
    
    style LibraryBuilder fill:#055

    %% Style Transient Types as Purple

    style LocalIdentifierProvider fill: #505

    %% Style Non-Services Types as Gray

    style LibraryInfo fill: #555
    style ILibraryProvider fill: #555
    style FileSystemLibraryProvider fill: #555
    style MemoryLibraryProvider fill: #555
    style ModelInfo fill: #555
    style CultureInfo fill: #555
    style DiskStreamProvider fill: #555
    style IStreamProvider fill: #555
    style LibraryVisitor fill: #555
    style ISymbolScope fill: #555
    style DefinitionVisitor fill: #555

    %% Inheritance  

    DiskStreamProvider --> IStreamProvider : inherits
    MemoryLibraryProvider --> ILibraryProvider : inherits
    FileSystemLibraryProvider --> ILibraryProvider : inherits
    BuiltinModelProvider --> IModelProvider : inherits
    SystemLibrary --> ISymbolScope : inherits
    
    %% Dependencies

    CultureInfo ..> MessageProvider : injected

    CoercionProvider ..> ElmFactory : injected
    MessageProvider ..> ElmFactory : injected

    ModelInfo ..> BuiltinModelProvider : injected as params[]

    IModelProvider ..> CoercionProvider : injected

    IModelProvider ..> InvocationBuilder : injected
    CoercionProvider ..> InvocationBuilder : injected
    ElmFactory ..> InvocationBuilder : injected
    MessageProvider ..> InvocationBuilder : injected

    LibraryBuilder ..> LibraryInfo : assigned to Library property<br>by FileSystemLibraryProvider

    StreamInspector ..> FileSystemLibraryProvider : injected
    LibraryBuilder ..> FileSystemLibraryProvider : created scoped<br>in TryResolveLibrary()
    CqlToElmConverter ..> FileSystemLibraryProvider : injected
    IServiceProvider ..> FileSystemLibraryProvider : injected

    LibraryBuilder ..> DefinitionVisitor : injected
    IServiceProvider ..> DefinitionVisitor : injected    
    InvocationBuilder ..> DefinitionVisitor : created in ctor  

    LibraryBuilder ..> CqlToElmConverter : created scoped<br>in ConvertLibrary()
    IServiceProvider ..> CqlToElmConverter : injected  
    
    SystemLibrary ..> LibraryVisitor : created in SystemLibrary
    IModelProvider ..> LibraryVisitor : created in ModelProvider
    LocalIdentifierProvider ..> LibraryVisitor : created in VisitLibrary()
    DefinitionVisitor ..> LibraryVisitor : created in VisitLibrary()
    LibraryBuilder ..> LibraryVisitor : created in VisitLibrary()
    IServiceProvider ..> LibraryVisitor : injected    

Loading

CQL to ELM Code Smells

  • IServiceProvider must not be used directly in the code
  • Scoped services leak out of the scope into data objects e.g. LibraryBuilder into LibraryInfo
  • Services leak out their dependencies by making them public properties e.g.
    • LibraryBuilder exposes FileSystemLibraryProvider
    • LibraryInfo exposes LibraryBuilder library
    • CqlToElmConverter exposes IServiceProvider Services, ILogger<CqlToElmConverter> Logger
    • LibraryVisitor exposes IServiceProvider Services, SystemLibrary SystemLibrary
  • CqlToElmConverter is also a factory for LibraryBuilder, see GetBuilder method
  • SystemLibrary is a singleton service but it is not used as a service

CQL Packager SDK (with dependencies: Code Generation and Compiler)

Remarks

  • Excl Logger and Options
  • Cyan classes indicate scoped services
  • Brown classes indicate singleton services
  • Classes are group by their respective projects
classDiagram

    direction LR

    namespace Compiler {
        class LibrarySetExpressionBuilder { }    
        class LibraryExpressionBuilder { }    
        class ExpressionBuilder { }    
        class ExpressionBuilderSettings { }    
        class TupleBuilderCache { }
        class CqlContextBinder { }
        class CqlOperatorsBinder { }
    }

    namespace CodeGeneration {
        class CSharpCodeStreamPostProcessor { }
        class WriteToFileCSharpCodeStreamPostProcessor { }
        class StubCSharpCodeStreamPostProcessor { }
        class AssemblyDataPostProcessor { }
        class WriteToFileAssemblyDataPostProcessor { }
        class StubAssemblyDataPostProcessor { }
        class TypeToCSharpConverter { }
        class CSharpLibrarySetToStreamsWriter { }
        class AssemblyCompiler { }
    }

    namespace Packaging {
        class FhirResourcePostProcessor { }
        class WriteToFileFhirResourcePostProcessor { }
        class StubFhirResourcePostProcessor { }
        class CqlToResourcePackagingPipeline { }
        class ResourcePackager { }
    }

    namespace Abstraction {
        class TypeResolver { }
    }

    namespace Runtime {
        class BaseTypeResolver { }
    }

    namespace Fhir {
        class FhirTypeResolver { }
        class ModelInspector { }
    }

    namespace Conversion {
        class TypeConverter { }
    }

    %% Style Singleton Types as Brown
    
    style FhirTypeResolver fill:#550
    style BaseTypeResolver fill:#550
    style ModelInspector fill:#550
    style TypeConverter fill:#550
    style WriteToFileAssemblyDataPostProcessor fill:#550
    style StubAssemblyDataPostProcessor fill:#550
    style WriteToFileCSharpCodeStreamPostProcessor fill:#550
    style StubCSharpCodeStreamPostProcessor fill:#550
    style TypeToCSharpConverter fill:#550
    style TypeResolver fill:#550
    style AssemblyDataPostProcessor fill:#550
    style CSharpCodeStreamPostProcessor fill:#550
    style CSharpLibrarySetToStreamsWriter fill:#550
    style AssemblyCompiler fill:#550
    style WriteToFileFhirResourcePostProcessor fill:#550
    style StubFhirResourcePostProcessor fill:#550
    style CqlOperatorsBinder fill:#550
    style CqlContextBinder fill:#550
    style ExpressionBuilderSettings fill:#550
    style FhirResourcePostProcessor fill:#550
    style ResourcePackager fill:#550

    %% Style Scoped Types as Cyan

    style LibrarySetExpressionBuilder fill:#055
    style LibraryExpressionBuilder fill:#055
    style ExpressionBuilder fill:#055
    style TupleBuilderCache fill:#055
    style CqlToResourcePackagingPipeline fill:#055

    %% Inheritance  

    BaseTypeResolver --> TypeResolver : inherits
    FhirTypeResolver --> BaseTypeResolver : inherits
    WriteToFileCSharpCodeStreamPostProcessor --> CSharpCodeStreamPostProcessor : inherits
    StubCSharpCodeStreamPostProcessor --> CSharpCodeStreamPostProcessor : inherits
    WriteToFileAssemblyDataPostProcessor --> AssemblyDataPostProcessor : inherits
    StubAssemblyDataPostProcessor --> AssemblyDataPostProcessor : inherits
    WriteToFileFhirResourcePostProcessor --> FhirResourcePostProcessor : inherits
    StubFhirResourcePostProcessor --> FhirResourcePostProcessor : inherits

    %% Dependencies

    LibraryExpressionBuilder ..> LibrarySetExpressionBuilder : injected

    ExpressionBuilder ..> LibraryExpressionBuilder : injected

    TypeResolver ..> ExpressionBuilder : injected
    CqlOperatorsBinder ..> ExpressionBuilder : injected
    TupleBuilderCache ..> ExpressionBuilder : injected
    CqlContextBinder ..> ExpressionBuilder : injected
    ExpressionBuilderSettings ..> ExpressionBuilder : injected

    TypeResolver ..> CqlOperatorsBinder : injected
    TypeConverter ..> CqlOperatorsBinder : injected

    ModelInspector ..> TypeConverter : injected  

    TypeToCSharpConverter ..> CSharpLibrarySetToStreamsWriter : injected

    AssemblyDataPostProcessor ..> AssemblyCompiler : injected\n(optional)
    CSharpCodeStreamPostProcessor ..> AssemblyCompiler : injected\n(optional)
    CSharpLibrarySetToStreamsWriter ..> AssemblyCompiler : injected
    TypeResolver ..> AssemblyCompiler : injected

    TypeResolver ..> CSharpLibrarySetToStreamsWriter : injected

    AssemblyCompiler ..> CqlToResourcePackagingPipeline : injected
    ResourcePackager ..> CqlToResourcePackagingPipeline : injected 
    LibrarySetExpressionBuilder ..> CqlToResourcePackagingPipeline : injected

    TypeResolver ..> ResourcePackager : injected
    FhirResourcePostProcessor ..> ResourcePackager : injected\n(optional) 
Loading

@baseTwo baseTwo linked an issue Sep 13, 2024 that may be closed by this pull request
@baseTwo baseTwo changed the title 409 update 20 documentation 409 update 2.0 documentation Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update 2.0 Documentation
1 participant