From cb4644c28da0310c1e1b5b02377c92001e357b68 Mon Sep 17 00:00:00 2001 From: James Harris Date: Fri, 1 Nov 2024 12:55:21 +1000 Subject: [PATCH] Update tests to work with new message formats. --- config/staticconfig/analyze_test.go | 12 +- config/staticconfig/application.go | 7 +- config/staticconfig/entity.go | 131 ++++++++++-------- config/staticconfig/handler.go | 50 +++---- config/staticconfig/route.go | 26 ++-- .../testdata/alias-for-generic.md | 2 +- .../conditional-excluded-by-const-expr.md | 4 +- .../conditional-included-by-const-expr.md | 2 +- .../testdata/conditional-present-in-method.md | 2 +- config/staticconfig/testdata/conditional.md | 2 +- .../testdata/handler-aggregate.md | 9 +- .../testdata/handler-integration.md | 9 +- .../staticconfig/testdata/handler-process.md | 11 +- .../testdata/handler-projection.md | 7 +- .../handler-with-unregistered-routes.md | 6 +- .../testdata/identity-from-const.md | 2 +- .../identity-from-non-const-static.md | 2 +- .../testdata/identity-from-non-const.md | 6 +- .../testdata/incomplete-entity.md | 3 +- config/staticconfig/testdata/indirect.md | 2 +- config/staticconfig/testdata/multiple-apps.md | 4 +- config/staticconfig/testdata/nil-handlers.md | 26 ++-- config/staticconfig/testdata/no-handlers.md | 2 +- config/staticconfig/varargs.go | 10 +- 24 files changed, 195 insertions(+), 142 deletions(-) diff --git a/config/staticconfig/analyze_test.go b/config/staticconfig/analyze_test.go index c0c5392..9ae685b 100644 --- a/config/staticconfig/analyze_test.go +++ b/config/staticconfig/analyze_test.go @@ -93,18 +93,22 @@ func TestAnalyzer(t *testing.T) { } // Render the details of the application. - details := config.RenderDetails(app) + err := config.Validate(app) + desc := config.Description( + app, + config.WithValidationResult(err), + ) // Remove the random portion of the temporary directory name // so that the test output is deterministic. rel, _ := filepath.Rel(cwd, dir) - details = strings.ReplaceAll( - details, + desc = strings.ReplaceAll( + desc, "/"+rel+".", ".", ) - if _, err := io.WriteString(out, details); err != nil { + if _, err := io.WriteString(out, desc); err != nil { return err } } diff --git a/config/staticconfig/application.go b/config/staticconfig/application.go index 909899c..984fb21 100644 --- a/config/staticconfig/application.go +++ b/config/staticconfig/application.go @@ -3,6 +3,7 @@ package staticconfig import ( "go/types" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/enginekit/config" "github.com/dogmatiq/enginekit/config/internal/configbuilder" ) @@ -24,7 +25,9 @@ func analyzeApplicationType(ctx *context, t types.Type) { ctx.Analysis.Applications = append(ctx.Analysis.Applications, app) } -func analyzeApplicationConfigurerCall(ctx *configurerCallContext[*configbuilder.ApplicationBuilder]) { +func analyzeApplicationConfigurerCall( + ctx *configurerCallContext[*config.Application, dogma.Application, *configbuilder.ApplicationBuilder], +) { switch ctx.Method.Name() { case "RegisterAggregate": analyzeHandler(ctx, ctx.Builder.Aggregate, nil) @@ -35,6 +38,6 @@ func analyzeApplicationConfigurerCall(ctx *configurerCallContext[*configbuilder. case "RegisterProjection": analyzeHandler(ctx, ctx.Builder.Projection, analyzeProjectionConfigurerCall) default: - ctx.Builder.UpdateFidelity(config.Incomplete) + ctx.Builder.Partial() } } diff --git a/config/staticconfig/entity.go b/config/staticconfig/entity.go index 4296754..e02d449 100644 --- a/config/staticconfig/entity.go +++ b/config/staticconfig/entity.go @@ -10,17 +10,21 @@ import ( "golang.org/x/tools/go/ssa" ) -type entityContext[T configbuilder.EntityBuilder] struct { +type entityContext[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +] struct { *context EntityType types.Type - Builder T + Builder B ConfigureMethod *ssa.Function FunctionUnderAnalysis *ssa.Function ConfigurerParamIndices []int } -func (c *entityContext[T]) IsConfigurer(v ssa.Value) bool { +func (c *entityContext[T, E, B]) IsConfigurer(v ssa.Value) bool { for _, i := range c.ConfigurerParamIndices { if v == c.FunctionUnderAnalysis.Params[i] { return true @@ -29,57 +33,77 @@ func (c *entityContext[T]) IsConfigurer(v ssa.Value) bool { return false } -type configurerCallContext[T configbuilder.EntityBuilder] struct { - *entityContext[T] +type configurerCallContext[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +] struct { + *entityContext[T, E, B] *ssa.CallCommon - Instruction ssa.CallInstruction - Fidelity config.Fidelity + Instruction ssa.CallInstruction + IsSpeculative bool } // configurerCallAnalyzer is a function that analyzes a call to a method on an // entity's configurer. -type configurerCallAnalyzer[T configbuilder.EntityBuilder] func(*configurerCallContext[T]) +type configurerCallAnalyzer[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +] func(*configurerCallContext[T, E, B]) // analyzeEntity analyzes the Configure() method of the type t, which must be a // Dogma application or handler. // // It calls the analyze function for each call to a method on the configurer, // other than Identity() which is handled the same in all cases. -func analyzeEntity[T configbuilder.EntityBuilder]( +func analyzeEntity[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +]( ctx *context, t types.Type, - builder T, - analyze configurerCallAnalyzer[T], + builder B, + analyze configurerCallAnalyzer[T, E, B], ) { - builder.SetSourceTypeName(typename.OfStatic(t)) + builder.TypeName(typename.OfStatic(t)) configure := ctx.LookupMethod(t, "Configure") + ectx := &entityContext[T, E, B]{ + context: ctx, + EntityType: t, + Builder: builder, + ConfigureMethod: configure, + FunctionUnderAnalysis: configure, + ConfigurerParamIndices: []int{1}, + } + + fn := func(ctx *configurerCallContext[T, E, B]) { + switch ctx.Method.Name() { + case "Identity": + analyzeIdentity(ctx) + default: + analyze(ctx) + } + } + analyzeConfigurerCallsInFunc( - &entityContext[T]{ - context: ctx, - EntityType: t, - Builder: builder, - ConfigureMethod: configure, - FunctionUnderAnalysis: configure, - ConfigurerParamIndices: []int{1}, - }, - func(ctx *configurerCallContext[T]) { - switch ctx.Method.Name() { - case "Identity": - analyzeIdentity(ctx) - default: - analyze(ctx) - } - }, + ectx, + fn, ) } // analyzeConfigurerCallsInFunc analyzes calls to methods on the configurer in // the function under analysis. -func analyzeConfigurerCallsInFunc[T configbuilder.EntityBuilder]( - ctx *entityContext[T], - analyze configurerCallAnalyzer[T], +func analyzeConfigurerCallsInFunc[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +]( + ctx *entityContext[T, E, B], + analyze configurerCallAnalyzer[T, E, B], ) { for b := range ssax.WalkFunc(ctx.FunctionUnderAnalysis) { for _, inst := range b.Instrs { @@ -92,27 +116,24 @@ func analyzeConfigurerCallsInFunc[T configbuilder.EntityBuilder]( // analyzeConfigurerCallsInInstruction analyzes calls to methods on the // configurer in the given instruction. -func analyzeConfigurerCallsInInstruction[T configbuilder.EntityBuilder]( - ctx *entityContext[T], +func analyzeConfigurerCallsInInstruction[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +]( + ctx *entityContext[T, E, B], inst ssa.CallInstruction, - analyze configurerCallAnalyzer[T], + analyze configurerCallAnalyzer[T, E, B], ) { com := inst.Common() if com.IsInvoke() && ctx.IsConfigurer(com.Value) { - // We've found a direct call to a method on the configurer. - var f config.Fidelity - if !ssax.IsUnconditional(inst.Block()) { - f |= config.Speculative - } - - analyze(&configurerCallContext[T]{ + analyze(&configurerCallContext[T, E, B]{ entityContext: ctx, CallCommon: com, Instruction: inst, - Fidelity: f, + IsSpeculative: !ssax.IsUnconditional(inst.Block()), }) - return } @@ -143,12 +164,12 @@ func analyzeConfigurerCallsInInstruction[T configbuilder.EntityBuilder]( // some other un-analyzable function. fn := com.StaticCallee() if fn == nil { - ctx.Builder.UpdateFidelity(config.Incomplete) + ctx.Builder.Partial() return } analyzeConfigurerCallsInFunc( - &entityContext[T]{ + &entityContext[T, E, B]{ context: ctx.context, EntityType: ctx.EntityType, Builder: ctx.Builder, @@ -160,24 +181,26 @@ func analyzeConfigurerCallsInInstruction[T configbuilder.EntityBuilder]( ) } -func analyzeIdentity[T configbuilder.EntityBuilder]( - ctx *configurerCallContext[T], +func analyzeIdentity[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +]( + ctx *configurerCallContext[T, E, B], ) { ctx. Builder. Identity(func(b *configbuilder.IdentityBuilder) { - b.UpdateFidelity(ctx.Fidelity) + if ctx.IsSpeculative { + b.Speculative() + } if name, ok := ssax.AsString(ctx.Args[0]).TryGet(); ok { - b.SetName(name) - } else { - b.UpdateFidelity(config.Incomplete) + b.Name(name) } if key, ok := ssax.AsString(ctx.Args[1]).TryGet(); ok { - b.SetKey(key) - } else { - b.UpdateFidelity(config.Incomplete) + b.Key(key) } }) } diff --git a/config/staticconfig/handler.go b/config/staticconfig/handler.go index 33dd592..e4b8568 100644 --- a/config/staticconfig/handler.go +++ b/config/staticconfig/handler.go @@ -1,23 +1,30 @@ package staticconfig import ( + "github.com/dogmatiq/dogma" "github.com/dogmatiq/enginekit/config" "github.com/dogmatiq/enginekit/config/internal/configbuilder" "github.com/dogmatiq/enginekit/config/staticconfig/internal/ssax" ) -func analyzeHandler[T configbuilder.HandlerBuilder]( - ctx *configurerCallContext[*configbuilder.ApplicationBuilder], - build func(func(T)), - analyze configurerCallAnalyzer[T], +func analyzeHandler[ + T config.Handler, + H any, + B configbuilder.HandlerBuilder[T, H], +]( + ctx *configurerCallContext[*config.Application, dogma.Application, *configbuilder.ApplicationBuilder], + build func(func(B)), + analyze configurerCallAnalyzer[T, H, B], ) { - build(func(b T) { - b.UpdateFidelity(ctx.Fidelity) + build(func(b B) { + if ctx.IsSpeculative { + b.Speculative() + } t := ssax.ConcreteType(ctx.Args[0]) if !t.IsPresent() { - b.UpdateFidelity(config.Incomplete) + b.Partial() return } @@ -25,45 +32,40 @@ func analyzeHandler[T configbuilder.HandlerBuilder]( ctx.context, t.Get(), b, - func(ctx *configurerCallContext[T]) { + func(ctx *configurerCallContext[T, H, B]) { switch ctx.Method.Name() { case "Routes": analyzeRoutes(ctx) case "Disable": - // TODO(jmalloc): f is lost in this case, so any handler - // that is _sometimes_ disabled will appear as always - // disabled, which is a bit non-sensical. - // - // It probably needs similar treatment to - // https://github.com/dogmatiq/enginekit/issues/55. - ctx.Builder.SetDisabled(true) + ctx.Builder.Disabled( + func(b *configbuilder.FlagBuilder[config.Disabled]) { + if ctx.IsSpeculative { + b.Speculative() + } + b.Value(true) + }, + ) default: if analyze == nil { - ctx.Builder.UpdateFidelity(config.Incomplete) + ctx.Builder.Partial() } else { analyze(ctx) } } }, ) - - // If the handler wasn't disabled, and the configuration is NOT - // incomplete, we know that the handler is enabled. - if !b.IsDisabled().IsPresent() && b.Fidelity()&config.Incomplete == 0 { - b.SetDisabled(false) - } }) } func analyzeProjectionConfigurerCall( - ctx *configurerCallContext[*configbuilder.ProjectionBuilder], + ctx *configurerCallContext[*config.Projection, dogma.ProjectionMessageHandler, *configbuilder.ProjectionBuilder], ) { switch ctx.Method.Name() { case "DeliveryPolicy": panic("not implemented") // TODO default: - ctx.Builder.UpdateFidelity(config.Incomplete) + ctx.Builder.Partial() } } diff --git a/config/staticconfig/route.go b/config/staticconfig/route.go index 50fb3cf..54d0688 100644 --- a/config/staticconfig/route.go +++ b/config/staticconfig/route.go @@ -7,12 +7,18 @@ import ( "golang.org/x/tools/go/ssa" ) -func analyzeRoutes[T configbuilder.HandlerBuilder]( - ctx *configurerCallContext[T], +func analyzeRoutes[ + T config.Handler, + H any, + B configbuilder.HandlerBuilder[T, H], +]( + ctx *configurerCallContext[T, H, B], ) { for r := range resolveVariadic(ctx.Builder, ctx.Instruction) { ctx.Builder.Route(func(b *configbuilder.RouteBuilder) { - b.UpdateFidelity(ctx.Fidelity) // TODO: is this correct? + if ctx.IsSpeculative { + b.Speculative() // TODO: is this correct? + } analyzeRoute(ctx.context, b, r) }) } @@ -25,7 +31,7 @@ func analyzeRoute( ) { call, ok := findRouteCall(ctx, r) if !ok { - b.UpdateFidelity(config.Incomplete) + b.Partial() return } @@ -33,18 +39,18 @@ func analyzeRoute( switch fn.Object() { case ctx.Dogma.HandlesCommand: - b.SetRouteType(config.HandlesCommandRouteType) + b.RouteType(config.HandlesCommandRouteType) case ctx.Dogma.HandlesEvent: - b.SetRouteType(config.HandlesEventRouteType) + b.RouteType(config.HandlesEventRouteType) case ctx.Dogma.ExecutesCommand: - b.SetRouteType(config.ExecutesCommandRouteType) + b.RouteType(config.ExecutesCommandRouteType) case ctx.Dogma.RecordsEvent: - b.SetRouteType(config.RecordsEventRouteType) + b.RouteType(config.RecordsEventRouteType) case ctx.Dogma.SchedulesTimeout: - b.SetRouteType(config.SchedulesTimeoutRouteType) + b.RouteType(config.SchedulesTimeoutRouteType) } - b.SetMessageTypeName(typename.OfStatic(fn.TypeArgs()[0])) + b.MessageTypeName(typename.OfStatic(fn.TypeArgs()[0])) } func findRouteCall( diff --git a/config/staticconfig/testdata/alias-for-generic.md b/config/staticconfig/testdata/alias-for-generic.md index dc02eb0..3bcba29 100644 --- a/config/staticconfig/testdata/alias-for-generic.md +++ b/config/staticconfig/testdata/alias-for-generic.md @@ -4,7 +4,7 @@ This test ensures that the static analyzer finds an instantiated generic type that implements the `dogma.Application` interface. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.Alias (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.Alias (value unavailable) - valid identity app/8a6baab1-ee64-402e-a081-e43f4bebc243 ``` diff --git a/config/staticconfig/testdata/conditional-excluded-by-const-expr.md b/config/staticconfig/testdata/conditional-excluded-by-const-expr.md index 3b16d7c..45f9f94 100644 --- a/config/staticconfig/testdata/conditional-excluded-by-const-expr.md +++ b/config/staticconfig/testdata/conditional-excluded-by-const-expr.md @@ -4,8 +4,8 @@ This test verifies that the static analyzer excludes information about an entity's identity if it appears in an unreachable branch. ```au:output au:group=matrix -invalid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) - - no identity is configured +invalid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) + - no identity ``` ## After conditional return diff --git a/config/staticconfig/testdata/conditional-included-by-const-expr.md b/config/staticconfig/testdata/conditional-included-by-const-expr.md index a100a6a..06211e7 100644 --- a/config/staticconfig/testdata/conditional-included-by-const-expr.md +++ b/config/staticconfig/testdata/conditional-included-by-const-expr.md @@ -5,7 +5,7 @@ entity's identity if it appears in a conditional block that is always executed. Note that the identity is not marked as "speculative". ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/de142370-93ee-409c-9336-5084d9c5e285 ``` diff --git a/config/staticconfig/testdata/conditional-present-in-method.md b/config/staticconfig/testdata/conditional-present-in-method.md index 620a487..f3ffeac 100644 --- a/config/staticconfig/testdata/conditional-present-in-method.md +++ b/config/staticconfig/testdata/conditional-present-in-method.md @@ -5,7 +5,7 @@ entity's identity even if it appears after (but not within) a conditional statement. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/de142370-93ee-409c-9336-5084d9c5e285 ``` diff --git a/config/staticconfig/testdata/conditional.md b/config/staticconfig/testdata/conditional.md index f2f8853..dd0ebac 100644 --- a/config/staticconfig/testdata/conditional.md +++ b/config/staticconfig/testdata/conditional.md @@ -4,7 +4,7 @@ This test verifies that the static analyzer includes information about an entity's identity when it is defined within a conditional statement. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid speculative identity app/de142370-93ee-409c-9336-5084d9c5e285 ``` diff --git a/config/staticconfig/testdata/handler-aggregate.md b/config/staticconfig/testdata/handler-aggregate.md index d84ecb3..0faa880 100644 --- a/config/staticconfig/testdata/handler-aggregate.md +++ b/config/staticconfig/testdata/handler-aggregate.md @@ -4,12 +4,13 @@ This test ensures that the static analyzer supports all aspects of configuring an aggregate handler. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/0726ae0d-67e4-4a50-8a19-9f58eae38e51 - - disabled valid aggregate github.com/dogmatiq/enginekit/config/staticconfig.Aggregate (runtime type unavailable) + - valid aggregate github.com/dogmatiq/enginekit/config/staticconfig.Aggregate (value unavailable) - valid identity aggregate/916e5e95-70c4-4823-9de2-0f7389d18b4f - - valid handles-command route for github.com/dogmatiq/enginekit/enginetest/stubs.CommandStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) - - valid records-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) + - valid handles-command route for github.com/dogmatiq/enginekit/enginetest/stubs.CommandStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid records-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid disabled flag, set to true ``` ```go au:input au:group=matrix diff --git a/config/staticconfig/testdata/handler-integration.md b/config/staticconfig/testdata/handler-integration.md index 8786aa7..0baa37a 100644 --- a/config/staticconfig/testdata/handler-integration.md +++ b/config/staticconfig/testdata/handler-integration.md @@ -4,12 +4,13 @@ This test ensures that the static analyzer supports all aspects of configuring an integration handler. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/0726ae0d-67e4-4a50-8a19-9f58eae38e51 - - disabled valid integration github.com/dogmatiq/enginekit/config/staticconfig.Integration (runtime type unavailable) + - valid integration github.com/dogmatiq/enginekit/config/staticconfig.Integration (value unavailable) - valid identity integration/b92431e6-3a7d-4235-a76f-541622c487ee - - valid handles-command route for github.com/dogmatiq/enginekit/enginetest/stubs.CommandStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) - - valid records-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) + - valid handles-command route for github.com/dogmatiq/enginekit/enginetest/stubs.CommandStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid records-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid disabled flag, set to true ``` ```go au:input au:group=matrix diff --git a/config/staticconfig/testdata/handler-process.md b/config/staticconfig/testdata/handler-process.md index 4e9f03c..adcd082 100644 --- a/config/staticconfig/testdata/handler-process.md +++ b/config/staticconfig/testdata/handler-process.md @@ -4,13 +4,14 @@ This test ensures that the static analyzer supports all aspects of configuring a process handler. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/0726ae0d-67e4-4a50-8a19-9f58eae38e51 - - disabled valid process github.com/dogmatiq/enginekit/config/staticconfig.Process (runtime type unavailable) + - valid process github.com/dogmatiq/enginekit/config/staticconfig.Process (value unavailable) - valid identity process/4ff1b1c1-5c64-49bc-a547-c13f5bafad7d - - valid handles-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) - - valid executes-command route for github.com/dogmatiq/enginekit/enginetest/stubs.CommandStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) - - valid schedules-timeout route for github.com/dogmatiq/enginekit/enginetest/stubs.TimeoutStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) + - valid handles-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid executes-command route for github.com/dogmatiq/enginekit/enginetest/stubs.CommandStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid schedules-timeout route for github.com/dogmatiq/enginekit/enginetest/stubs.TimeoutStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid disabled flag, set to true ``` ```go au:input au:group=matrix diff --git a/config/staticconfig/testdata/handler-projection.md b/config/staticconfig/testdata/handler-projection.md index 6124cd5..4902509 100644 --- a/config/staticconfig/testdata/handler-projection.md +++ b/config/staticconfig/testdata/handler-projection.md @@ -4,11 +4,12 @@ This test ensures that the static analyzer supports all aspects of configuring a projection handler. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/0726ae0d-67e4-4a50-8a19-9f58eae38e51 - - disabled valid projection github.com/dogmatiq/enginekit/config/staticconfig.Projection (runtime type unavailable) + - valid projection github.com/dogmatiq/enginekit/config/staticconfig.Projection (value unavailable) - valid identity projection/238d7498-515b-44b5-b6a8-914a08762ecc - - valid handles-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (runtime type unavailable) + - valid handles-event route for github.com/dogmatiq/enginekit/enginetest/stubs.EventStub[github.com/dogmatiq/enginekit/enginetest/stubs.TypeA] (type unavailable) + - valid disabled flag, set to true ``` ```go au:input au:group=matrix diff --git a/config/staticconfig/testdata/handler-with-unregistered-routes.md b/config/staticconfig/testdata/handler-with-unregistered-routes.md index eb50208..8f87c45 100644 --- a/config/staticconfig/testdata/handler-with-unregistered-routes.md +++ b/config/staticconfig/testdata/handler-with-unregistered-routes.md @@ -5,10 +5,10 @@ routes that are constructed but never passed to the configurer's `Routes()` method. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/f2c08525-623e-4c76-851c-3172953269e3 - - invalid integration github.com/dogmatiq/enginekit/config/staticconfig.Integration (runtime type unavailable) - - no "handles-command" routes are configured + - invalid integration github.com/dogmatiq/enginekit/config/staticconfig.Integration (value unavailable) + - no handles-command routes - valid identity handler/ac391765-da58-4e7c-a478-e4725eb2b0e9 ``` diff --git a/config/staticconfig/testdata/identity-from-const.md b/config/staticconfig/testdata/identity-from-const.md index 06e9192..e4255e3 100644 --- a/config/staticconfig/testdata/identity-from-const.md +++ b/config/staticconfig/testdata/identity-from-const.md @@ -4,7 +4,7 @@ This test verifies that the static analyzer can discover the values within an entity's identity when they are sourced from non-literal constant expressions. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/d0de39ba-aaaf-43fd-8e8f-7c4e3be309ec ``` diff --git a/config/staticconfig/testdata/identity-from-non-const-static.md b/config/staticconfig/testdata/identity-from-non-const-static.md index 480cdb5..84c2648 100644 --- a/config/staticconfig/testdata/identity-from-non-const-static.md +++ b/config/staticconfig/testdata/identity-from-non-const-static.md @@ -4,7 +4,7 @@ This test verifies that the static analyzer includes an entity's identity, even if it cannot determine the values used. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/a0a0edb7-ce45-4eb4-940c-0f77459ae2a0 ``` diff --git a/config/staticconfig/testdata/identity-from-non-const.md b/config/staticconfig/testdata/identity-from-non-const.md index e6a9ec2..3a2f80f 100644 --- a/config/staticconfig/testdata/identity-from-non-const.md +++ b/config/staticconfig/testdata/identity-from-non-const.md @@ -4,8 +4,10 @@ This test verifies that the static analyzer includes an entity's identity, even if it cannot determine the values used. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) - - incomplete identity ?/? +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) + - incomplete identity + - name is unavailable + - key is unavailable ``` ## Variables diff --git a/config/staticconfig/testdata/incomplete-entity.md b/config/staticconfig/testdata/incomplete-entity.md index e17d8ec..116421e 100644 --- a/config/staticconfig/testdata/incomplete-entity.md +++ b/config/staticconfig/testdata/incomplete-entity.md @@ -5,7 +5,8 @@ incomplete if the `Configure()` method calls into code that is unable to be analyzed. ```au:output au:group=matrix -incomplete application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +incomplete application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) + - could not evaluate entire configuration - valid identity app/de142370-93ee-409c-9336-5084d9c5e285 ``` diff --git a/config/staticconfig/testdata/indirect.md b/config/staticconfig/testdata/indirect.md index b77a3ef..2425f3b 100644 --- a/config/staticconfig/testdata/indirect.md +++ b/config/staticconfig/testdata/indirect.md @@ -5,7 +5,7 @@ This test verifies that the static analyzer traverses into code called from the `ApplicationConfigurer` interface. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/de142370-93ee-409c-9336-5084d9c5e285 ``` diff --git a/config/staticconfig/testdata/multiple-apps.md b/config/staticconfig/testdata/multiple-apps.md index 0ab2303..792cf40 100644 --- a/config/staticconfig/testdata/multiple-apps.md +++ b/config/staticconfig/testdata/multiple-apps.md @@ -4,10 +4,10 @@ This test verifies that the static analyzer discovers multiple Dogma application types defined within the same Go package. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.One (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.One (value unavailable) - valid identity one/4fec74a1-6ed4-46f4-8417-01e0910be8f1 -valid application github.com/dogmatiq/enginekit/config/staticconfig.Two (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.Two (value unavailable) - valid identity two/6e97d403-3cb8-4a59-a7ec-74e8e219a7bc ``` diff --git a/config/staticconfig/testdata/nil-handlers.md b/config/staticconfig/testdata/nil-handlers.md index edeb1bb..f6172e3 100644 --- a/config/staticconfig/testdata/nil-handlers.md +++ b/config/staticconfig/testdata/nil-handlers.md @@ -4,22 +4,26 @@ This test ensures that the static analyzer includes basic information about the presence of `nil` handlers. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/0726ae0d-67e4-4a50-8a19-9f58eae38e51 - incomplete aggregate - - no identity is configured - - no "handles-command" routes are configured - - no "records-event" routes are configured + - could not evaluate entire configuration + - no identity + - no handles-command routes + - no records-event routes - incomplete process - - no identity is configured - - no "handles-event" routes are configured - - no "executes-command" routes are configured + - could not evaluate entire configuration + - no identity + - no handles-event routes + - no executes-command routes - incomplete integration - - no identity is configured - - no "handles-command" routes are configured + - could not evaluate entire configuration + - no identity + - no handles-command routes - incomplete projection - - no identity is configured - - no "handles-event" routes are configured + - could not evaluate entire configuration + - no identity + - no handles-event routes ``` ```go au:input au:group=matrix diff --git a/config/staticconfig/testdata/no-handlers.md b/config/staticconfig/testdata/no-handlers.md index e129ba0..1fb8888 100644 --- a/config/staticconfig/testdata/no-handlers.md +++ b/config/staticconfig/testdata/no-handlers.md @@ -4,7 +4,7 @@ This test ensures that the static analyzer includes Dogma applications that have no handlers. ```au:output au:group=matrix -valid application github.com/dogmatiq/enginekit/config/staticconfig.App (runtime type unavailable) +valid application github.com/dogmatiq/enginekit/config/staticconfig.App (value unavailable) - valid identity app/8a6baab1-ee64-402e-a081-e43f4bebc243 ``` diff --git a/config/staticconfig/varargs.go b/config/staticconfig/varargs.go index 0f0ea06..0bf7a55 100644 --- a/config/staticconfig/varargs.go +++ b/config/staticconfig/varargs.go @@ -43,8 +43,12 @@ func isIndexOfArray( return 0, false } -func resolveVariadic( - b configbuilder.EntityBuilder, +func resolveVariadic[ + T config.Entity, + E any, + B configbuilder.EntityBuilder[T, E], +]( + b B, inst ssa.CallInstruction, ) iter.Seq[ssa.Value] { return func(yield func(ssa.Value) bool) { @@ -57,7 +61,7 @@ func resolveVariadic( array, ok := findAllocation(variadics) if !ok { - b.UpdateFidelity(config.Incomplete) + b.Partial() return }