winmd 0.4.0-dev.2 copy "winmd: ^0.4.0-dev.2" to clipboard
winmd: ^0.4.0-dev.2 copied to clipboard

outdated

A Dart library for working with Windows Metadata (winmd) formats.

example/main.dart

// Copyright (c) 2020, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Parse the Windows Metadata for a type and interpret its metadata

// Sources of inspiration:
// https://stackoverflow.com/questions/54375771/how-to-read-a-winmd-winrt-metadata-file
// https://docs.microsoft.com/en-us/windows/win32/api/rometadataresolution/nf-rometadataresolution-rogetmetadatafile
// https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-335.pdf

import 'dart:io';

import 'package:winmd/winmd.dart';

final typesToGenerate = [
  'Windows.Foundation.IPropertyValue',
  'Windows.Foundation.IAsyncInfo',
  'Windows.Foundation.IClosable',
  'Windows.Foundation.IStringable',
];

void main(List<String> args) {
  final outputDirectory = (args.length == 1)
      ? Directory(args.first)
      : Directory('lib/src/generated');

  for (final type in typesToGenerate) {
    final mdTypeDef = MetadataStore.getMetadataForType(type)!;
    final projection = TypeBuilder.projectWindowsType(mdTypeDef);
    final dartClass = TypePrinter.printType(projection);

    final outputFilename = type.split('.').last;
    final outputFile =
        File('${outputDirectory.uri.toFilePath()}$outputFilename.dart');

    print('Writing:    ${outputFile.path}');
    outputFile.writeAsStringSync(dartClass);
  }
}
8
likes
0
pub points
57%
popularity

Publisher

verified publisherhalildurmus.dev

A Dart library for working with Windows Metadata (winmd) formats.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

ffi, win32

More

Packages that depend on winmd