hunk.code_window:     expect(fileString).not.toContain('canActivateChild');
       expect(fileString).not.toContain('CanLoad');
       expect(fileString).not.toContain('canLoad');
     });
     it('should respect the guardType value', async () => {
       const options = { ...defaultOptions, guardType: 'canActivate' };
       const tree = await schematicRunner.runSchematicAsync('guard', options, appTree).toPromise();
       const fileString = tree.readContent('/projects/bar/src/app/foo.guard.ts');
       expect(fileString).toContain('export const fooGuard: CanActivateFn = (route, state) => {');
       expect(fileString).not.toContain('CanActivateChild');
  
hunk.labels: keep keep keep keep keep replace replace keep keep keep keep
hunk.after_edit:   it('should respect the functional guard value', async () => {
       const options = { ...defaultOptions, implements: ['CanActivate'], functional: true };
  
hunk.file_path: packages/schematics/angular/guard/index_spec.ts
hunk.type: replace
file: /**
   * @license
   * Copyright Google LLC All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  
  import type { Diagnostics } from '@angular/localize/tools';
  import { createHash } from 'crypto';
  import * as fs from 'fs';
  import { loadEsmModule } from './load-esm';
  
  export type TranslationLoader = (path: string) => {
    translations: Record<string, import('@angular/localize').ɵParsedTranslation>;
    format: string;
    locale?: string;
    diagnostics: Diagnostics;
    integrity: string;
  };
  
  export async function createTranslationLoader(): Promise<TranslationLoader> {
    const { parsers, diagnostics } = await importParsers();
  
    return (path: string) => {
      const content = fs.readFileSync(path, 'utf8');
      const unusedParsers = new Map();
      for (const [format, parser] of Object.entries(parsers)) {
        const analysis = parser.analyze(path, content);
        if (analysis.canParse) {
          // Types don't overlap here so we need to use any.
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
          const { locale, translations } = parser.parse(path, content, analysis.hint as any);
          const integrity = 'sha256-' + createHash('sha256').update(content).digest('base64');
  
          return { format, locale, translations, diagnostics, integrity };
        } else {
          unusedParsers.set(parser, analysis);
        }
      }
  
      const messages: string[] = [];
      for (const [parser, analysis] of unusedParsers.entries()) {
        messages.push(analysis.diagnostics.formatDiagnostics(`*** ${parser.constructor.name} ***`));
      }
      throw new Error(
        `Unsupported translation file format in ${path}. The following parsers were tried:\n` +
          messages.join('\n'),
      );
    };
  }
  
  async function importParsers() {
    try {
      // Load ESM `@angular/localize/tools` using the TypeScript dynamic import workaround.
      // Once TypeScript provides support for keeping the dynamic import this workaround can be
      // changed to a direct dynamic import.
      const {
        Diagnostics,
        ArbTranslationParser,
        SimpleJsonTranslationParser,
        Xliff1TranslationParser,
        Xliff2TranslationParser,
        XtbTranslationParser,
      } = await loadEsmModule<typeof import('@angular/localize/tools')>('@angular/localize/tools');
  
      const diagnostics = new Diagnostics();
      const parsers = {
        arb: new ArbTranslationParser(),
        json: new SimpleJsonTranslationParser(),
        xlf: new Xliff1TranslationParser(),
        xlf2: new Xliff2TranslationParser(),
        // The name ('xmb') needs to match the AOT compiler option
        xmb: new XtbTranslationParser(),
      };
  
      return { parsers, diagnostics };
    } catch {
      throw new Error(
        `Unable to load translation file parsers. Please ensure '@angular/localize' is installed.`,
      );
    }
  }
  