Merge pull request #3297 from github/koesie10/more-consistency-information
Add more information for consistency check errors
This commit is contained in:
@@ -3,7 +3,10 @@ import type { ModeledMethod } from "./modeled-method";
|
||||
import type { BaseLogger } from "../common/logging";
|
||||
|
||||
interface Notifier {
|
||||
missingMethod(signature: string): void;
|
||||
missingMethod(
|
||||
signature: string,
|
||||
modeledMethods: readonly ModeledMethod[],
|
||||
): void;
|
||||
inconsistentSupported(signature: string, expectedSupported: boolean): void;
|
||||
}
|
||||
|
||||
@@ -21,14 +24,14 @@ export function checkConsistency(
|
||||
);
|
||||
|
||||
for (const signature in modeledMethods) {
|
||||
const modeledMethodsForSignature = modeledMethods[signature];
|
||||
|
||||
const method = methodsBySignature[signature];
|
||||
if (!method) {
|
||||
notifier.missingMethod(signature);
|
||||
notifier.missingMethod(signature, modeledMethodsForSignature);
|
||||
continue;
|
||||
}
|
||||
|
||||
const modeledMethodsForSignature = modeledMethods[signature];
|
||||
|
||||
checkMethodConsistency(method, modeledMethodsForSignature, notifier);
|
||||
}
|
||||
}
|
||||
@@ -51,9 +54,14 @@ function checkMethodConsistency(
|
||||
export class DefaultNotifier implements Notifier {
|
||||
constructor(private readonly logger: BaseLogger) {}
|
||||
|
||||
missingMethod(signature: string) {
|
||||
missingMethod(signature: string, modeledMethods: readonly ModeledMethod[]) {
|
||||
const modelTypes = modeledMethods
|
||||
.map((m) => m.type)
|
||||
.filter((t) => t !== "none")
|
||||
.join(", ");
|
||||
|
||||
void this.logger.log(
|
||||
`Model editor query consistency check: Missing method ${signature} for method that is modeled.`,
|
||||
`Model editor query consistency check: Missing method ${signature} for method that is modeled as ${modelTypes}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,20 @@ describe("checkConsistency", () => {
|
||||
});
|
||||
|
||||
it("should call missingMethod when method is missing", () => {
|
||||
const modeledMethods = [createSourceModeledMethod()];
|
||||
|
||||
checkConsistency(
|
||||
[],
|
||||
{
|
||||
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)":
|
||||
[createSourceModeledMethod()],
|
||||
modeledMethods,
|
||||
},
|
||||
notifier,
|
||||
);
|
||||
|
||||
expect(notifier.missingMethod).toHaveBeenCalledWith(
|
||||
"Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SeparatedList`1(System.Collections.Generic.IEnumerable<TNode>)",
|
||||
modeledMethods,
|
||||
);
|
||||
expect(notifier.inconsistentSupported).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user